Merge pull request #445 from abf/rosa-build:update-access-rights-for-create-product-build-lists
Add ability for project writers for create ProductBuildList
This commit is contained in:
commit
dc2532c9bc
|
@ -141,6 +141,7 @@ class Ability
|
||||||
can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.main?}
|
can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.main?}
|
||||||
can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.main?}
|
can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.main?}
|
||||||
|
|
||||||
|
can([:create, :cancel], ProductBuildList) {|pbl| can?(:write, pbl.project)}
|
||||||
can([:create, :cancel, :update], ProductBuildList) {|pbl| can?(:update, pbl.product)}
|
can([:create, :cancel, :update], ProductBuildList) {|pbl| can?(:update, pbl.product)}
|
||||||
can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)}
|
can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,8 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
Time.now - LIVE_TIME, Time.now - MAX_LIVE_TIME)
|
Time.now - LIVE_TIME, Time.now - MAX_LIVE_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
after_initialize :init_project, if: :new_record?
|
||||||
|
|
||||||
after_create :add_job_to_abf_worker_queue
|
after_create :add_job_to_abf_worker_queue
|
||||||
before_destroy :can_destroy?
|
before_destroy :can_destroy?
|
||||||
|
|
||||||
|
@ -153,6 +155,10 @@ class ProductBuildList < ActiveRecord::Base
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def init_project
|
||||||
|
self.project ||= product.try(:project)
|
||||||
|
end
|
||||||
|
|
||||||
def abf_worker_priority
|
def abf_worker_priority
|
||||||
''
|
''
|
||||||
end
|
end
|
||||||
|
|
|
@ -115,6 +115,7 @@ end
|
||||||
describe Api::V1::ProductBuildListsController do
|
describe Api::V1::ProductBuildListsController do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
stub_symlink_methods
|
stub_symlink_methods
|
||||||
|
FactoryGirl.create(:arch, name: 'x86_64')
|
||||||
|
|
||||||
@product_build_list = FactoryGirl.create(:product_build_list)
|
@product_build_list = FactoryGirl.create(:product_build_list)
|
||||||
@another_user = FactoryGirl.create(:user)
|
@another_user = FactoryGirl.create(:user)
|
||||||
|
|
|
@ -318,5 +318,43 @@ describe CanCan do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end # 'repository relations'
|
end # 'repository relations'
|
||||||
|
|
||||||
|
context 'product build list relations' do
|
||||||
|
let(:product_build_list) { FactoryGirl.create(:product_build_list) }
|
||||||
|
|
||||||
|
before { FactoryGirl.create(:arch, name: 'x86_64') }
|
||||||
|
|
||||||
|
context 'with platform admin rights' do
|
||||||
|
before do
|
||||||
|
product_build_list.product.platform.owner = @user
|
||||||
|
product_build_list.product.platform.save
|
||||||
|
end
|
||||||
|
|
||||||
|
[:read, :create, :update, :destroy, :log, :cancel].each do |action|
|
||||||
|
it "should be able to #{action} product build list" do
|
||||||
|
@ability.should be_able_to(action, product_build_list)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with project writer rights' do
|
||||||
|
before do
|
||||||
|
create_relation(product_build_list.project, @user, 'writer')
|
||||||
|
end
|
||||||
|
|
||||||
|
[:read, :create, :log, :cancel].each do |action|
|
||||||
|
it "should be able to #{action} product build list" do
|
||||||
|
@ability.should be_able_to(action, product_build_list)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
[:update, :destroy].each do |action|
|
||||||
|
it "should not be able to #{action} product build list" do
|
||||||
|
@ability.should_not be_able_to(action, product_build_list)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end # 'product build list relations'
|
||||||
|
|
||||||
end # 'Site user'
|
end # 'Site user'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue