Skip to content

Commit

Permalink
Refactor template.visibility w/ Rails enum method
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronskiba committed Jul 10, 2024
1 parent 595e013 commit 15e4d4d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/org_admin/templates/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
placement: 'right' }%>
<div class="form-check">
<%= f.label(:visibility) do %>
<%= f.check_box(:visibility, checked: f.object.visibility == 'organisationally_visible') %>
<%= f.check_box(:visibility, checked: f.object.organisationally_visible?) %>
<%= _('for internal %{org_name} use only') % { org_name: f.object.org.name } %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/org_admin/templates/_show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- If the Org is a funder and another org type then allow then to set the visibility -->
<dt><%= _('Visibility') %></dt>
<dd>
<% if template.visibility == 'organisationally_visible' %>
<% if template.organisationally_visible? %>
<%= _('for internal %{org_name} use only') % {org_name: template.org.name} %>
<% else %>
<%= _('available to the public') + (template.published? ? '' : ' (once published)') %>
Expand Down
4 changes: 2 additions & 2 deletions spec/models/template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@
end

it 'sets visibility to Organisationally visible' do
expect(subject.visibility).to eql('organisationally_visible')
expect(subject.organisationally_visible?).to eql(true)
end

it 'sets is_default to false' do
Expand Down Expand Up @@ -1152,7 +1152,7 @@
end

it 'sets the visibility to Organisationally visible' do
expect(subject.visibility).to eql('organisationally_visible')
expect(subject.organisationally_visible?).to eql(true)
end

it 'sets is_default to false' do
Expand Down

0 comments on commit 15e4d4d

Please sign in to comment.