Skip to content
This repository was archived by the owner on May 12, 2018. It is now read-only.

Commit 5195cdd

Browse files
committed
Fix notification for success builds
Signed-off-by: Dmitriy Zaporozhets <[email protected]>
1 parent 6128bdc commit 5195cdd

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

app/models/build.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def self.create_from(build)
7878
project = build.project
7979

8080
if project.email_notification?
81-
if build.status.to_sym == :failed || project.email_all_broken_builds
81+
if build.status.to_sym == :failed || !project.email_all_broken_builds
8282
NotificationService.new.build_ended(build)
8383
end
8484
end

config/initializers/1_settings.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Settings < Settingslogic
22
source "#{Rails.root}/config/application.yml"
33
namespace Rails.env
4-
4+
55
class << self
66
def gitlab_ci_on_non_standard_port?
77
![443, 80].include?(gitlab_ci.port.to_i)
@@ -37,8 +37,8 @@ def build_gitlab_ci_url
3737
Settings.gitlab_ci['protocol'] ||= Settings.gitlab_ci.https ? "https" : "http"
3838
Settings.gitlab_ci['email_from'] ||= "gitlab-ci@#{Settings.gitlab_ci.host}"
3939
Settings.gitlab_ci['support_email'] ||= Settings.gitlab_ci.email_from
40-
Settings.gitlab_ci['all_broken_builds'] ||= true
41-
Settings.gitlab_ci['add_committer'] ||= true
40+
Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
41+
Settings.gitlab_ci['add_committer'] = true if Settings.gitlab_ci['add_committer'].nil?
4242
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
4343

4444

spec/models/project_spec.rb

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# gitlab_id :integer
1919
# allow_git_fetch :boolean default(TRUE), not null
2020
# email_recipients :string(255)
21-
# email_add_committer :boolean default(TRUE), not null
22-
# email_only_breaking_build :boolean default(TRUE), not null
21+
# email_add_committer :boolean default(TRUE), not null
22+
# email_only_breaking_build :boolean default(TRUE), not null
2323
#
2424

2525
require 'spec_helper'
@@ -67,34 +67,24 @@
6767
it { project.status_image.should == 'running.png' }
6868
end
6969
end
70-
71-
describe '#email_notification?' do
72-
it {
73-
project = FactoryGirl.create :project, email_add_committer: true
74-
project.stub(:broken_or_success?).and_return(true)
75-
project.email_notification?.should == true
76-
}
7770

78-
it {
71+
describe '#email_notification?' do
72+
it do
7973
project = FactoryGirl.create :project, email_add_committer: true
80-
project.stub(:broken_or_success?).and_return(false)
81-
project.email_notification?.should == false
82-
}
83-
74+
project.email_notification?.should == true
75+
end
8476

85-
it {
86-
project = FactoryGirl.create :project, email_add_committer: false, email_recipients: 'test tesft'
87-
project.stub(:broken_or_success?).and_return(true)
88-
project.email_notification?.should == true
89-
}
77+
it do
78+
project = FactoryGirl.create :project, email_add_committer: false, email_recipients: 'test tesft'
79+
project.email_notification?.should == true
80+
end
9081

91-
it {
92-
project = FactoryGirl.create :project, email_add_committer: false, email_recipients: ''
93-
project.stub(:broken_or_success?).and_return(true)
94-
project.email_notification?.should == false
95-
}
82+
it do
83+
project = FactoryGirl.create :project, email_add_committer: false, email_recipients: ''
84+
project.email_notification?.should == false
85+
end
9686
end
97-
87+
9888
describe '#broken_or_success?' do
9989

10090
it {
@@ -124,7 +114,7 @@
124114
project.stub(:success?).and_return(false)
125115
project.broken_or_success?.should == false
126116
}
127-
end
117+
end
128118
end
129119

130120
# == Schema Information
@@ -147,7 +137,7 @@
147137
# gitlab_id :integer
148138
# allow_git_fetch :boolean default(TRUE), not null
149139
# email_recipients :string(255)
150-
# email_add_committer :boolean default(TRUE), not null
151-
# email_only_breaking_build :boolean default(TRUE), not null
140+
# email_add_committer :boolean default(TRUE), not null
141+
# email_only_breaking_build :boolean default(TRUE), not null
152142
#
153143

0 commit comments

Comments
 (0)