summaryrefslogtreecommitdiff
path: root/spec/models/concerns/mentionable_spec.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-01-25 11:26:32 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-01-25 11:26:32 +0000
commit7afe79fb767086a993f13aa40e6d9ffb2d8bd9ef (patch)
tree25e2b5fcf8fc43b4401b54bb172cfa36644d0694 /spec/models/concerns/mentionable_spec.rb
parent1e64882da165bc872f5ce487775addf7347779f2 (diff)
parent0c350b79395d6712c7c4fee649cdbd77aa4052cc (diff)
downloadgitlab-ce-7afe79fb767086a993f13aa40e6d9ffb2d8bd9ef.tar.gz
Merge branch 'no_project_notes' into 'master'
Support notes without a project (personal snippets notes) See merge request !8468
Diffstat (limited to 'spec/models/concerns/mentionable_spec.rb')
-rw-r--r--spec/models/concerns/mentionable_spec.rb24
1 files changed, 21 insertions, 3 deletions
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
index 132858950d5..b73028f0bc0 100644
--- a/spec/models/concerns/mentionable_spec.rb
+++ b/spec/models/concerns/mentionable_spec.rb
@@ -30,12 +30,20 @@ describe Issue, "Mentionable" do
describe '#mentioned_users' do
let!(:user) { create(:user, username: 'stranger') }
let!(:user2) { create(:user, username: 'john') }
- let!(:issue) { create(:issue, description: "#{user.to_reference} mentioned") }
+ let!(:user3) { create(:user, username: 'jim') }
+ let(:issue) { create(:issue, description: "#{user.to_reference} mentioned") }
subject { issue.mentioned_users }
- it { is_expected.to include(user) }
- it { is_expected.not_to include(user2) }
+ it { expect(subject).to contain_exactly(user) }
+
+ context 'when a note on personal snippet' do
+ let!(:note) { create(:note_on_personal_snippet, note: "#{user.to_reference} mentioned #{user3.to_reference}") }
+
+ subject { note.mentioned_users }
+
+ it { expect(subject).to contain_exactly(user, user3) }
+ end
end
describe '#referenced_mentionables' do
@@ -138,6 +146,16 @@ describe Issue, "Mentionable" do
issue.update_attributes(description: issues[1].to_reference)
issue.create_new_cross_references!
end
+
+ it 'notifies new references from project snippet note' do
+ snippet = create(:snippet, project: project)
+ note = create(:note, note: issues[0].to_reference, noteable: snippet, project: project, author: author)
+
+ expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
+
+ note.update_attributes(note: issues[1].to_reference)
+ note.create_new_cross_references!
+ end
end
def create_issue(description:)