diff --git a/app/views/admin/budget_groups/_form.html.erb b/app/views/admin/budget_groups/_form.html.erb index 8c152c3c5..5e86059c0 100644 --- a/app/views/admin/budget_groups/_form.html.erb +++ b/app/views/admin/budget_groups/_form.html.erb @@ -9,7 +9,7 @@ <% end %> - <% if group.persisted? %> + <% if group.persisted? && group.headings.any? %>
<%= f.select :max_votable_headings, (1..group.headings.count), diff --git a/spec/system/admin/budget_groups_spec.rb b/spec/system/admin/budget_groups_spec.rb index c74b82177..090375235 100644 --- a/spec/system/admin/budget_groups_spec.rb +++ b/spec/system/admin/budget_groups_spec.rb @@ -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" 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 group = create(:budget_group, budget: budget, name: "Old English Name")