From 7b50792bd44242fae89cdfee2d923b62bd8bbcde Mon Sep 17 00:00:00 2001 From: CL Fisher Date: Sat, 14 Dec 2024 09:55:41 -0500 Subject: [PATCH] fix number of purchases appearing on paginated purchases --- app/views/purchases/index.html.erb | 2 +- spec/requests/purchases_requests_spec.rb | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/app/views/purchases/index.html.erb b/app/views/purchases/index.html.erb index cdbda040b8..42f2d482f6 100644 --- a/app/views/purchases/index.html.erb +++ b/app/views/purchases/index.html.erb @@ -89,7 +89,7 @@ - <%= render partial: "purchase_row", collection: @purchases %> + <%= render partial: "purchase_row", collection: @paginated_purchases %> diff --git a/spec/requests/purchases_requests_spec.rb b/spec/requests/purchases_requests_spec.rb index f1167cf9b2..3e51348c1e 100644 --- a/spec/requests/purchases_requests_spec.rb +++ b/spec/requests/purchases_requests_spec.rb @@ -37,6 +37,27 @@ expect(subject.body).to include("Comments") expect(subject.body).to include("Purchase Comment") end + + describe "pagination" do + around do |ex| + Kaminari.config.default_per_page = 2 + ex.run + Kaminari.config.default_per_page = 50 + end + before do + item = create(:item, organization: organization) + purchase_1 = create(:purchase, organization: organization, comment: "Singleton", issued_at: 1.day.ago) + create(:line_item, item: item, itemizable: purchase_1, quantity: 2) + purchase_2 = create(:purchase, organization: organization, comment: "Twins", issued_at: 2.days.ago) + create(:line_item, item: item, itemizable: purchase_2, quantity: 2) + purchase_3 = create(:purchase, organization: organization, comment: "Fates", issued_at: 3.days.ago) + create(:line_item, item: item, itemizable: purchase_3, quantity: 2) + end + + it "puts the right number of purchases on the page" do + expect(subject.body).to include(" View").twice + end + end end context "csv" do