2016-05-24 09:30:36 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
require_relative 'email_shared_blocks'
|
2015-08-20 19:17:59 +00:00
|
|
|
|
2015-12-09 10:55:36 +00:00
|
|
|
describe Gitlab::Email::Receiver, lib: true do
|
2016-05-24 09:30:36 +00:00
|
|
|
include_context :email_shared_context
|
2015-08-20 19:17:59 +00:00
|
|
|
|
2016-05-23 17:19:20 +00:00
|
|
|
context "when we cannot find a capable handler" do
|
|
|
|
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "!!!") }
|
|
|
|
|
2017-05-01 13:25:04 +00:00
|
|
|
it "raises an UnknownIncomingEmail error" do
|
2016-05-23 17:19:20 +00:00
|
|
|
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
|
|
|
|
end
|
2017-05-01 13:25:04 +00:00
|
|
|
|
|
|
|
context "and the email contains no references header" do
|
|
|
|
let(:email_raw) { fixture_file("emails/auto_reply.eml").gsub(mail_key, "!!!") }
|
|
|
|
|
|
|
|
it "raises an UnknownIncomingEmail error" do
|
|
|
|
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
|
|
|
|
end
|
|
|
|
end
|
2016-05-23 17:19:20 +00:00
|
|
|
end
|
|
|
|
|
2015-08-20 19:17:59 +00:00
|
|
|
context "when the email is blank" do
|
|
|
|
let(:email_raw) { "" }
|
|
|
|
|
|
|
|
it "raises an EmptyEmailError" do
|
2016-05-18 22:19:25 +00:00
|
|
|
expect { receiver.execute }.to raise_error(Gitlab::Email::EmptyEmailError)
|
2015-08-20 19:17:59 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|