-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #706 from projecthydra-labs/unauthorized
Handle unauthorized when curation_concern is not set
- Loading branch information
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
23
spec/views/curation_concerns/base/unauthorized.html.erb_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |