diff --git a/app/models/ability.rb b/app/models/ability.rb index d8310dc60..53ca8bd42 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -82,7 +82,7 @@ class Ability can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'User', :owner_id => user.id} can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :log, :everything], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} - can(:create, BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project)} + can(:create, BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project) && can?(:read, build_list.build_for_platform) } can(:publish, BuildList) do |build_list| if build_list.build_published? diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 6fc73168d..b81d29ec8 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -35,7 +35,7 @@ class BuildList < ActiveRecord::Base errors.add(:build_for_platform, I18n.t('flash.build_list.wrong_build_for_platform')) unless build_for_platform.main? } validate lambda { - errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.map(&:id) + errors.add(:save_to_repository, I18n.t('flash.build_list.wrong_repository')) unless save_to_repository_id.in? save_to_platform.repositories.pluck(:id) } validate lambda { include_repos.each {|ir|