summaryrefslogtreecommitdiff
path: root/spec/support/shared_examples/updating_mentions_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/updating_mentions_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/updating_mentions_shared_examples.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/support/shared_examples/updating_mentions_shared_examples.rb b/spec/support/shared_examples/updating_mentions_shared_examples.rb
new file mode 100644
index 00000000000..5e3f19ba19e
--- /dev/null
+++ b/spec/support/shared_examples/updating_mentions_shared_examples.rb
@@ -0,0 +1,36 @@
+RSpec.shared_examples 'updating mentions' do |service_class|
+ let(:mentioned_user) { create(:user) }
+ let(:service_class) { service_class }
+
+ before do
+ project.add_developer(mentioned_user)
+ 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