Skip to content

Commit

Permalink
Do not display agent presenter if agent has zero workflow responsibil…
Browse files Browse the repository at this point in the history
…ities

Pulls over a workaround from Sufia: samvera-deprecated/sufia#3080

Needs backporting to 1-7-stable once merged
  • Loading branch information
mjgiarlo committed Feb 27, 2017
1 parent f7db91a commit c665141
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<tr>
<td><%= user.user_key %></td>
<% agent_presenter = @presenter.presenter_for(user) %>
<% if agent_presenter %>
<% if agent_presenter && user.workflow_responsibilities.any? %>
<td>
<ul>
<% agent_presenter.responsibilities do |responsibility_presenter| %>
Expand Down Expand Up @@ -42,4 +42,3 @@
</div>
</div>
</div>

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require 'spec_helper'

describe 'curation_concerns/admin/workflow_roles/index.html.erb', type: :view do
let!(:user1) { create(:user) }
let!(:user2) { create(:user) }
let(:presenter) do
CurationConcerns::Admin::WorkflowRolePresenter.new
end

before do
assign(:presenter, presenter)
allow(view).to receive(:admin_workflow_roles_path).and_return('/admin/workflow_roles')
end

context 'with no users having workflow roles' do
it 'displays "No Roles" for each user' do
render
expect(rendered).to have_content('No roles', count: 2)
end
end

context 'with some users having workflow roles' do
before do
# Force user instances to have corresponding sipity agents
user1.to_sipity_agent
user2.to_sipity_agent
end
it 'displays roles for each user' do
render
expect(rendered.match(/<ul>\s+<\/ul>/m)).to be nil
end
end
end

0 comments on commit c665141

Please sign in to comment.