#339: added synchronizing_publications into Repository

This commit is contained in:
Vokhmin Alexey V 2014-01-14 01:51:12 +04:00
parent e5db817583
commit 5db6516085
3 changed files with 37 additions and 5 deletions

View File

@ -47,6 +47,11 @@ class BuildList < ActiveRecord::Base
validate lambda {
errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_project')) unless save_to_repository.projects.exists?(project_id)
}
validate lambda {
if status == BUILD_PUBLISH && !can_publish_into_repository?
errors.add(:save_to_repository, I18n.t('flash.build_list.not_all_build_lists_success'))
end
}
before_validation lambda { self.include_repos = include_repos.uniq if include_repos.present? }, :on => :create
before_validation :prepare_extra_repositories, :on => :create
before_validation :prepare_extra_build_lists, :on => :create
@ -313,6 +318,27 @@ class BuildList < ActiveRecord::Base
[SUCCESS, BUILD_PUBLISH, FAILED_PUBLISH, BUILD_PUBLISHED, TESTS_FAILED, BUILD_PUBLISHED_INTO_TESTING, FAILED_PUBLISH_INTO_TESTING].include?(status) && [WAITING_FOR_RESPONSE, FAILED_PUBLISH].include?(container_status)
end
def can_publish_into_repository?
return true if !save_to_repository.synchronizing_publications? || save_to_platform.personal? || project.architecture_dependent?
arch_ids = save_to_platform.platform_arch_settings.by_default.pluck(:arch_id)
BuildList.where(
:project_id => project_id,
:save_to_repository_id => save_to_repository_id,
:arch_id => arch_ids,
:commit_hash => commit_hash,
:status => [
SUCCESS,
BUILD_PUBLISHED,
BUILD_PUBLISH,
FAILED_PUBLISH,
TESTS_FAILED,
BUILD_PUBLISHED_INTO_TESTING,
BUILD_PUBLISH_INTO_TESTING,
FAILED_PUBLISH_INTO_TESTING
]
).group(:arch_id).count == arch_ids.size
end
#TODO: Share this checking on product owner.
def can_cancel?
build_started? || build_pending?

View File

@ -0,0 +1,5 @@
class AddSynchronizePublicationToRepository < ActiveRecord::Migration
def change
add_column :repositories, :synchronizing_publications, :boolean, :default => false, :null => false
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131126154305) do
ActiveRecord::Schema.define(:version => 20140113205657) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -493,6 +493,7 @@ ActiveRecord::Schema.define(:version => 20131126154305) do
t.datetime "updated_at"
t.string "name", :null => false
t.boolean "publish_without_qa", :default => true
t.boolean "synchronizing_publications", :default => false, :null => false
end
add_index "repositories", ["platform_id"], :name => "index_repositories_on_platform_id"