Hide maximum headings select in groups without headings

This commit is contained in:
Alberto
2020-03-21 03:45:59 +01:00
committed by Javi Martín
parent 03e598a53d
commit e71ccee682
2 changed files with 20 additions and 1 deletions

View File

@@ -9,7 +9,7 @@
</div> </div>
<% end %> <% end %>
<% if group.persisted? %> <% if group.persisted? && group.headings.any? %>
<div class="small-12 medium-6 column margin"> <div class="small-12 medium-6 column margin">
<%= f.select :max_votable_headings, <%= f.select :max_votable_headings,
(1..group.headings.count), (1..group.headings.count),

View File

@@ -129,6 +129,25 @@ describe "Admin budget groups", :admin do
expect(page).to have_field "Maximum number of headings in which a user can select projects", with: "2" expect(page).to have_field "Maximum number of headings in which a user can select projects", with: "2"
end end
describe "Select for maxium number of headings to select projects" do
scenario "is present if there are headings in the group" do
group = create(:budget_group, budget: budget)
create(:budget_heading, group: group)
visit edit_admin_budget_group_path(budget, group)
expect(page).to have_field "Maximum number of headings in which a user can select projects"
end
scenario "is not present if there are no headings in the group" do
group = create(:budget_group, budget: budget)
visit edit_admin_budget_group_path(budget, group)
expect(page).not_to have_field "Maximum number of headings in which a user can select projects"
end
end
scenario "Changing name for current locale will update the slug if budget is in draft phase" do scenario "Changing name for current locale will update the slug if budget is in draft phase" do
group = create(:budget_group, budget: budget, name: "Old English Name") group = create(:budget_group, budget: budget, name: "Old English Name")