summaryrefslogtreecommitdiff
path: root/spec/mailers
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-02-25 14:05:45 +0100
committerDouwe Maan <douwe@gitlab.com>2015-02-25 14:20:35 +0100
commite0c186c35735a2dc9e05e88ad9975ae016c815d9 (patch)
treec040a133925106da34de651cb88e155988a079fc /spec/mailers
parent0e7d1fd44f057c83c5384618f4599271f9fdd006 (diff)
downloadgitlab-ce-e0c186c35735a2dc9e05e88ad9975ae016c815d9.tar.gz
Add option to send EmailsOnPush from committer email if domain matches.
See #1809.
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/notify_spec.rb30
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 41b0daacded..ad2b7c11f84 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -569,8 +569,9 @@ describe Notify do
let(:compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) }
let(:commits) { Commit.decorate(compare.commits) }
let(:diff_path) { namespace_project_compare_path(project.namespace, project, from: commits.first, to: commits.last) }
+ let(:send_from_committer_email) { false }
- subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare) }
+ subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare, send_from_committer_email) }
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
@@ -601,6 +602,33 @@ describe Notify do
it 'doesn not contain the misleading footer' do
is_expected.not_to have_body_text /you are a member of/
end
+
+ context "when set to send from committer email if domain matches" do
+
+ let(:send_from_committer_email) { true }
+
+ context "when the committer email domain matches" do
+
+ before do
+ allow(Gitlab.config.gitlab).to receive(:host).and_return("gitlab.dev")
+ user.update_attribute(:email, "user@#{Gitlab.config.gitlab.host}")
+ user.confirm!
+ end
+
+ it "is sent from the committer email" do
+ sender = subject.header[:from].addrs[0]
+ expect(sender.address).to eq(user.email)
+ end
+ end
+
+ context "when the committer email doesn't match" do
+
+ it "is sent from the default email" do
+ sender = subject.header[:from].addrs[0]
+ expect(sender.address).to eq(gitlab_sender)
+ end
+ end
+ end
end
describe 'email on push with a single commit' do