gitlab-org--gitlab-foss/spec/lib/gitlab/email/receiver_spec.rb
Sean McGivern 08b1380ff7 Don't blow up when email has no References header
If an email doesn't match our incoming email patterns on the To header, we fall
back to the References header. If there was no References header, we'd raise an
exception, when we'd be better off acting as if it was empty.
2017-05-01 14:25:04 +01:00

30 lines
949 B
Ruby

require 'spec_helper'
require_relative 'email_shared_blocks'
describe Gitlab::Email::Receiver, lib: true do
include_context :email_shared_context
context "when we cannot find a capable handler" do
let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "!!!") }
it "raises an UnknownIncomingEmail error" do
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
end
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
end
context "when the email is blank" do
let(:email_raw) { "" }
it "raises an EmptyEmailError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::EmptyEmailError)
end
end
end