Fix valuation tags being overwritten

When params[:budget_investment][:valuation_tag_list] was not present,
which is the case when updating an investment using the "mark as visible
to valuators" checkbox, we were removing all valuation tags.

Using a virtual attribute to assign the tags only if the parameter is
present simplifies the code in the controller and avoids the issue.
This commit is contained in:
Javi Martín
2019-02-25 12:18:24 +01:00
parent 9fd3c4fb1c
commit 4980819528
3 changed files with 20 additions and 6 deletions

View File

@@ -1376,6 +1376,22 @@ feature "Admin budget investments" do
expect(valuating_checkbox).not_to be_checked
end
end
scenario "Keeps the valuation tags", :js do
investment1.set_tag_list_on(:valuation, %w[Possimpible Truthiness])
investment1.save
visit admin_budget_budget_investments_path(budget)
within("#budget_investment_#{investment1.id}") do
check "budget_investment_visible_to_valuators"
end
visit edit_admin_budget_budget_investment_path(budget, investment1)
expect(page).to have_content "Possimpible"
expect(page).to have_content "Truthiness"
end
end
context "Selecting csv" do