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 1a6fba2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
Expand Up @@ -16,6 +16,10 @@ def initialize(agent)
@agent = agent
end

def responsibilities_present?
@agent.workflow_responsibilities.any?
end

def responsibilities
@agent.workflow_responsibilities.each do |responsibility|
yield ResponsibilityPresenter.new(responsibility)
Expand Down
Expand Up @@ -11,7 +11,7 @@
<tr>
<td><%= user.user_key %></td>
<% agent_presenter = @presenter.presenter_for(user) %>
<% if agent_presenter %>
<% if agent_presenter && agent_presenter.responsibilities_present? %>
<td>
<ul>
<% agent_presenter.responsibilities do |responsibility_presenter| %>
Expand Down Expand Up @@ -42,4 +42,3 @@
</div>
</div>
</div>

@@ -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 1a6fba2

Please sign in to comment.