#880: remove unnecessary code, update specs
This commit is contained in:
parent
973fabb31f
commit
2fa96551aa
|
@ -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')
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -60,12 +60,13 @@ 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)
|
||||
[: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)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue