Hide max votable field on single heading budgets
IMHO selecting in how many headings it's possible to support investments isn't necessary when there's only one option to choose from. It's obvious that if there's only one heading, it will be impossible to select investments from more than one heading.
This commit is contained in:
@@ -30,6 +30,10 @@ class Budget
|
||||
all.sort_by(&:name)
|
||||
end
|
||||
|
||||
def multiple_headings?
|
||||
headings.size > 1
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_slug?
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if group.persisted? && group.headings.any? %>
|
||||
<% if group.multiple_headings? %>
|
||||
<div class="small-12 medium-6 column margin">
|
||||
<%= f.select :max_votable_headings,
|
||||
(1..group.headings.count),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user