#759: refactoring according to Vladimir's comments

This commit is contained in:
Vokhmin Alexey V 2012-12-06 21:34:09 +04:00
parent c3e8d18925
commit ab8c4016b5
3 changed files with 17 additions and 9 deletions

View File

@ -100,15 +100,12 @@ class Projects::BuildListsController < Projects::BaseController
end
def cancel
if @build_list.new_core? && @build_list.can_cancel?
@build_list.cancel_job
notice = t('layout.build_lists.will_be_canceled')
if @build_list.cancel
notice = @build_list.new_core? ?
t('layout.build_lists.will_be_canceled') :
t('layout.build_lists.cancel_success')
else
if @build_list.cancel
notice = t('layout.build_lists.cancel_success')
else
notice = t('layout.build_lists.cancel_fail')
end
notice = t('layout.build_lists.cancel_fail')
end
redirect_to :back, :notice => notice
end

View File

@ -141,6 +141,8 @@ class BuildList < ActiveRecord::Base
end
after_transition :on => :published, :do => [:set_version_and_tag, :actualize_packages]
after_transition :on => :cancel, :do => [:cancel_job],
:if => lambda { |build_list| build_list.build_canceling? }
after_transition :on => [:published, :fail_publish, :build_error], :do => :notify_users
after_transition :on => :build_success, :do => :notify_users,
@ -175,6 +177,15 @@ class BuildList < ActiveRecord::Base
transition [:build_pending, :platform_pending] => :build_canceled, :if => lambda { |build_list|
!build_list.new_core? && build_list.can_cancel? && BuildServer.delete_build_list(build_list.bs_id) == BuildServer::SUCCESS
}
transition [:build_pending, :build_started] => :build_canceling, :if => lambda { |build_list|
build_list.new_core? && build_list.can_cancel?
}
end
event :build_canceled do
transition [:build_canceling] => :build_canceled, :if => lambda { |build_list|
build_list.new_core?
}
end
event :published do

View File

@ -24,7 +24,7 @@ module AbfWorker
bl.save!
bl.start_build
when BUILD_CANCELED
bl.update_attributes({:status => BuildList::BUILD_CANCELED})
bl.build_canceled
item.update_attributes({:status => BuildList::BUILD_CANCELED})
end
if status != BUILD_STARTED