diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-03-10 15:37:45 +0200 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-03-10 15:56:33 +0200 |
commit | 7499901c2421074b1730b8a803b9435a3f234506 (patch) | |
tree | c445cf6e3b2a44605befcd16c477ca6547370db9 | |
parent | e435e6b4a4100f1884088aa5a6156ce69304b473 (diff) | |
download | gitlab-ci-7499901c2421074b1730b8a803b9435a3f234506.tar.gz |
rename committer to pusher
-rw-r--r-- | app/controllers/services_controller.rb | 2 | ||||
-rw-r--r-- | app/models/commit.rb | 2 | ||||
-rw-r--r-- | app/models/project.rb | 8 | ||||
-rw-r--r-- | app/models/project_services/mail_service.rb | 4 | ||||
-rw-r--r-- | app/views/admin/projects/show.html.haml | 2 | ||||
-rw-r--r-- | config/application.yml.example | 4 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 2 | ||||
-rw-r--r-- | db/migrate/20150310001733_rename_committer_to_pusher.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 4 | ||||
-rw-r--r-- | spec/factories/projects.rb | 2 | ||||
-rw-r--r-- | spec/models/commit_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/mail_service_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 16 |
13 files changed, 39 insertions, 34 deletions
diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 99b4d65..39cf306 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -50,7 +50,7 @@ class ServicesController < ApplicationController def service_params params.require(:service).permit( :type, :active, :webhook, :notify_only_broken_builds, - :email_recipients, :email_only_broken_builds, :email_add_committer + :email_recipients, :email_only_broken_builds, :email_add_pusher ) end end diff --git a/app/models/commit.rb b/app/models/commit.rb index 82e20f8..2e1bd52 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -93,7 +93,7 @@ class Commit < ActiveRecord::Base def project_recipients recipients = project.email_recipients.split(' ') - if project.email_add_committer? && push_data[:user_email].present? + if project.email_add_pusher? && push_data[:user_email].present? recipients << push_data[:user_email] end diff --git a/app/models/project.rb b/app/models/project.rb index bf14dc5..d615f7e 100644 --- a/app/models/project.rb +++ b/app/models/project.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) @@ -29,7 +29,7 @@ class Project < ActiveRecord::Base attr_accessible :name, :path, :timeout, :token, :timeout_in_minutes, :default_ref, :gitlab_url, :always_build, :polling_interval, :public, :ssh_url_to_repo, :gitlab_id, :allow_git_fetch, :skip_refs, - :email_recipients, :email_add_committer, :email_only_broken_builds, :coverage_regex, + :email_recipients, :email_add_pusher, :email_only_broken_builds, :coverage_regex, :jobs_attributes has_many :commits, dependent: :destroy @@ -81,7 +81,7 @@ ls -la gitlab_url: project.web_url, default_ref: project.default_branch || 'master', ssh_url_to_repo: project.ssh_url_to_repo, - email_add_committer: GitlabCi.config.gitlab_ci.add_committer, + email_add_pusher: GitlabCi.config.gitlab_ci.add_pusher, email_only_broken_builds: GitlabCi.config.gitlab_ci.all_broken_builds, } @@ -137,7 +137,7 @@ ls -la end def email_notification? - email_add_committer || email_recipients.present? + email_add_pusher || email_recipients.present? end def web_hooks? diff --git a/app/models/project_services/mail_service.rb b/app/models/project_services/mail_service.rb index 380d2b6..a920968 100644 --- a/app/models/project_services/mail_service.rb +++ b/app/models/project_services/mail_service.rb @@ -14,7 +14,7 @@ class MailService < Service delegate :email_recipients, :email_recipients=, - :email_add_committer, :email_add_committer=, + :email_add_pusher, :email_add_pusher=, :email_only_broken_builds, :email_only_broken_builds=, to: :project, prefix: false before_save :update_project @@ -36,7 +36,7 @@ class MailService < Service def fields [ { type: 'text', name: 'email_recipients', label: 'Recipients', help: 'Whitespace-separated list of recipient addresses' }, - { type: 'checkbox', name: 'email_add_committer', label: 'Add committer to recipients list' }, + { type: 'checkbox', name: 'email_add_pusher', label: 'Add pusher to recipients list' }, { type: 'checkbox', name: 'email_only_broken_builds', label: 'Notify only broken builds' } ] end diff --git a/app/views/admin/projects/show.html.haml b/app/views/admin/projects/show.html.haml index 8204a90..f8e6b9f 100644 --- a/app/views/admin/projects/show.html.haml +++ b/app/views/admin/projects/show.html.haml @@ -42,7 +42,7 @@ %strong= @project.email_recipients %p Send mail to commiter: - %strong= @project.email_add_committer + %strong= @project.email_add_pusher %p Send on all broken builds: %strong= @project.email_only_broken_builds diff --git a/config/application.yml.example b/config/application.yml.example index acdc993..124d147 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -23,8 +23,8 @@ defaults: &defaults # Send emails only on broken builds (default: true) # all_broken_builds: true # - # Add committer to recipients list (default: false) - # add_committer: true + # Add pusher to recipients list (default: false) + # add_pusher: true gravatar: enabled: true diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 8b9703a..8e77da8 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -38,7 +38,7 @@ Settings.gitlab_ci['protocol'] ||= Settings.gitlab_ci.https ? "https" 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 if Settings.gitlab_ci['all_broken_builds'].nil? -Settings.gitlab_ci['add_committer'] = false if Settings.gitlab_ci['add_committer'].nil? +Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil? Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url) # Compatibility with old config diff --git a/db/migrate/20150310001733_rename_committer_to_pusher.rb b/db/migrate/20150310001733_rename_committer_to_pusher.rb new file mode 100644 index 0000000..7e18367 --- /dev/null +++ b/db/migrate/20150310001733_rename_committer_to_pusher.rb @@ -0,0 +1,5 @@ +class RenameCommitterToPusher < ActiveRecord::Migration + def change + rename_column :projects, :email_add_committer, :email_add_pusher + end +end diff --git a/db/schema.rb b/db/schema.rb index 804984c..b76eaa0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150306135341) do +ActiveRecord::Schema.define(version: 20150310001733) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -87,7 +87,7 @@ ActiveRecord::Schema.define(version: 20150306135341) do t.integer "gitlab_id" t.boolean "allow_git_fetch", default: true, null: false t.string "email_recipients", default: "", null: false - t.boolean "email_add_committer", default: true, null: false + t.boolean "email_add_pusher", default: true, null: false t.boolean "email_only_broken_builds", default: true, null: false t.string "skip_refs" t.string "coverage_regex" 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 d93488c..da57109 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -81,7 +81,7 @@ describe Commit do context 'always sending notification' 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 = 'commit_pusher_email' @@ -91,7 +91,7 @@ describe Commit 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 = 'commit_pusher_email' @@ -101,7 +101,7 @@ describe Commit do 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 commit.project_recipients.should == ['rec1', 'rec2'] @@ -109,7 +109,7 @@ describe Commit do 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' diff --git a/spec/models/mail_service_spec.rb b/spec/models/mail_service_spec.rb index 839333e..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) } @@ -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) } @@ -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") } @@ -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 |