#416: sends email when build list status is 'Unpermitted architecture'

This commit is contained in:
Vokhmin Alexey V 2014-09-23 21:41:34 +04:00
parent 43ab29a135
commit e7a24a27a3
2 changed files with 31 additions and 28 deletions

View File

@ -182,7 +182,7 @@ class BuildList < ActiveRecord::Base
end
after_transition on: :cancel, do: :cancel_job
after_transition on: [:published, :fail_publish, :build_error, :tests_failed], do: :notify_users
after_transition on: %i(published fail_publish build_error tests_failed unpermitted_arch), do: :notify_users
after_transition on: :build_success, do: :notify_users,
unless: ->(build_list) { build_list.auto_publish? || build_list.auto_publish_into_testing? }

View File

@ -58,21 +58,17 @@ describe BuildList do
end
context "#notify_users" do
let!(:user) { FactoryGirl.create(:user) }
let!(:build_list) { FactoryGirl.create(:build_list,
user: user,
auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_NONE) }
let!(:build_list_package) { FactoryGirl.create(:build_list_package,
build_list: build_list,
project: build_list.project) }
let(:user) { FactoryGirl.build(:user) }
let!(:build_list) {
FactoryGirl.create(:build_list,
user: user,
auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_NONE,
status: BuildList::BUILD_STARTED
)
}
before(:all) { ActionMailer::Base.deliveries = [] }
before do
build_list.update_attributes({commit_hash: build_list.project.repo.commits('master').last.id,
status: BuildList::BUILD_STARTED}, without_protection: true)
end
after { ActionMailer::Base.deliveries = [] }
before(:all) { ActionMailer::Base.deliveries = [] }
after { ActionMailer::Base.deliveries = [] }
shared_examples_for 'build list notifications by email' do
it "gets notification by email when status - Build complete" do
@ -85,51 +81,58 @@ describe BuildList do
should have(1).item
end
it "gets notification by email when status - Unpermitted architecture" do
build_list.unpermitted_arch
should have(1).item
end
it "gets notification by email when auto_publish and status - Build error" do
build_list.update_attributes(auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT)
build_list.auto_publish_status = BuildList::AUTO_PUBLISH_STATUS_DEFAULT
build_list.build_error
should have(1).item
end
it "gets notification by email when status - Failed publish" do
build_list.update_attributes({status: BuildList::BUILD_PUBLISH}, without_protection: true)
build_list.status = BuildList::BUILD_PUBLISH
build_list.fail_publish
should have(1).item
end
it "gets notification by email when auto_publish and status - Failed publish" do
build_list.update_attributes({auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT, status: BuildList::BUILD_PUBLISH}, without_protection: true)
build_list.auto_publish_status = BuildList::AUTO_PUBLISH_STATUS_DEFAULT
build_list.status = BuildList::BUILD_PUBLISH
build_list.fail_publish
should have(1).item
end
it "gets notification by email when status - Build published" do
build_list.update_attributes({status: BuildList::BUILD_PUBLISH}, without_protection: true)
build_list.status = BuildList::BUILD_PUBLISH
build_list.published
should have(1).item
end
it "gets notification by email when auto_publish and status - Build published" do
build_list.update_attributes({auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT, status: BuildList::BUILD_PUBLISH}, without_protection: true)
build_list.auto_publish_status = BuildList::AUTO_PUBLISH_STATUS_DEFAULT
build_list.status = BuildList::BUILD_PUBLISH
build_list.published
should have(1).item
end
it "doesn't get notification by email when auto_publish and status - Build complete" do
build_list.update_attributes(auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT)
build_list.auto_publish_status = BuildList::AUTO_PUBLISH_STATUS_DEFAULT
build_list.build_success
should have(:no).items
end
it "doesn't get notification by email when auto_publish_into_testing and status - Build complete" do
build_list.update_attributes(auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_TESTING)
build_list.auto_publish_status =BuildList::AUTO_PUBLISH_STATUS_TESTING
build_list.build_success
should have(:no).items
end
it "doesn't get notification by email when mass build" do
mb = FactoryGirl.build(:mass_build)
build_list.update_attributes(mass_build_id: mb.id, status: BuildList::BUILD_PUBLISH)
build_list.mass_build_id = 123
build_list.status = BuildList::BUILD_PUBLISH
build_list.published
should have(:no).items
end
@ -146,20 +149,21 @@ describe BuildList do
context "user created build task" do
let!(:notifier) { user.notifier }
before do
notifier.update_attributes(new_associated_build: false)
allow(notifier).to receive(:new_associated_build?).and_return(false)
build_list.project.owner.notifier.update_attributes(can_notify: false)
end
it_should_behave_like 'build list notifications by email'
it "doesn't get notification by email when 'build list' notifications has been disabled" do
notifier.update_attributes(new_build: false)
allow(notifier).to receive(:new_build?).and_return(false)
build_list.build_success
should have(:no).items
end
it "doesn't get notification by email when 'build list' notifications - enabled, email notifications - disabled" do
notifier.update_attributes(can_notify: false, new_build: true)
allow(notifier).to receive(:can_notify?).and_return(false)
allow(notifier).to receive(:new_build?).and_return(true)
build_list.build_success
should have(:no).items
end
@ -194,7 +198,6 @@ describe BuildList do
auto_publish_status: BuildList::AUTO_PUBLISH_STATUS_DEFAULT,
project: project
)
FactoryGirl.create(:build_list_package, build_list: bl, project: bl.project)
bl.update_attributes({commit_hash: bl.project.repo.commits('master').last.id,
status: BuildList::BUILD_PUBLISH}, without_protection: true)
bl.published