diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-02 18:39:18 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-06-02 18:39:18 +0000 |
commit | 79aac2c128e0c2fa8fd657af273fbd219002f39c (patch) | |
tree | be65a8f1a10fc6f99d7de160e11a679ff549dee5 /spec | |
parent | 34d176ad577ea421c99c87a54196deda92f796e8 (diff) | |
parent | a916936f3feeda0a6d58fef2c06c51f95f10c45a (diff) | |
download | gitlab-ce-79aac2c128e0c2fa8fd657af273fbd219002f39c.tar.gz |
Merge branch 'ignore-references' into 'master'
Don't notify users mentioned in code blocks or blockquotes.
cc @rspeicher
See merge request !753
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/reference_extractor_spec.rb | 24 | ||||
-rw-r--r-- | spec/support/mentionable_shared_examples.rb | 21 |
2 files changed, 39 insertions, 6 deletions
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb index c14f4ac6bf6..f921dd9cc09 100644 --- a/spec/lib/gitlab/reference_extractor_spec.rb +++ b/spec/lib/gitlab/reference_extractor_spec.rb @@ -16,6 +16,30 @@ describe Gitlab::ReferenceExtractor do expect(subject.users).to eq([@u_foo, @u_bar, @u_offteam]) end + it 'ignores user mentions inside specific elements' do + @u_foo = create(:user, username: 'foo') + @u_bar = create(:user, username: 'bar') + @u_offteam = create(:user, username: 'offteam') + + project.team << [@u_foo, :reporter] + project.team << [@u_bar, :guest] + + subject.analyze(%Q{ + Inline code: `@foo` + + Code block: + + ``` + @bar + ``` + + Quote: + + > @offteam + }) + expect(subject.users).to eq([]) + end + it 'accesses valid issue objects' do @i0 = create(:issue, project: project) @i1 = create(:issue, project: project) diff --git a/spec/support/mentionable_shared_examples.rb b/spec/support/mentionable_shared_examples.rb index ede62e8f37a..d29c8a55c82 100644 --- a/spec/support/mentionable_shared_examples.rb +++ b/spec/support/mentionable_shared_examples.rb @@ -107,17 +107,26 @@ shared_examples 'an editable mentionable' do it 'creates new cross-reference notes when the mentionable text is edited' do subject.save - new_text = <<-MSG + new_text = <<-MSG.strip_heredoc These references already existed: - Issue: #{mentioned_issue.to_reference} - Commit: #{mentioned_commit.to_reference} + + Issue: #{mentioned_issue.to_reference} + + Commit: #{mentioned_commit.to_reference} + + --- This cross-project reference already existed: - Issue: #{ext_issue.to_reference(project)} + + Issue: #{ext_issue.to_reference(project)} + + --- These two references are introduced in an edit: - Issue: #{new_issues[0].to_reference} - Cross: #{new_issues[1].to_reference(project)} + + Issue: #{new_issues[0].to_reference} + + Cross: #{new_issues[1].to_reference(project)} MSG # These three objects were already referenced, and should not receive new |