2016-08-16 12:08:43 -04:00
|
|
|
RSpec.shared_examples 'updating mentions' do |service_class|
|
|
|
|
let(:mentioned_user) { create(:user) }
|
|
|
|
let(:service_class) { service_class }
|
|
|
|
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
project.team << [mentioned_user, :developer]
|
|
|
|
end
|
2016-08-16 12:08:43 -04:00
|
|
|
|
|
|
|
def update_mentionable(opts)
|
|
|
|
reset_delivered_emails!
|
|
|
|
|
|
|
|
perform_enqueued_jobs do
|
|
|
|
service_class.new(project, user, opts).execute(mentionable)
|
|
|
|
end
|
|
|
|
|
|
|
|
mentionable.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in title' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
update_mentionable(title: mentioned_user.to_reference)
|
|
|
|
end
|
2016-08-16 12:08:43 -04:00
|
|
|
|
|
|
|
it 'emails only the newly-mentioned user' do
|
|
|
|
should_only_email(mentioned_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in description' do
|
2017-06-14 14:18:56 -04:00
|
|
|
before do
|
|
|
|
update_mentionable(description: mentioned_user.to_reference)
|
|
|
|
end
|
2016-08-16 12:08:43 -04:00
|
|
|
|
|
|
|
it 'emails only the newly-mentioned user' do
|
|
|
|
should_only_email(mentioned_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|