From 607f0c05feb2cde82493a36ac43ba5ecd6c71620 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 20 Feb 2015 17:43:28 +0100 Subject: Change EmailsOnPush subject to include namespace, repo and branch. See #1827. --- spec/mailers/notify_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 3b09c618f2a..ae2b61262bd 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -583,7 +583,7 @@ describe Notify do end it 'has the correct subject' do - is_expected.to have_subject /#{commits.length} new commits pushed to repository/ + is_expected.to have_subject /\[#{project.path_with_namespace}\]\[master\] #{commits.length} commits:/ end it 'includes commits list' do -- cgit v1.2.3 From 6afb03ee96a2f0c36e69a6da4e10dbe298c5b79f Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Fri, 20 Feb 2015 17:44:13 +0100 Subject: Remove incorrect footer from EmailsOnPush body. See #1754. --- spec/mailers/notify_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'spec') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index ae2b61262bd..41b0daacded 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -597,6 +597,10 @@ describe Notify do it 'contains a link to the diff' do is_expected.to have_body_text /#{diff_path}/ end + + it 'doesn not contain the misleading footer' do + is_expected.not_to have_body_text /you are a member of/ + end end describe 'email on push with a single commit' do -- cgit v1.2.3 From e0c186c35735a2dc9e05e88ad9975ae016c815d9 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 25 Feb 2015 14:05:45 +0100 Subject: Add option to send EmailsOnPush from committer email if domain matches. See #1809. --- spec/mailers/notify_spec.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'spec') 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 -- cgit v1.2.3 From 5d86332153838252384f9f87a0ae3e34c46eb266 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 25 Feb 2015 15:12:19 +0100 Subject: Send EmailsOnPush when deleting commits using force push. See #1924. --- spec/mailers/notify_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index ad2b7c11f84..9af17942612 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -571,7 +571,7 @@ describe Notify do 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, send_from_committer_email) } + subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare, false, send_from_committer_email) } it 'is sent as the author' do sender = subject.header[:from].addrs[0] -- cgit v1.2.3 From 969de4c15a876ab9096f163ef6182571ca199492 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 25 Feb 2015 15:49:40 +0100 Subject: Fix EmailsOnPush to allow sending from @company.com for GitLab at gitlab.corp.company.com. --- spec/mailers/notify_spec.rb | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 9af17942612..534ab05942c 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -607,11 +607,14 @@ describe Notify 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.corp.company.com") + end + + context "when the committer email domain is within the GitLab domain" do before do - allow(Gitlab.config.gitlab).to receive(:host).and_return("gitlab.dev") - user.update_attribute(:email, "user@#{Gitlab.config.gitlab.host}") + user.update_attribute(:email, "user@company.com") user.confirm! end @@ -621,7 +624,25 @@ describe Notify do end end - context "when the committer email doesn't match" do + context "when the committer email domain is not completely within the GitLab domain" do + + before do + user.update_attribute(:email, "user@something.company.com") + user.confirm! + end + + it "is sent from the default email" do + sender = subject.header[:from].addrs[0] + expect(sender.address).to eq(gitlab_sender) + end + end + + context "when the committer email domain is outside the GitLab domain" do + + before do + user.update_attribute(:email, "user@mpany.com") + user.confirm! + end it "is sent from the default email" do sender = subject.header[:from].addrs[0] -- cgit v1.2.3 From 4658e554b7129c44221a73fe8ec3b73b4b9b8b24 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Wed, 25 Feb 2015 17:17:24 +0100 Subject: Fix EmailsOnPush comparison link to include first commit. --- spec/mailers/notify_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 534ab05942c..4090fa46205 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -568,7 +568,7 @@ describe Notify do let(:user) { create(:user) } 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(:diff_path) { namespace_project_compare_path(project.namespace, project, from: Commit.new(compare.base), to: Commit.new(compare.head)) } let(:send_from_committer_email) { false } subject { Notify.repository_push_email(project.id, 'devs@company.name', user.id, 'master', compare, false, send_from_committer_email) } -- cgit v1.2.3