diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-18 18:37:55 -0500 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-18 18:38:17 -0500 |
commit | bf708e55c2e6035b64861a1cda8bfe3d3b4a2105 (patch) | |
tree | 6eb5f726e0d033a6a69ea1ad900223ef4ef30054 /spec | |
parent | d6b11dafd37e78c12c982c42f274928293cdfa53 (diff) | |
download | gitlab-ce-bf708e55c2e6035b64861a1cda8bfe3d3b4a2105.tar.gz |
make mentions working when project not specified
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/banzai/filter/user_reference_filter_spec.rb | 21 | ||||
-rw-r--r-- | spec/models/concerns/mentionable_spec.rb | 13 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notification_service_spec.rb | 4 |
4 files changed, 37 insertions, 3 deletions
diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index 5bfeb82e738..2166350f579 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -152,6 +152,27 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do end end + context 'when a project is not specified' do + let(:project) { nil } + + it 'does not link a User' do + doc = reference_filter("Hey #{reference}") + expect(doc).not_to include('a') + end + + context 'when skip_project_check set to true' do + it 'links to a User' do + doc = reference_filter("Hey #{reference}", skip_project_check: true) + expect(doc.css('a').first.attr('href')).to eq urls.user_url(user) + end + + it 'does not link users using @all reference' do + doc = reference_filter("Hey #{User.reference_prefix}all", skip_project_check: true) + expect(doc).not_to include('a') + end + end + end + describe '#namespaces' do it 'returns a Hash containing all Namespaces' do document = Nokogiri::HTML.fragment("<p>#{user.to_reference}</p>") diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb index 8321e0b89f8..63eb7473c97 100644 --- a/spec/models/concerns/mentionable_spec.rb +++ b/spec/models/concerns/mentionable_spec.rb @@ -30,12 +30,23 @@ 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) } + + 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 { is_expected.to include(user) } + it { is_expected.to include(user3) } + it { is_expected.not_to include(user2) } + end end describe '#referenced_mentionables' do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index ddd62d7f0e6..8017bf7a13c 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -152,6 +152,7 @@ describe Note, models: true do with([{ text: note1.note, context: { + skip_project_check: false, pipeline: :note, cache_key: [note1, "note"], project: note1.project, @@ -163,6 +164,7 @@ describe Note, models: true do with([{ text: note2.note, context: { + skip_project_check: false, pipeline: :note, cache_key: [note2, "note"], project: note2.project, diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index 0ba210fdc5b..bfbee7ca35f 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -306,8 +306,8 @@ describe NotificationService, services: true do should_email(@u_watcher) should_email(@u_snippet_author) - # TODO: make mentions working for pesronal snippets - # should_email(@u_mentioned_level) + # it emails mentioned users + should_email(@u_mentioned) # it does not email participants with mention notification level should_not_email(@u_mentioned_level) |