Merge pull request #1434 from consul/valuation-tags

displays only valuation tags for filtering
This commit is contained in:
Enrique García
2017-03-07 19:14:44 +01:00
committed by GitHub
3 changed files with 20 additions and 1 deletions

View File

@@ -38,4 +38,8 @@ module BudgetsHelper
def current_ballot
Budget::Ballot.where(user: current_user, budget: @budget).first
end
def investment_tags_select_options
Budget::Investment.tags_on(:valuation).order(:name).select(:name).distinct
end
end

View File

@@ -28,7 +28,7 @@
<div class="small-12 medium-3 column">
<%= select_tag :tag_name,
options_for_select(spending_proposal_tags_select_options, params[:tag_name]),
options_for_select(investment_tags_select_options, params[:tag_name]),
{ prompt: t("admin.budget_investments.index.tags_filter_all"),
label: false,
class: "js-submit-on-change" } %>

View File

@@ -252,6 +252,21 @@ feature 'Admin budget investments' do
expect(page).to have_content("More schools")
end
scenario "Filtering by tag, display only valuation tags" do
investment1 = create(:budget_investment, budget: @budget, tag_list: 'Education')
investment2 = create(:budget_investment, budget: @budget, tag_list: 'Health')
investment1.set_tag_list_on(:valuation, 'Teachers')
investment2.set_tag_list_on(:valuation, 'Hospitals')
investment1.save
investment2.save
visit admin_budget_budget_investments_path(budget_id: @budget.id)
expect(page).to have_select("tag_name", options: ["All tags", "Hospitals", "Teachers"])
end
end
scenario 'Show' do