#757: send error when some containers for main platform have not been published

This commit is contained in:
Vokhmin Alexey V 2013-02-22 13:09:37 +04:00
parent 3e9c28e238
commit 38b6375ca3
5 changed files with 18 additions and 8 deletions

View File

@ -33,7 +33,11 @@ class Api::V1::BuildListsController < Api::V1::BaseController
end end
def publish def publish
if @build_list.can_publish_to_repository?
render_json :publish render_json :publish
else
render_validation_error @build_list, t('layout.build_lists.publish_with_extra_fail')
end
end end
def reject_publish def reject_publish

View File

@ -173,8 +173,12 @@ class Projects::BuildListsController < Projects::BaseController
end end
if @build_list.save and @build_list.now_publish if @build_list.save && @build_list.can_publish?
if @build_list.can_publish_to_repository? && @build_list.now_publish
redirect_to :back, :notice => t('layout.build_lists.publish_success') redirect_to :back, :notice => t('layout.build_lists.publish_success')
else
redirect_to :back, :notice => t('layout.build_lists.publish_with_extra_fail')
end
else else
redirect_to :back, :notice => t('layout.build_lists.publish_fail') redirect_to :back, :notice => t('layout.build_lists.publish_fail')
end end

View File

@ -287,6 +287,11 @@ class BuildList < ActiveRecord::Base
[SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include? status [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include? status
end end
def can_publish_to_repository?
return true unless save_to_platform.main?
BuildList.where(:id => extra_containers).where('status != ?', BUILD_PUBLISHED).count == 0
end
def can_reject_publish? def can_reject_publish?
can_publish? && !save_to_repository.publish_without_qa && !build_published? can_publish? && !save_to_repository.publish_without_qa && !build_published?
end end
@ -502,9 +507,4 @@ class BuildList < ActiveRecord::Base
self.extra_containers = bls.pluck('build_lists.id') self.extra_containers = bls.pluck('build_lists.id')
end end
def can_publish_to_repository?
return true unless save_to_platform.main?
BuildList.where(:id => extra_containers).where('status != ?', BUILD_PUBLISHED).count == 0
end
end end

View File

@ -80,6 +80,7 @@ en:
create_container_fail: 'Errors during container creating!' create_container_fail: 'Errors during container creating!'
publish_success: 'Build is queued for publishing' publish_success: 'Build is queued for publishing'
publish_fail: 'Errors during build publishing!' publish_fail: 'Errors during build publishing!'
publish_with_extra_fail: 'All extra containers should be published before publishing this build list!'
cancel_success: 'Build canceled' cancel_success: 'Build canceled'
cancel_fail: 'Errors during build cancelation!' cancel_fail: 'Errors during build cancelation!'
reject_publish_success: 'Publishing rejected' reject_publish_success: 'Publishing rejected'

View File

@ -81,6 +81,7 @@ ru:
cancel_fail: 'При отмене сборки произошла ошибка!' cancel_fail: 'При отмене сборки произошла ошибка!'
publish_success: 'Сборка поставлена в очередь на публикацию.' publish_success: 'Сборка поставлена в очередь на публикацию.'
publish_fail: 'При публикации сборки произошла ошибка!' publish_fail: 'При публикации сборки произошла ошибка!'
publish_with_extra_fail: 'Все дополнительные контейнеры должны быть опубликованы до публикации этой сборки!'
reject_publish_success: 'Публикация отклонена' reject_publish_success: 'Публикация отклонена'
reject_publish_fail: 'Не удалось отклонить публикацию сборки' reject_publish_fail: 'Не удалось отклонить публикацию сборки'
container_published: 'Контейнер размещен в репозитории' container_published: 'Контейнер размещен в репозитории'