diff options
author | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-10 18:26:11 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dzaporozhets@gitlab.com> | 2015-03-10 18:26:11 +0000 |
commit | f8ebe264ee725a3d98bf04ef8c7a1f22cfd55907 (patch) | |
tree | db78dfbea34360c4c017c73b20204bf5e44a116c /spec | |
parent | 52a12893747ddac4a38dfa5becd3231e5092619c (diff) | |
parent | 7499901c2421074b1730b8a803b9435a3f234506 (diff) | |
download | gitlab-ci-f8ebe264ee725a3d98bf04ef8c7a1f22cfd55907.tar.gz |
Merge branch 'notify_based_on_pusher_email' into 'master'
Notify only pusher instead of commiter
Fixes #161
!!! Dependent MR on GitLab - https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/1630
See merge request !126
Diffstat (limited to 'spec')
-rw-r--r-- | spec/factories/commits.rb | 1 | ||||
-rw-r--r-- | spec/factories/projects.rb | 2 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 24 | ||||
-rw-r--r-- | spec/models/mail_service_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 16 |
5 files changed, 31 insertions, 32 deletions
diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb index 156fabe..3674643 100644 --- a/spec/factories/commits.rb +++ b/spec/factories/commits.rb @@ -25,6 +25,7 @@ FactoryGirl.define do before: '76de212e80737a608d939f648d959671fb0a0142', after: '97de212e80737a608d939f648d959671fb0a0142', user_name: 'Git User', + user_email: 'git@example.com', repository: { name: 'test-data', url: 'ssh://git@gitlab.com/test/test-data.git', diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 552cd4e..55e2cdd 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -17,7 +17,7 @@ # gitlab_id :integer # allow_git_fetch :boolean default(TRUE), not null # email_recipients :string(255) default(""), not null -# email_add_committer :boolean default(TRUE), not null +# email_add_pusher :boolean default(TRUE), not null # email_only_broken_builds :boolean default(TRUE), not null # skip_refs :string(255) # coverage_regex :string(255) diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 891cd52..da57109 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -79,43 +79,41 @@ 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_add_pusher: 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_add_pusher: 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 it 'should return recipients' do project = FactoryGirl.create :project, - email_add_committer: false, + email_add_pusher: 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 it 'should return unique recipients only' do project = FactoryGirl.create :project, - email_add_committer: true, + email_add_pusher: true, 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 diff --git a/spec/models/mail_service_spec.rb b/spec/models/mail_service_spec.rb index 7a43978..a24fca2 100644 --- a/spec/models/mail_service_spec.rb +++ b/spec/models/mail_service_spec.rb @@ -17,7 +17,7 @@ describe MailService do let(:mail) { MailService.new } describe 'failed build' do - let(:project) { FactoryGirl.create(:project, email_add_committer: true) } + let(:project) { FactoryGirl.create(:project, email_add_pusher: true) } let(:commit) { FactoryGirl.create(:commit, project: project) } let(:build) { FactoryGirl.create(:build, status: :failed, commit: commit) } @@ -28,7 +28,7 @@ describe MailService do end it do - should_email(commit.git_author_email) + should_email("git@example.com") mail.execute(build) end @@ -39,7 +39,7 @@ describe MailService do end describe 'successfull build' do - let(:project) { FactoryGirl.create(:project, email_add_committer: true, email_only_broken_builds: false) } + let(:project) { FactoryGirl.create(:project, email_add_pusher: true, email_only_broken_builds: false) } let(:commit) { FactoryGirl.create(:commit, project: project) } let(:build) { FactoryGirl.create(:build, status: :success, commit: commit) } @@ -50,7 +50,7 @@ describe MailService do end it do - should_email(commit.git_author_email) + should_email("git@example.com") mail.execute(build) end @@ -63,7 +63,7 @@ describe MailService do describe 'successfull build and project has email_recipients' do let(:project) { FactoryGirl.create(:project, - email_add_committer: true, + email_add_pusher: true, email_only_broken_builds: false, email_recipients: "jeroen@example.com") } @@ -77,7 +77,7 @@ describe MailService do end it do - should_email(commit.git_author_email) + should_email("git@example.com") should_email("jeroen@example.com") mail.execute(build) end @@ -91,7 +91,7 @@ describe MailService do describe 'successful build and notify only broken builds' do let(:project) { FactoryGirl.create(:project, - email_add_committer: true, + email_add_pusher: true, email_only_broken_builds: true, email_recipients: "jeroen@example.com") } @@ -119,7 +119,7 @@ describe MailService do describe 'successful build and can test service' do let(:project) { FactoryGirl.create(:project, - email_add_committer: true, + email_add_pusher: true, email_only_broken_builds: false, email_recipients: "jeroen@example.com") } @@ -141,7 +141,7 @@ describe MailService do describe 'successful build and cannot test service' do let(:project) { FactoryGirl.create(:project, - email_add_committer: true, + email_add_pusher: true, email_only_broken_builds: true, email_recipients: "jeroen@example.com") } @@ -163,7 +163,7 @@ describe MailService do describe 'retried build should not receive email' do let(:project) { FactoryGirl.create(:project, - email_add_committer: true, + email_add_pusher: true, email_only_broken_builds: true, email_recipients: "jeroen@example.com") } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 4f7f299..af7d162 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -17,7 +17,7 @@ # gitlab_id :integer # allow_git_fetch :boolean default(TRUE), not null # email_recipients :string(255) default(""), not null -# email_add_committer :boolean default(TRUE), not null +# email_add_pusher :boolean default(TRUE), not null # email_only_broken_builds :boolean default(TRUE), not null # skip_refs :string(255) # coverage_regex :string(255) @@ -63,45 +63,45 @@ describe Project do describe '#email_notification?' do it do - project = FactoryGirl.create :project, email_add_committer: true + project = FactoryGirl.create :project, email_add_pusher: true project.email_notification?.should == true end it do - project = FactoryGirl.create :project, email_add_committer: false, email_recipients: 'test tesft' + project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: 'test tesft' project.email_notification?.should == true end it do - project = FactoryGirl.create :project, email_add_committer: false, email_recipients: '' + project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: '' project.email_notification?.should == false end end describe '#broken_or_success?' do it { - project = FactoryGirl.create :project, email_add_committer: true + project = FactoryGirl.create :project, email_add_pusher: true project.stub(:broken?).and_return(true) project.stub(:success?).and_return(true) project.broken_or_success?.should == true } it { - project = FactoryGirl.create :project, email_add_committer: true + project = FactoryGirl.create :project, email_add_pusher: true project.stub(:broken?).and_return(true) project.stub(:success?).and_return(false) project.broken_or_success?.should == true } it { - project = FactoryGirl.create :project, email_add_committer: true + project = FactoryGirl.create :project, email_add_pusher: true project.stub(:broken?).and_return(false) project.stub(:success?).and_return(true) project.broken_or_success?.should == true } it { - project = FactoryGirl.create :project, email_add_committer: true + project = FactoryGirl.create :project, email_add_pusher: true project.stub(:broken?).and_return(false) project.stub(:success?).and_return(false) project.broken_or_success?.should == false |