|
100 | 100 | it "should include the storage location name" do |
101 | 101 | expect(subject.body).to include("Pawane Location") |
102 | 102 | end |
| 103 | + |
| 104 | + context "when creating a new donation" do |
| 105 | + let!(:inactive_donation_site) { create(:donation_site, organization: organization, active: false) } |
| 106 | + |
| 107 | + it "does not include inactive donation sites" do |
| 108 | + subject |
| 109 | + expect(response.body).not_to include(inactive_donation_site.name) |
| 110 | + end |
| 111 | + end |
103 | 112 | end |
104 | 113 |
|
105 | 114 | describe "POST #create" do |
|
265 | 274 | expect(response.body).to include("you’ll need to make an adjustment to the inventory as well.") |
266 | 275 | end |
267 | 276 | end |
| 277 | + |
| 278 | + context "when editing a donation with an inactive donation site" do |
| 279 | + let!(:active_donation_site) { create(:donation_site, organization: organization, name: "Active Donation Site") } |
| 280 | + let!(:inactive_donation_site) { create(:donation_site, organization: organization, active: false, name: "Inactive Donation Site") } |
| 281 | + let!(:donation_with_inactive_site) { create(:donation, organization: organization, donation_site: inactive_donation_site) } |
| 282 | + |
| 283 | + it "includes the inactive donation site in the dropdown" do |
| 284 | + get edit_donation_path(donation_with_inactive_site) |
| 285 | + expect(response.body).to include(inactive_donation_site.name) |
| 286 | + end |
| 287 | + |
| 288 | + it "displays the donation site names alphabetically" do |
| 289 | + get edit_donation_path(donation_with_inactive_site) |
| 290 | + |
| 291 | + # Get all donation site names that should be in the dropdown and sort them |
| 292 | + donation_sites = [active_donation_site, inactive_donation_site] |
| 293 | + sorted_names = donation_sites.map(&:name).sort |
| 294 | + |
| 295 | + # Verify that the donation sites are alphabetized |
| 296 | + expect(sorted_names[0]).to eq(active_donation_site.name) |
| 297 | + expect(sorted_names[1]).to eq(inactive_donation_site.name) |
| 298 | + end |
| 299 | + end |
268 | 300 | end |
269 | 301 |
|
270 | 302 | context "when an non-finalized audit has been performed on the donated items" do |
|
0 commit comments