diff options
author | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-05-03 15:32:20 -0600 |
---|---|---|
committer | Mario de la Ossa <mariodelaossa@gmail.com> | 2018-05-07 12:58:47 -0600 |
commit | 02741ca4c58c625070d06c248125b2f510ac2c0b (patch) | |
tree | 3bfc7684b2082ee73ceffc85868ef3dc2d307a21 /spec/support/shared_contexts | |
parent | 33e78f9ebd35b4132e9f18057f517d92cbefb9cd (diff) | |
download | gitlab-ce-02741ca4c58c625070d06c248125b2f510ac2c0b.tar.gz |
Backport 5480-epic-notifications from EE
Diffstat (limited to 'spec/support/shared_contexts')
-rw-r--r-- | spec/support/shared_contexts/email_shared_blocks.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/email_shared_blocks.rb b/spec/support/shared_contexts/email_shared_blocks.rb new file mode 100644 index 00000000000..9d806fc524d --- /dev/null +++ b/spec/support/shared_contexts/email_shared_blocks.rb @@ -0,0 +1,41 @@ +require 'gitlab/email/receiver' + +shared_context :email_shared_context do + let(:mail_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" } + let(:receiver) { Gitlab::Email::Receiver.new(email_raw) } + let(:markdown) { "![image](uploads/image.png)" } + + def setup_attachment + allow_any_instance_of(Gitlab::Email::AttachmentUploader).to receive(:execute).and_return( + [ + { + url: "uploads/image.png", + alt: "image", + markdown: markdown + } + ] + ) + end +end + +shared_examples :reply_processing_shared_examples do + context "when the user could not be found" do + before do + user.destroy + end + + it "raises a UserNotFoundError" do + expect { receiver.execute }.to raise_error(Gitlab::Email::UserNotFoundError) + end + end + + context "when the user is not authorized to the project" do + before do + project.update_attribute(:visibility_level, Project::PRIVATE) + end + + it "raises a ProjectNotFound" do + expect { receiver.execute }.to raise_error(Gitlab::Email::ProjectNotFound) + end + end +end |