diff --git a/app/models/budget/group.rb b/app/models/budget/group.rb
index 22138b04a..9ca141725 100644
--- a/app/models/budget/group.rb
+++ b/app/models/budget/group.rb
@@ -30,6 +30,10 @@ class Budget
all.sort_by(&:name)
end
+ def multiple_headings?
+ headings.size > 1
+ end
+
private
def generate_slug?
diff --git a/app/views/admin/budget_groups/_form.html.erb b/app/views/admin/budget_groups/_form.html.erb
index 1f8031df9..8c18c9999 100644
--- a/app/views/admin/budget_groups/_form.html.erb
+++ b/app/views/admin/budget_groups/_form.html.erb
@@ -11,7 +11,7 @@
<% end %>
- <% if group.persisted? && group.headings.any? %>
+ <% if group.multiple_headings? %>
<%= 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 d70d2d1ee..ac0010afa 100644
--- a/spec/system/admin/budget_groups_spec.rb
+++ b/spec/system/admin/budget_groups_spec.rb
@@ -129,14 +129,23 @@ 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
+ describe "Select for maximum number of headings to select projects" do
+ scenario "is present if there are several headings in the group" do
+ group = create(:budget_group, budget: budget)
+ 2.times { 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's only one heading 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"
+ expect(page).not_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