diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2016-05-12 12:12:12 +0200 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2016-05-12 12:12:12 +0200 |
commit | b5d26db03b480a88620bc4a96314365e2c27d188 (patch) | |
tree | 231bc201aa14e4f636a47a43db7dc53a6c8faf66 | |
parent | 55d5273cfb83dd7b72e4261908a9dddc52f5bd36 (diff) | |
download | gitlab-ce-b5d26db03b480a88620bc4a96314365e2c27d188.tar.gz |
Add Issue#participants specs for private projects
-rw-r--r-- | spec/models/issue_spec.rb | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb index 52c7f19abbe..7b364ba37b1 100644 --- a/spec/models/issue_spec.rb +++ b/spec/models/issue_spec.rb @@ -233,23 +233,40 @@ describe Issue, models: true do end describe '#participants' do - let(:project) { create(:project, :public) } - let(:issue) { create(:issue, project: project) } + context 'using a public project' do + let(:project) { create(:project, :public) } + let(:issue) { create(:issue, project: project) } - let!(:note1) do - create(:note_on_issue, noteable: issue, project: project, note: 'a') - end + let!(:note1) do + create(:note_on_issue, noteable: issue, project: project, note: 'a') + end - let!(:note2) do - create(:note_on_issue, noteable: issue, project: project, note: 'b') - end + let!(:note2) do + create(:note_on_issue, noteable: issue, project: project, note: 'b') + end - it 'includes the issue author as the first participant' do - expect(issue.participants[0]).to eq(issue.author) + it 'includes the issue author as the first participant' do + expect(issue.participants[0]).to eq(issue.author) + end + + it 'includes the authors of the notes' do + expect(issue.participants).to include(note1.author, note2.author) + end end - it 'includes the authors of the notes' do - expect(issue.participants).to include(note1.author, note2.author) + context 'using a private project' do + it 'does not include mentioned users that do not have access to the project' do + project = create(:project) + user = create(:user) + issue = create(:issue, project: project) + + create(:note_on_issue, + noteable: issue, + project: project, + note: user.to_reference) + + expect(issue.participants).not_to include(user) + end end end end |