Add max votable headings to groups
This commit is contained in:
@@ -17,7 +17,7 @@ class Admin::BudgetGroupsController < Admin::BaseController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def budget_group_params
|
def budget_group_params
|
||||||
params.require(:budget_group).permit(:name)
|
params.require(:budget_group).permit(:name, :max_votable_headings)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,19 @@
|
|||||||
maxlength: 50,
|
maxlength: 50,
|
||||||
placeholder: t("admin.budgets.form.group"),
|
placeholder: t("admin.budgets.form.group"),
|
||||||
class: "input-group-field" %>
|
class: "input-group-field" %>
|
||||||
|
|
||||||
|
<% if group.persisted? %>
|
||||||
|
<div class="small-12 medium-6 large-4">
|
||||||
|
<%= f.label :name, t("admin.budgets.form.max_votable_headings") %>
|
||||||
|
|
||||||
|
<%= f.select :max_votable_headings,
|
||||||
|
(1..group.headings.count),
|
||||||
|
label: false,
|
||||||
|
placeholder: t("admin.budgets.form.max_votable_headings"),
|
||||||
|
class: "input-group-field" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="input-group-button">
|
<div class="input-group-button">
|
||||||
<%= f.submit button_title, class: "button success" %>
|
<%= f.submit button_title, class: "button success" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class AddMaxVotableHeadingsToBudgetGroups < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :budget_groups, :max_votable_headings, :integer, default: 1
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20180220211105) do
|
ActiveRecord::Schema.define(version: 20180320104823) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -103,6 +103,7 @@ ActiveRecord::Schema.define(version: 20180220211105) do
|
|||||||
t.integer "budget_id"
|
t.integer "budget_id"
|
||||||
t.string "name", limit: 50
|
t.string "name", limit: 50
|
||||||
t.string "slug"
|
t.string "slug"
|
||||||
|
t.integer "max_votable_headings", default: 1
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "budget_groups", ["budget_id"], name: "index_budget_groups_on_budget_id", using: :btree
|
add_index "budget_groups", ["budget_id"], name: "index_budget_groups_on_budget_id", using: :btree
|
||||||
|
|||||||
@@ -65,4 +65,49 @@ feature 'Admin can change the groups name' do
|
|||||||
expect(page).to have_content('has already been taken')
|
expect(page).to have_content('has already been taken')
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user