Fix: Milestone - Participants list is showing duplicate assignees
This commit is contained in:
parent
e5226177ac
commit
c3bca2ac74
2 changed files with 14 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue