Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render the unavailable template w/ a friendly message if user cannot …
…act on the work in its current workflow state Fixes samvera-deprecated/sufia#2727
- Loading branch information
Showing
7 changed files
with
134 additions
and
4 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
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
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,10 @@ | ||
<h1><%= @presenter %> </h1> | ||
<span class="state state-<%= @presenter.workflow.state %>"><%= @presenter.workflow.state_label %></span> | ||
<% if @parent_presenter %> | ||
<ul class="breadcrumb"> | ||
<li><%= link_to @parent_presenter, polymorphic_path([main_app, @parent_presenter]) %></li> | ||
<li class="active"><%= @presenter.human_readable_type %></li> | ||
</ul> | ||
<% else %> | ||
<span class="human_readable_type">(<%= @presenter.human_readable_type %>)</span> | ||
<% end %> |
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
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,4 @@ | ||
module CurationConcerns | ||
class WorkflowAuthorizationException < StandardError | ||
end | ||
end |
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
40 changes: 40 additions & 0 deletions
40
spec/views/curation_concerns/base/unavailable.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,40 @@ | ||
require 'spec_helper' | ||
|
||
describe 'curation_concerns/base/unavailable.html.erb', type: :view do | ||
let(:model) do | ||
double('model', | ||
persisted?: true, | ||
to_param: '123', | ||
model_name: GenericWork.model_name) | ||
end | ||
let(:workflow) do | ||
double('workflow', state: 'deposited', state_label: 'really deposited') | ||
end | ||
let(:presenter) do | ||
double('presenter', | ||
to_s: 'super cool', | ||
workflow: workflow, | ||
human_readable_type: 'Generic Work') | ||
end | ||
let(:parent_presenter) do | ||
double('parent_presenter', | ||
to_s: 'parental remark', | ||
to_model: model, | ||
human_readable_type: 'Foo Bar') | ||
end | ||
before do | ||
assign(:presenter, presenter) | ||
assign(:parent_presenter, parent_presenter) | ||
stub_template 'shared/_brand_bar.html.erb' => '' | ||
stub_template 'shared/_title_bar.html.erb' => '' | ||
flash[:notice] = I18n.t("curation_concerns.workflow.unauthorized") | ||
render template: 'curation_concerns/base/unavailable.html.erb', layout: 'layouts/curation_concerns' | ||
end | ||
it "renders with the flash message" do | ||
expect(rendered).to have_content 'super cool' | ||
expect(rendered).to have_content 'really deposited' | ||
expect(rendered).to have_content 'parental remark' | ||
expect(rendered).to have_content 'Generic Work' | ||
expect(rendered).to have_content 'The work is not currently available because it has not yet completed the approval process' | ||
end | ||
end |