From 8b994cc6a5d1732386de4b9c16f9c6a5f6d15d98 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Tue, 26 Feb 2013 20:24:42 +0400 Subject: [PATCH] #963: publish build list only if project exist in repository --- app/models/ability.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 424e21d58..2d518d0ef 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -80,11 +80,15 @@ class Ability can([:create, :update], BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)} can(:publish, BuildList) do |build_list| - if build_list.build_published? - local_admin?(build_list.save_to_platform) || build_list.save_to_repository.members.exists?(:id => user.id) + if build_list.save_to_repository.projects.exists?(:id => build_list.project_id) + if build_list.build_published? + local_admin?(build_list.save_to_platform) || build_list.save_to_repository.members.exists?(:id => user.id) + else + build_list.save_to_repository.publish_without_qa ? + can?(:write, build_list.project) : local_admin?(build_list.save_to_platform) + end else - build_list.save_to_repository.publish_without_qa ? - can?(:write, build_list.project) : local_admin?(build_list.save_to_platform) + false end end can([:reject_publish, :create_container], BuildList) do |build_list|