From ff522d9ef4016dad91f0405a33648871c07ee46d Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 22 Feb 2013 18:29:22 +0400 Subject: [PATCH] #757: revert changes in #can_publish? method --- app/helpers/build_lists_helper.rb | 4 ++++ app/models/build_list.rb | 5 ++--- app/views/projects/build_lists/show.html.haml | 10 +++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/helpers/build_lists_helper.rb b/app/helpers/build_lists_helper.rb index 02605b537..b6a27cbb1 100644 --- a/app/helpers/build_lists_helper.rb +++ b/app/helpers/build_lists_helper.rb @@ -85,6 +85,10 @@ module BuildListsHelper p.html_safe end + def can_publish_in_future?(bl) + [BuildList::SUCCESS, BuildList::FAILED_PUBLISH, BuildList::BUILD_PUBLISHED, BuildList::TESTS_FAILED].include?(bl.status) + end + def log_reload_time_options t = I18n.t("layout.build_lists.log.reload_times").map { |i| i.reverse } diff --git a/app/models/build_list.rb b/app/models/build_list.rb index e2a086a1b..1ec0a70b7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -282,9 +282,8 @@ class BuildList < ActiveRecord::Base build_started? || build_pending? end - def can_publish?(check_only_status = false) - by_status = [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) - check_only_status ? by_status : (by_status && extra_build_lists_published?) + def can_publish? + [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED].include?(status) && extra_build_lists_published? end def extra_build_lists_published? diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 8d7930ddb..c8cae418a 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -151,14 +151,14 @@ - if can?(:publish, @build_list) - if @build_list.build_published? = submit_tag t("layout.publish_again"), :confirm => t("layout.publish_again_warning"), :name => 'publish' - - elsif @build_list.can_publish?(true) - - if !@build_list.extra_build_lists_published? + - elsif can_publish_in_future?(@build_list) + - if @build_list.extra_build_lists_published? + - confirm = @build_list.tests_failed? ? t('layout.build_lists.tests_failed') : t('layout.confirm') + = submit_tag t("layout.publish"), :confirm => confirm, :name => 'publish' + - else .flash_notify .alert.alert-error= t('layout.build_lists.publish_with_extra_fail') .both - - else - - confirm = @build_list.tests_failed? ? t('layout.build_lists.tests_failed') : t('layout.confirm') - = submit_tag t("layout.publish"), :confirm => confirm, :name => 'publish' - if @build_list.can_reject_publish? && can?(:reject_publish, @build_list) = submit_tag t("layout.reject_publish"), :confirm => t("layout.confirm"), :name => 'reject_publish' - if @build_list.can_create_container? && can?(:create_container, @build_list)