Skip to content

Commit edc66cd

Browse files
committed
Tests for date range input pages
1 parent 33ccf43 commit edc66cd

8 files changed

Lines changed: 74 additions & 0 deletions

spec/requests/adjustments_requests_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
end
6969
end
7070
end
71+
72+
it "falls back to default date range and renders without error when given an invalid date_range param" do
73+
get adjustments_path(format: :html, params: {
74+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
75+
})
76+
77+
expect(response).to be_successful
78+
expect(response.body).to include("The date range you supplied was invalid")
79+
end
80+
7181
end
7282

7383
context "csv" do

spec/requests/distributions_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@
7575
expect(response).to be_successful
7676
end
7777

78+
it "falls back to default date range and renders without error when given an invalid date_range param" do
79+
get distributions_path(format: :html, params: {
80+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
81+
})
82+
83+
expect(response).to be_successful
84+
expect(response.body).to include("The date range you supplied was invalid")
85+
end
86+
7887
it "sums distribution totals accurately" do
7988
create(:distribution, :with_items, item_quantity: 5, organization: organization)
8089
create(:line_item, :distribution, itemizable_id: distribution.id, quantity: 7)

spec/requests/donations_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@
8080
expect(subject.body).to_not include("<td>#{full_comment}</td>")
8181
end
8282
end
83+
84+
it "falls back to default date range and renders without error when given an invalid date_range param" do
85+
get donations_path(format: :html, params: {
86+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
87+
})
88+
89+
expect(response).to be_successful
90+
expect(response.body).to include("The date range you supplied was invalid")
91+
end
8392
end
8493

8594
context "csv" do

spec/requests/events_requests_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,16 @@
211211
expect(response.body).to include("88<br>")
212212
expect(response.body).not_to include("99<br>")
213213
end
214+
215+
it "falls back to default date range and renders without error when given an invalid date_range param" do
216+
get events_path(format: :html, params: {
217+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
218+
})
219+
220+
expect(response).to be_successful
221+
expect(response.body).to include("The date range you supplied was invalid")
222+
end
223+
214224
end
215225

216226
context "with eventable_id" do

spec/requests/product_drives_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@
5151
let(:index_path) { product_drives_path(params) }
5252
end
5353

54+
it "falls back to default date range and renders without error when given an invalid date_range param" do
55+
get product_drives_path(format: :html, params: {
56+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
57+
})
58+
59+
expect(response).to be_successful
60+
expect(response.body).to include("The date range you supplied was invalid")
61+
end
62+
5463
context "csv" do
5564
it 'is successful' do
5665
get product_drives_path(format: :csv)

spec/requests/purchases_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
expect(subject.body).to include("Purchase Comment")
3939
end
4040

41+
it "falls back to default date range and renders without error when given an invalid date_range param" do
42+
get purchases_path(format: :html, params: {
43+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
44+
})
45+
46+
expect(response).to be_successful
47+
expect(response.body).to include("The date range you supplied was invalid")
48+
end
49+
4150
context "with multiple purchases" do
4251
let!(:storage_location) { create(:storage_location, organization: organization) }
4352
let(:vendor) { create(:vendor, organization: organization) }

spec/requests/requests_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
let(:response_format) { 'html' }
2020

2121
it { is_expected.to be_successful }
22+
23+
it "falls back to default date range and renders without error when given an invalid date_range param" do
24+
get requests_path(format: :html, params: {
25+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
26+
})
27+
28+
expect(response).to be_successful
29+
expect(response.body).to include("The date range you supplied was invalid")
30+
end
2231
end
2332

2433
context "csv" do

spec/requests/transfers_requests_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@
3636
get transfers_path(filters: { date_range: "#{start_date} - #{end_date}" })
3737
expect(assigns(:transfers)).to eq([new_transfer])
3838
end
39+
40+
it "falls back to default date range and renders without error when given an invalid date_range param" do
41+
get transfers_path(format: :html, params: {
42+
filters: { date_range: "Foo 10, 2025 - Bar 20, 2025" }
43+
})
44+
45+
expect(response).to be_successful
46+
expect(response.body).to include("The date range you supplied was invalid")
47+
end
3948
end
4049

4150
context 'when date parameters are not supplied' do

0 commit comments

Comments
 (0)