diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index ae0083893..541ad91e1 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -1,15 +1,12 @@ # -*- encoding : utf-8 -*- class Platforms::ProductBuildListsController < Platforms::BaseController - before_filter :authenticate_user!, :except => [:status_build] + before_filter :authenticate_user! skip_before_filter :authenticate_user!, :only => [:index, :show, :log] if APP_CONFIG['anonymous_access'] - load_and_authorize_resource :platform, :except => [:index, :status_build] - load_and_authorize_resource :product, :through => :platform, :except => [:index, :status_build] - load_and_authorize_resource :product_build_list, :through => :product, :except => [:index, :status_build] + load_and_authorize_resource :platform, :except => :index + load_and_authorize_resource :product, :through => :platform, :except => :index + load_and_authorize_resource :product_build_list, :through => :product, :except => :index load_and_authorize_resource :only => [:index, :show, :log, :cancel] - before_filter :authenticate_product_builder!, :only => [:status_build] - before_filter :find_product_build_list, :only => [:status_build] - def new product = @product_build_list.product @product_build_list.params = product.params @@ -57,12 +54,6 @@ class Platforms::ProductBuildListsController < Platforms::BaseController end end - def status_build - @product_build_list.status = params[:status].to_i # ProductBuildList::BUILD_COMPLETED : ProductBuildList::BUILD_FAILED) - @product_build_list.save! - render :nothing => true - end - def destroy if @product_build_list.destroy flash[:notice] = t('flash.product_build_list.delete') diff --git a/app/models/ability.rb b/app/models/ability.rb index 14871a320..d1e2837a6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -23,9 +23,6 @@ class Ability can [:read, :log], ProductBuildList#, :product => {:platform => {:visibility => 'open'}} # double nested hash don't work can :read, Advisory - # Core callbacks - can [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt], BuildList - # Platforms block can [:show, :members, :advisories], Platform, :visibility => 'open' can :platforms_for_build, Platform, :visibility => 'open', :platform_type => 'main' @@ -83,7 +80,7 @@ class Ability can(:publish, BuildList) do |build_list| if build_list.build_published? - local_admin?(build_list.save_to_platform) + local_admin?(build_list.save_to_platform) || local_admin?(build_list.save_to_repository) else build_list.save_to_repository.publish_without_qa ? can?(:write, build_list.project) : local_admin?(build_list.save_to_platform) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 20730494a..605ee2524 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -186,9 +186,9 @@ class BuildList < ActiveRecord::Base end event :publish do + transition :published => :build_publish transition [:success, :failed_publish] => :build_publish transition [:success, :failed_publish] => :failed_publish - transition :published => :build_publish end event :reject_publish do @@ -271,11 +271,11 @@ class BuildList < ActiveRecord::Base end def can_publish? - [SUCCESS, FAILED_PUBLISH].include? status + [SUCCESS, FAILED_PUBLISH, BUILD_PUBLISHED].include? status end def can_reject_publish? - can_publish? and not save_to_repository.publish_without_qa + can_publish? && !save_to_repository.publish_without_qa && !build_published? end def add_to_queue diff --git a/config/routes.rb b/config/routes.rb index 1406ac24a..a67ef0064 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -167,7 +167,6 @@ Rosa::Application.routes.draw do match '/private/:platform_name/*file_path' => 'privates#show' resources :product_build_lists, :only => [:index] - match 'product_status', :to => 'product_build_lists#status_build' end resources :autocompletes, :only => [] do diff --git a/spec/controllers/platforms/product_build_lists_controller_spec.rb b/spec/controllers/platforms/product_build_lists_controller_spec.rb index 3fbf57d1e..f7ae23a8d 100644 --- a/spec/controllers/platforms/product_build_lists_controller_spec.rb +++ b/spec/controllers/platforms/product_build_lists_controller_spec.rb @@ -150,23 +150,4 @@ describe Platforms::ProductBuildListsController do end end - context 'callbacks' do - - let(:pbl) { FactoryGirl.create(:product_build_list) } - - before(:each) do - mock(controller).authenticate_product_builder! {true} - end - - def do_get - get :status_build, :id => pbl.id, :status => ProductBuildList::BUILD_FAILED - pbl.reload - end - - it "should update ProductBuildList status" do - expect { do_get }.to change(pbl, :status).to(ProductBuildList::BUILD_FAILED) - response.should be_success - response.body.should be_blank - end - end end diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index ccf4efc2c..f3c6415e4 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -60,11 +60,12 @@ describe CanCan do @ability.should_not be_able_to(:read, hidden_platform) end - [:publish_build, :status_build, :pre_build, :post_build, :circle_build, :new_bbdt].each do |action| - it "should be able to #{ action } build list" do - @ability.should be_able_to(action, BuildList) - end - end + [:publish, :cancel, :reject_publish, :create_container].each do |action| + it "should not be able to #{ action } build list" do + @ability.should_not be_able_to(action, BuildList) + end + end + it 'should not be able to update register request' do @ability.should_not be_able_to(:update, register_request)