Skip to content

Commit

Permalink
Check referer on holds/result (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
Banu Hapeloglu Kutlu authored Oct 27, 2020
1 parent 12e6a7d commit d6147aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/controllers/holds_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class HoldsController < ApplicationController
before_action :unless_maintenance_mode, only: :new
rescue_from NewHoldException, with: :deny_new
rescue_from HoldCreateException, with: :deny_create
rescue_from HoldException, with: :past_date

# Render patron holds
#
Expand Down Expand Up @@ -73,7 +72,11 @@ def create
#
# GET /holds/result
def result
render
if request.referer && URI(request.referer).path == '/holds/new'
render
else
redirect_to '/not_found'
end
end

# Handles form submission for canceling holds in Symphony
Expand Down
3 changes: 0 additions & 3 deletions app/models/hold_exception.rb

This file was deleted.

8 changes: 5 additions & 3 deletions spec/controllers/holds_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@
end

describe '#result' do
it 'renders the result template' do
get :result
context 'when not redirected from /holds/new' do
it 'redirects to the summary page' do
get :result

expect(response).to render_template(:result)
expect(response).to redirect_to '/not_found'
end
end
end

Expand Down

0 comments on commit d6147aa

Please sign in to comment.