summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-03-04 20:48:56 +0200
committerValery Sizov <vsv2711@gmail.com>2015-03-10 15:54:59 +0200
commit2fbe5a92eb777f038da775608d80b002833f88be (patch)
tree23522e7836be707c5e54434d949951d75905dea0
parentc95dfd87376bfe3913def89a34b47ad629e96073 (diff)
downloadgitlab-ci-2fbe5a92eb777f038da775608d80b002833f88be.tar.gz
Notify only pusher instead of commiter
-rw-r--r--CHANGELOG1
-rw-r--r--app/models/commit.rb6
-rw-r--r--app/services/create_commit_service.rb1
-rw-r--r--spec/models/commit_spec.rb16
4 files changed, 14 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 33f4087..c38703b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ v7.9.0
v7.8.2
- Fix the broken build failed email
+ - Notify only pusher instead of commiter
v7.8.0
- Fix OAuth login with GitLab installed in relative URL
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 11b61d4..82e20f8 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -92,7 +92,11 @@ class Commit < ActiveRecord::Base
def project_recipients
recipients = project.email_recipients.split(' ')
- recipients << git_author_email if project.email_add_committer?
+
+ if project.email_add_committer? && push_data[:user_email].present?
+ recipients << push_data[:user_email]
+ end
+
recipients.uniq
end
diff --git a/app/services/create_commit_service.rb b/app/services/create_commit_service.rb
index 6526445..b7a5903 100644
--- a/app/services/create_commit_service.rb
+++ b/app/services/create_commit_service.rb
@@ -32,6 +32,7 @@ class CreateCommitService
after: sha,
ref: ref,
user_name: params[:user_name],
+ user_email: params[:user_email],
repository: params[:repository],
commits: params[:commits],
total_commits_count: params[:total_commits_count]
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 891cd52..d93488c 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -79,23 +79,23 @@ describe Commit do
describe :project_recipients do
context 'always sending notification' do
- it 'should return git_author_email as only recipient when no additional recipients are given' do
+ it 'should return commit_pusher_email as only recipient when no additional recipients are given' do
project = FactoryGirl.create :project,
email_add_committer: true,
email_recipients: ''
commit = FactoryGirl.create :commit, project: project
- expected = 'git_author_email'
- commit.stub(:git_author_email) { expected }
+ expected = 'commit_pusher_email'
+ commit.stub(:push_data) { { user_email: expected } }
commit.project_recipients.should == [expected]
end
- it 'should return git_author_email and additional recipients' do
+ it 'should return commit_pusher_email and additional recipients' do
project = FactoryGirl.create :project,
email_add_committer: true,
email_recipients: 'rec1 rec2'
commit = FactoryGirl.create :commit, project: project
- expected = 'git_author_email'
- commit.stub(:git_author_email) { expected }
+ expected = 'commit_pusher_email'
+ commit.stub(:push_data) { { user_email: expected } }
commit.project_recipients.should == ['rec1', 'rec2', expected]
end
@@ -104,8 +104,6 @@ describe Commit do
email_add_committer: false,
email_recipients: 'rec1 rec2'
commit = FactoryGirl.create :commit, project: project
- expected = 'git_author_email'
- commit.stub(:git_author_email) { expected }
commit.project_recipients.should == ['rec1', 'rec2']
end
@@ -115,7 +113,7 @@ describe Commit do
email_recipients: 'rec1 rec1 rec2'
commit = FactoryGirl.create :commit, project: project
expected = 'rec2'
- commit.stub(:git_author_email) { expected }
+ commit.stub(:push_data) { { user_email: expected } }
commit.project_recipients.should == ['rec1', 'rec2']
end
end