2016-09-13 17:45:13 +05:30
|
|
|
RSpec.shared_examples 'updating mentions' do |service_class|
|
|
|
|
let(:mentioned_user) { create(:user) }
|
|
|
|
let(:service_class) { service_class }
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
2018-03-17 18:26:18 +05:30
|
|
|
project.add_developer(mentioned_user)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
def update_mentionable(opts)
|
|
|
|
perform_enqueued_jobs do
|
|
|
|
service_class.new(project, user, opts).execute(mentionable)
|
|
|
|
end
|
|
|
|
|
|
|
|
mentionable.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in title' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
update_mentionable(title: mentioned_user.to_reference)
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
it 'emails only the newly-mentioned user' do
|
|
|
|
should_only_email(mentioned_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'in description' do
|
2017-09-10 17:25:29 +05:30
|
|
|
before do
|
|
|
|
update_mentionable(description: mentioned_user.to_reference)
|
|
|
|
end
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
it 'emails only the newly-mentioned user' do
|
|
|
|
should_only_email(mentioned_user)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|