summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-18 20:16:21 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-12-18 20:16:21 +0200
commit5195cdd351f4ecff7966d3197211eceadb02855e (patch)
treef90c8903864e14c176099fba86b4a93e005a4a69
parent6128bdcb524314737b07a074d62e6eb6bf36095f (diff)
downloadgitlab-ci-5195cdd351f4ecff7966d3197211eceadb02855e.tar.gz
Fix notification for success builds
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/models/build.rb2
-rw-r--r--config/initializers/1_settings.rb6
-rw-r--r--spec/models/project_spec.rb46
3 files changed, 22 insertions, 32 deletions
diff --git a/app/models/build.rb b/app/models/build.rb
index 99193aa..5b90524 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -78,7 +78,7 @@ class Build < ActiveRecord::Base
project = build.project
if project.email_notification?
- if build.status.to_sym == :failed || project.email_all_broken_builds
+ if build.status.to_sym == :failed || !project.email_all_broken_builds
NotificationService.new.build_ended(build)
end
end
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index b6105e9..a7aa77b 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -1,7 +1,7 @@
class Settings < Settingslogic
source "#{Rails.root}/config/application.yml"
namespace Rails.env
-
+
class << self
def gitlab_ci_on_non_standard_port?
![443, 80].include?(gitlab_ci.port.to_i)
@@ -37,8 +37,8 @@ Settings.gitlab_ci['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] ||
Settings.gitlab_ci['protocol'] ||= Settings.gitlab_ci.https ? "https" : "http"
Settings.gitlab_ci['email_from'] ||= "gitlab-ci@#{Settings.gitlab_ci.host}"
Settings.gitlab_ci['support_email'] ||= Settings.gitlab_ci.email_from
-Settings.gitlab_ci['all_broken_builds'] ||= true
-Settings.gitlab_ci['add_committer'] ||= true
+Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
+Settings.gitlab_ci['add_committer'] = true if Settings.gitlab_ci['add_committer'].nil?
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 6a63a7e..df45bea 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -18,8 +18,8 @@
# gitlab_id :integer
# allow_git_fetch :boolean default(TRUE), not null
# email_recipients :string(255)
-# email_add_committer :boolean default(TRUE), not null
-# email_only_breaking_build :boolean default(TRUE), not null
+# email_add_committer :boolean default(TRUE), not null
+# email_only_breaking_build :boolean default(TRUE), not null
#
require 'spec_helper'
@@ -67,34 +67,24 @@ describe Project do
it { project.status_image.should == 'running.png' }
end
end
-
- describe '#email_notification?' do
- it {
- project = FactoryGirl.create :project, email_add_committer: true
- project.stub(:broken_or_success?).and_return(true)
- project.email_notification?.should == true
- }
- it {
+ describe '#email_notification?' do
+ it do
project = FactoryGirl.create :project, email_add_committer: true
- project.stub(:broken_or_success?).and_return(false)
- project.email_notification?.should == false
- }
-
+ project.email_notification?.should == true
+ end
- it {
- project = FactoryGirl.create :project, email_add_committer: false, email_recipients: 'test tesft'
- project.stub(:broken_or_success?).and_return(true)
- project.email_notification?.should == true
- }
+ it do
+ project = FactoryGirl.create :project, email_add_committer: false, email_recipients: 'test tesft'
+ project.email_notification?.should == true
+ end
- it {
- project = FactoryGirl.create :project, email_add_committer: false, email_recipients: ''
- project.stub(:broken_or_success?).and_return(true)
- project.email_notification?.should == false
- }
+ it do
+ project = FactoryGirl.create :project, email_add_committer: false, email_recipients: ''
+ project.email_notification?.should == false
+ end
end
-
+
describe '#broken_or_success?' do
it {
@@ -124,7 +114,7 @@ describe Project do
project.stub(:success?).and_return(false)
project.broken_or_success?.should == false
}
- end
+ end
end
# == Schema Information
@@ -147,7 +137,7 @@ end
# gitlab_id :integer
# allow_git_fetch :boolean default(TRUE), not null
# email_recipients :string(255)
-# email_add_committer :boolean default(TRUE), not null
-# email_only_breaking_build :boolean default(TRUE), not null
+# email_add_committer :boolean default(TRUE), not null
+# email_only_breaking_build :boolean default(TRUE), not null
#