summaryrefslogtreecommitdiff
path: root/spec/support/updating_mentions_shared_examples.rb
blob: 565d3203e4f1cd2819878ee99189a872d4e9cea3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
RSpec.shared_examples 'updating mentions' do |service_class|
  let(:mentioned_user) { create(:user) }
  let(:service_class) { service_class }

  before do
    project.team << [mentioned_user, :developer]
  end

  def update_mentionable(opts)
    perform_enqueued_jobs do
      service_class.new(project, user, opts).execute(mentionable)
    end

    mentionable.reload
  end

  context 'in title' do
    before do
      update_mentionable(title: mentioned_user.to_reference)
    end

    it 'emails only the newly-mentioned user' do
      should_only_email(mentioned_user)
    end
  end

  context 'in description' do
    before do
      update_mentionable(description: mentioned_user.to_reference)
    end

    it 'emails only the newly-mentioned user' do
      should_only_email(mentioned_user)
    end
  end
end