Skip to content

Commit

Permalink
Merge pull request #706 from projecthydra-labs/unauthorized
Browse files Browse the repository at this point in the history
Handle unauthorized when curation_concern is not set
  • Loading branch information
mjgiarlo committed Mar 31, 2016
2 parents 5749ca9 + 5711558 commit b86ec5b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/views/curation_concerns/base/unauthorized.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<h1>Unauthorized</h1>
<p>The <%= curation_concern.human_readable_type.downcase %> you have tried to access is private<p>
<p>ID: <%= curation_concern.id %>
<% if respond_to?(:curation_concern) %>
<p>The <%= curation_concern.human_readable_type.downcase %> you have tried to access is private<p>
<p>ID: <%= curation_concern.id %>
<% else %>
<p>The page you have tried to access is private<p>
<% end %>
23 changes: 23 additions & 0 deletions spec/views/curation_concerns/base/unauthorized.html.erb_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'spec_helper'

describe 'curation_concerns/base/unauthorized.html.erb' do
context "when it responds to curation_concern" do
let(:concern) { double(human_readable_type: 'Book', id: '777') }
before do
allow(view).to receive(:curation_concern).and_return(concern)
render
end
it "shows a message to the user" do
expect(rendered).to have_content "Unauthorized The book you have tried to access is private ID: 777"
end
end

context "when it doesn't respond to curation_concern" do
before do
render
end
it "shows a message to the user" do
expect(rendered).to have_content "Unauthorized The page you have tried to access is private"
end
end
end

0 comments on commit b86ec5b

Please sign in to comment.