Fix: Milestone - Participants list is showing duplicate assignees

This commit is contained in:
Valery Sizov 2017-05-29 12:20:41 +03:00
parent e5226177ac
commit c3bca2ac74
2 changed files with 14 additions and 1 deletions

View file

@ -107,7 +107,7 @@ class Milestone < ActiveRecord::Base
end
def participants
User.joins(assigned_issues: :milestone).where("milestones.id = ?", id)
User.joins(assigned_issues: :milestone).where("milestones.id = ?", id).uniq
end
def self.sort(method)

View file

@ -249,4 +249,17 @@ describe Milestone, models: true do
expect(milestone.to_reference(another_project)).to eq "sample-project%1"
end
end
describe '#participants' do
let(:project) { build(:empty_project, name: 'sample-project') }
let(:milestone) { build(:milestone, iid: 1, project: project) }
it 'returns participants without duplicates' do
user = create :user
create :issue, project: project, milestone: milestone, assignees: [user]
create :issue, project: project, milestone: milestone, assignees: [user]
expect(milestone.participants).to eq [user]
end
end
end