Skip to content

Commit 4138837

Browse files
authored
fix number of purchases appearing on paginated purchases (#4854)
1 parent c193eee commit 4138837

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

app/views/purchases/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
</tr>
9090
</thead>
9191
<tbody>
92-
<%= render partial: "purchase_row", collection: @purchases %>
92+
<%= render partial: "purchase_row", collection: @paginated_purchases %>
9393
</tbody>
9494
<tfoot>
9595
<tr>

spec/requests/purchases_requests_spec.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,27 @@
3737
expect(subject.body).to include("Comments")
3838
expect(subject.body).to include("Purchase Comment")
3939
end
40+
41+
describe "pagination" do
42+
around do |ex|
43+
Kaminari.config.default_per_page = 2
44+
ex.run
45+
Kaminari.config.default_per_page = 50
46+
end
47+
before do
48+
item = create(:item, organization: organization)
49+
purchase_1 = create(:purchase, organization: organization, comment: "Singleton", issued_at: 1.day.ago)
50+
create(:line_item, item: item, itemizable: purchase_1, quantity: 2)
51+
purchase_2 = create(:purchase, organization: organization, comment: "Twins", issued_at: 2.days.ago)
52+
create(:line_item, item: item, itemizable: purchase_2, quantity: 2)
53+
purchase_3 = create(:purchase, organization: organization, comment: "Fates", issued_at: 3.days.ago)
54+
create(:line_item, item: item, itemizable: purchase_3, quantity: 2)
55+
end
56+
57+
it "puts the right number of purchases on the page" do
58+
expect(subject.body).to include(" View").twice
59+
end
60+
end
4061
end
4162

4263
context "csv" do

0 commit comments

Comments
 (0)