mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Restore old pagination API for products
It's still used by the inventory page. This is an easy fix that I can deploy without risk. A rewrite of the inventory pagination should follow.
This commit is contained in:
@@ -127,6 +127,9 @@ module Api
|
||||
|
||||
render text: {
|
||||
products: serializer,
|
||||
# This line is used by the PagedFetcher JS service (inventory).
|
||||
pages: products.num_pages,
|
||||
# This hash is used by the BulkProducts JS service.
|
||||
pagination: pagination_data(products)
|
||||
}.to_json
|
||||
end
|
||||
|
||||
34
spec/features/admin/inventory_spec.rb
Normal file
34
spec/features/admin/inventory_spec.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
require "spec_helper"
|
||||
|
||||
feature "Managing inventory", js: true do
|
||||
include AdminHelper
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
it "shows more than 100 products" do
|
||||
supplier = create(:supplier_enterprise, sells: "own")
|
||||
inventory_items = (1..101).map do
|
||||
product = create(:simple_product, supplier: supplier)
|
||||
InventoryItem.create!(
|
||||
enterprise: supplier,
|
||||
variant: product.variants.first,
|
||||
visible: true
|
||||
)
|
||||
end
|
||||
first_variant = inventory_items.first.variant
|
||||
last_variant = inventory_items.last.variant
|
||||
first_variant.product.update_attributes!(name: "A First Product")
|
||||
last_variant.product.update_attributes!(name: "Z Last Product")
|
||||
quick_login_as supplier.users.first
|
||||
visit admin_inventory_path
|
||||
|
||||
expect(page).to have_text first_variant.name
|
||||
expect(page).to have_selector "tr.product", count: 10
|
||||
expect(page).to have_button "Show more"
|
||||
expect(page).to have_button "Show all (91 More)"
|
||||
|
||||
click_button "Show all (91 More)"
|
||||
expect(page).to have_selector "tr.product", count: 101
|
||||
expect(page).to have_text last_variant.name
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user