Skip to content

Commit

Permalink
Adds route, controller action, presenter, and view for inspect_work
Browse files Browse the repository at this point in the history
  • Loading branch information
randalldfloyd committed Oct 25, 2016
1 parent ca956b1 commit eb433c3
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -103,6 +103,10 @@ def file_manager
presenter
end

def inspect_work
presenter
end

attr_writer :actor

protected
Expand Down
9 changes: 9 additions & 0 deletions app/presenters/curation_concerns/inspect_work_presenter.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/presenters/curation_concerns/work_show_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
7 changes: 7 additions & 0 deletions app/views/curation_concerns/base/inspect_work.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<h1><%= t("inspect_work.link_text") %></h1>
<ul class="breadcrumb">
<li>
Back to <%= link_to @presenter.to_s, [main_app, @presenter] %>
</li>
</ul>

1 change: 1 addition & 0 deletions lib/curation_concerns/rails/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions spec/presenters/curation_concerns/work_show_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
4 changes: 4 additions & 0 deletions spec/routing/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb433c3

Please sign in to comment.