Add max votable headings to groups

This commit is contained in:
rgarcia
2018-03-21 16:44:26 +01:00
parent c1d7378c92
commit 730072e91e
5 changed files with 67 additions and 3 deletions

View File

@@ -65,4 +65,49 @@ feature 'Admin can change the groups name' do
expect(page).to have_content('has already been taken')
end
context "Maximum votable headings" do
background do
3.times { create(:budget_heading, group: group) }
end
scenario "Defaults to 1 heading per group", :js do
visit admin_budget_path(group.budget)
within("#budget_group_#{group.id}") do
click_link 'Edit group'
expect(page).to have_select('budget_group_max_votable_headings', selected: '1')
end
end
scenario "Update", :js do
visit admin_budget_path(group.budget)
within("#budget_group_#{group.id}") do
click_link 'Edit group'
select '2', from: 'budget_group_max_votable_headings'
click_button 'Save group'
end
visit admin_budget_path(group.budget)
within("#budget_group_#{group.id}") do
click_link 'Edit group'
expect(page).to have_select('budget_group_max_votable_headings', selected: '2')
end
end
scenario "Do not display maxium votable headings' select in new form", :js do
visit admin_budget_path(group.budget)
click_link 'Add new group'
expect(page).to have_field('budget_group_name')
expect(page).to_not have_field('budget_group_max_votable_headings')
end
end
end