When an investment had been assigned a user tag and a valuation tag with the same name, it appeared twice when filtering by tag. This is because by design, in order to provide compatibility with scopes using "select" or "distinct", the method `tagged_with` doesn't select unique records. Forcing the query to return unique records solves the issue.
18 lines
649 B
Ruby
18 lines
649 B
Ruby
require "rails_helper"
|
|
|
|
describe BudgetExecutionsHelper do
|
|
describe "#options_for_milestone_tags" do
|
|
let(:budget) { create(:budget) }
|
|
|
|
it "does not return duplicate records for tags in different contexts" do
|
|
create(:budget_investment, :winner, budget: budget, milestone_tag_list: ["Multiple"])
|
|
create(:budget_investment, :winner, budget: budget, milestone_tag_list: ["Multiple"])
|
|
create(:budget_investment, :winner, budget: budget, milestone_tag_list: ["Dup"], tag_list: ["Dup"])
|
|
|
|
@budget = budget
|
|
|
|
expect(options_for_milestone_tags).to eq [["Dup (1)", "Dup"], ["Multiple (2)", "Multiple"]]
|
|
end
|
|
end
|
|
end
|