diff --git a/app/controllers/concerns/curation_concerns/curation_concern_controller.rb b/app/controllers/concerns/curation_concerns/curation_concern_controller.rb index ca8cc73d0..4c4d074b6 100644 --- a/app/controllers/concerns/curation_concerns/curation_concern_controller.rb +++ b/app/controllers/concerns/curation_concerns/curation_concern_controller.rb @@ -17,7 +17,7 @@ module CurationConcerns::CurationConcernController module ClassMethods def curation_concern_type=(curation_concern_type) - load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager] + load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager, :inspect_work] self._curation_concern_type = curation_concern_type end @@ -103,6 +103,10 @@ def file_manager presenter end + def inspect_work + presenter + end + attr_writer :actor protected diff --git a/app/presenters/curation_concerns/inspect_work_presenter.rb b/app/presenters/curation_concerns/inspect_work_presenter.rb new file mode 100644 index 000000000..47dd5bf2f --- /dev/null +++ b/app/presenters/curation_concerns/inspect_work_presenter.rb @@ -0,0 +1,9 @@ +module CurationConcerns + class InspectWorkPresenter + def initialize(solr_document, current_ability) + @solr_document = solr_document + @current_ability = current_ability + end + attr_reader :solr_document, :current_ability + end +end diff --git a/app/presenters/curation_concerns/work_show_presenter.rb b/app/presenters/curation_concerns/work_show_presenter.rb index 3d6cd7530..3b1238d3e 100644 --- a/app/presenters/curation_concerns/work_show_presenter.rb +++ b/app/presenters/curation_concerns/work_show_presenter.rb @@ -50,6 +50,10 @@ def workflow @workflow ||= WorkflowPresenter.new(solr_document, current_ability) end + def inspect_work + @inspect_workflow ||= InspectWorkPresenter.new(solr_document, current_ability) + end + # @return FileSetPresenter presenter for the representative FileSets def representative_presenter return nil if representative_id.blank? diff --git a/app/views/curation_concerns/base/inspect_work.html.erb b/app/views/curation_concerns/base/inspect_work.html.erb new file mode 100644 index 000000000..690b02ea5 --- /dev/null +++ b/app/views/curation_concerns/base/inspect_work.html.erb @@ -0,0 +1,7 @@ +

<%= t("inspect_work.link_text") %>

+ + diff --git a/lib/curation_concerns/rails/routes.rb b/lib/curation_concerns/rails/routes.rb index 425f38a0a..8c3edede4 100644 --- a/lib/curation_concerns/rails/routes.rb +++ b/lib/curation_concerns/rails/routes.rb @@ -16,6 +16,7 @@ def curation_concerns_basic_routes(&block) namespaced_resources curation_concern_name, only: [] do member do get :file_manager + get :inspect_work end end end diff --git a/spec/controllers/curation_concerns/generic_works_controller_spec.rb b/spec/controllers/curation_concerns/generic_works_controller_spec.rb index f33ee8251..60cd01e0d 100644 --- a/spec/controllers/curation_concerns/generic_works_controller_spec.rb +++ b/spec/controllers/curation_concerns/generic_works_controller_spec.rb @@ -293,4 +293,13 @@ expect(assigns(:presenter)).not_to be_blank end end + + describe '#inspect_work' do + let(:work) { create(:private_generic_work, user: user) } + it "is successful" do + get :inspect_work, params: { id: work.id } + expect(response).to be_success + expect(assigns(:presenter)).not_to be_blank + end + end end diff --git a/spec/presenters/curation_concerns/work_show_presenter_spec.rb b/spec/presenters/curation_concerns/work_show_presenter_spec.rb index 7f3a8bd4e..99810f8e6 100644 --- a/spec/presenters/curation_concerns/work_show_presenter_spec.rb +++ b/spec/presenters/curation_concerns/work_show_presenter_spec.rb @@ -188,6 +188,15 @@ end end + context "with inspect_work" do + let(:user) { create(:user) } + let(:ability) { Ability.new(user) } + describe "#inspect_work" do + subject { presenter.inspect_work } + it { is_expected.to be_kind_of CurationConcerns::InspectWorkPresenter } + end + end + describe "graph export methods" do let(:graph) do RDF::Graph.new.tap do |g| diff --git a/spec/routing/route_spec.rb b/spec/routing/route_spec.rb index fda0d2221..55d578601 100644 --- a/spec/routing/route_spec.rb +++ b/spec/routing/route_spec.rb @@ -39,6 +39,10 @@ it 'routes to file_manager' do expect(get: 'concern/generic_works/6/file_manager').to route_to(controller: 'curation_concerns/generic_works', action: 'file_manager', id: '6') end + + it 'routes to inspect_work' do + expect(get: 'concern/generic_works/6/inspect_work').to route_to(controller: 'curation_concerns/generic_works', action: 'inspect_work', id: '6') + end end describe 'Permissions' do