Skip to content

Commit

Permalink
Improve spec by using per_page 2. This makes the previous version (ma…
Browse files Browse the repository at this point in the history
…ster at this time) fail in the first page where products come in the wrong order (product 8 and then product 7)
  • Loading branch information
luisramos0 committed Oct 31, 2019
1 parent 67a5a1c commit 9302e25
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions spec/controllers/api/order_cycles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,16 @@ module Api
end

it "displays products in correct order across multiple pages" do
api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3
expect(product_ids).to eq [product7.id, product8.id, product2.id]
api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 2
expect(product_ids).to eq [product7.id, product8.id]

api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3, page: 2
expect(product_ids).to eq [product3.id, product5.id, product6.id]
api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 2, page: 2
expect(product_ids).to eq [product2.id, product3.id]

api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 3, page: 3
api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 2, page: 3
expect(product_ids).to eq [product5.id, product6.id]

api_get :products, id: order_cycle.id, distributor: distributor.id, per_page: 2, page: 4
expect(product_ids).to eq [product1.id]
end
end
Expand Down

0 comments on commit 9302e25

Please sign in to comment.