Skip to content

Commit

Permalink
Not display agents with allow_public_data:false on public organizatio…
Browse files Browse the repository at this point in the history
…n page
  • Loading branch information
taitus committed Jan 26, 2018
1 parent 5a33bdb commit 7d258e3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
26 changes: 14 additions & 12 deletions app/views/organizations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,21 @@
<div class="content active">
<% if @organization.agents.present? %>
<% @organization.agents.each do |agent| %>
<p>
<strong><%= t('organizations.show.agents_fullname') %></strong>
<%= agent.name %>
<%= agent.first_surname %>
<%= agent.second_surname %>
</p>
<p><strong><%= t('organizations.show.agents_from') %></strong>
<%= I18n.l agent.from if agent.from? %>
</p>
<% if agent.to.present? %>
<p><strong><%= t('organizations.show.agents_to') %></strong>
<%= I18n.l agent.to if agent.to.present? %>
<% if agent.allow_public_data %>
<p>
<strong><%= t('organizations.show.agents_fullname') %></strong>
<%= agent.name %>
<%= agent.first_surname %>
<%= agent.second_surname %>
</p>
<p><strong><%= t('organizations.show.agents_from') %></strong>
<%= I18n.l agent.from if agent.from? %>
</p>
<% if agent.to.present? %>
<p><strong><%= t('organizations.show.agents_to') %></strong>
<%= I18n.l agent.to if agent.to.present? %>
</p>
<% end %>
<% end %>
<% end %>
<% else %>
Expand Down
11 changes: 11 additions & 0 deletions spec/features/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,17 @@
expect(page).to have_content I18n.l(agent2.to)
end

scenario "Should not display organization agent info allow_public_data: false" do
organization = create(:organization)
agent1 = create(:agent, organization: organization, to: Date.current, allow_public_data: true)
agent2 = create(:agent, organization: organization, to: Date.current, allow_public_data: false)

visit organization_path(organization)

expect(page).to have_content agent1.name
expect(page).not_to have_content agent2.name
end

scenario "Should display canceled organization but not display agent info" do
organization = create(:organization, canceled_at: Date.current)
agent = create(:agent, organization: organization)
Expand Down

0 comments on commit 7d258e3

Please sign in to comment.