bb5f79d43e
`:mailer` is needed to pick it easily, while `type: :mailer` is needed for picking it automatically for tests located in spec/mailers/*_spec.rb It's a bit complicated in spec/services/notification_service_spec.rb but we'll leave it alone for now.
36 lines
815 B
Ruby
36 lines
815 B
Ruby
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
|