Skip to content

Commit

Permalink
GREEN fix donations controller spec to expect redirect
Browse files Browse the repository at this point in the history
Error message changes if using events or not, add cases for both
  • Loading branch information
jimmyli97 committed Jun 28, 2024
1 parent a25a0d2 commit 0585857
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spec/controllers/donations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
}
donation_params = { source: donation.source, storage_location: new_storage_location, line_items_attributes: line_item_params }
put :update, params: { id: donation.id, donation: donation_params }
expect(response).not_to redirect_to(anything)
expect(response).to redirect_to(edit_donation_path(donation))
expect(original_storage_location.size).to eq 5
expect(new_storage_location.size).to eq 0
expect(donation.reload.line_items.first.quantity).to eq 10
Expand Down
7 changes: 6 additions & 1 deletion spec/requests/donations_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@

get response.headers['Location']

expect(flash[:alert]).to include("Error updating donation: Requested items exceed the available inventory")
if Event.read_events?(organization)
expect(flash[:alert]).to include("Error updating donation: Could not reduce quantity by 99 - current quantity is 10 for Brightbloom Seed")
else # TODO remove this branch when switching to events
expect(flash[:alert]).to include("Error updating donation: Requested items exceed the available inventory")
end

expect(response.body).to include(item.name)
expect(response.body).to include(original_quantity.to_s)
end
Expand Down

0 comments on commit 0585857

Please sign in to comment.