Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1236 from YaleSTC/1235_fix_empty_cart_redirect
Browse files Browse the repository at this point in the history
[1235] Empty cart redirects to the previous page
  • Loading branch information
orenyk committed Apr 26, 2015
2 parents ae4aedb + e6cd2f5 commit fdd6710
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/reservations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def new # rubocop:disable MethodLength, PerceivedComplexity
if cart.items.empty?
flash[:error] = 'You need to add items to your cart before making a '\
'reservation.'
redirect_to catalog_path
redirect_to :back
else
# error handling
@errors = cart.validate_all
Expand Down
7 changes: 5 additions & 2 deletions spec/controllers/reservations_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,16 @@
end

context 'when accessed by a non-banned user' do
before(:each) { sign_in @user }
before(:each) do
sign_in @user
request.env['HTTP_REFERER'] = 'where_i_came_from'
end

context 'with an empty cart' do
before(:each) do
get :new
end
it { expect(response).to be_redirect }
it { expect(response).to redirect_to('where_i_came_from') }
it { is_expected.to set_flash }
end

Expand Down

0 comments on commit fdd6710

Please sign in to comment.