Use a virtual attribute to get valuation tags
It was strange to set the valuation tags using `valuation_tag_list=` but then accessing the valuation tags using `tag_list_on(:valuation)`.
This commit is contained in:
@@ -349,6 +349,10 @@ class Budget
|
||||
self.valuator_groups.collect(&:name).compact.join(', ').presence
|
||||
end
|
||||
|
||||
def valuation_tag_list
|
||||
tag_list_on(:valuation)
|
||||
end
|
||||
|
||||
def valuation_tag_list=(tags)
|
||||
set_tag_list_on(:valuation, tags)
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<%= f.text_field :valuation_tag_list,
|
||||
value: @investment.tag_list_on(:valuation).sort.join(','),
|
||||
value: @investment.valuation_tag_list.sort.join(','),
|
||||
label: false,
|
||||
placeholder: t("admin.budget_investments.edit.tags_placeholder"),
|
||||
class: 'js-tag-list' %>
|
||||
|
||||
@@ -642,6 +642,14 @@ describe Budget::Investment do
|
||||
results = described_class.search("Latin")
|
||||
expect(results.first).to eq(investment)
|
||||
end
|
||||
|
||||
it "gets and sets valuation tags through virtual attributes" do
|
||||
investment = create(:budget_investment)
|
||||
|
||||
investment.valuation_tag_list = %w[Code Test Refactor]
|
||||
|
||||
expect(investment.valuation_tag_list).to match_array(%w[Code Test Refactor])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user