#859: some refactoring according to Alexander's comments
This commit is contained in:
parent
b8b03b62b0
commit
1cabd9cea8
|
@ -22,8 +22,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
bl_params[:auto_publish] = false unless save_to_repository.publish_without_qa?
|
||||
end
|
||||
|
||||
@build_list = BuildList.new(bl_params)
|
||||
@build_list.user = current_user
|
||||
@build_list = current_user.build_lists.new(bl_params)
|
||||
@build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
|
||||
|
||||
create_subject @build_list
|
||||
|
|
|
@ -223,9 +223,7 @@ class BuildList < ActiveRecord::Base
|
|||
:do => :remove_container
|
||||
|
||||
event :publish_container do
|
||||
transition [:waiting_for_publish, :container_failed_publish] => :container_publish, :if => lambda { |build_list|
|
||||
build_list.success?
|
||||
}
|
||||
transition [:waiting_for_publish, :container_failed_publish] => :container_publish, :if => :success?
|
||||
end
|
||||
|
||||
event :published_container do
|
||||
|
|
|
@ -73,9 +73,19 @@ shared_examples_for 'not create build list via api' do
|
|||
lambda { post :create, @create_params }.should change{ BuildList.count }.by(0)
|
||||
end
|
||||
|
||||
it 'should return 422 response code' do
|
||||
it 'should return 403 response code' do
|
||||
post :create, @create_params
|
||||
response.should_not be_success
|
||||
response.status.should == 403
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'validation error via build list api' do |message|
|
||||
it 'should return 422 response code' do
|
||||
response.status.should == 422
|
||||
end
|
||||
|
||||
it "should return correct json error message" do
|
||||
response.body.should == { :build_list => {:id => nil, :message => message} }.to_json
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -146,13 +156,7 @@ describe Api::V1::BuildListsController do
|
|||
do_cancel
|
||||
end
|
||||
|
||||
it "should return correct json error message" do
|
||||
response.body.should == { :build_list => {:id => nil, :message => I18n.t('layout.build_lists.cancel_fail')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 422 response code' do
|
||||
response.should_not be_success
|
||||
end
|
||||
it_should_behave_like 'validation error via build list api', I18n.t('layout.build_lists.cancel_fail')
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||
|
@ -211,13 +215,7 @@ describe Api::V1::BuildListsController do
|
|||
do_create_container
|
||||
end
|
||||
|
||||
it "should return correct json error message" do
|
||||
response.body.should == { :build_list => {:id => nil, :message => I18n.t('layout.build_lists.create_container_fail')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 422 response code' do
|
||||
response.should_not be_success
|
||||
end
|
||||
it_should_behave_like 'validation error via build list api', I18n.t('layout.build_lists.create_container_fail')
|
||||
|
||||
it "should not create container" do
|
||||
@build_list.reload.container_status.should == BuildList::WAITING_FOR_RESPONSE
|
||||
|
@ -273,13 +271,7 @@ describe Api::V1::BuildListsController do
|
|||
do_publish
|
||||
end
|
||||
|
||||
it "should return correct json error message" do
|
||||
response.body.should == { :build_list => {:id => nil, :message => I18n.t('layout.build_lists.publish_fail')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 422 response code' do
|
||||
response.should_not be_success
|
||||
end
|
||||
it_should_behave_like 'validation error via build list api', I18n.t('layout.build_lists.publish_fail')
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||
|
@ -341,13 +333,7 @@ describe Api::V1::BuildListsController do
|
|||
do_reject_publish
|
||||
end
|
||||
|
||||
it "should return correct json error message" do
|
||||
response.body.should == { :build_list => {:id => nil, :message => I18n.t('layout.build_lists.reject_publish_fail')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 422 response code' do
|
||||
response.should_not be_success
|
||||
end
|
||||
it_should_behave_like 'validation error via build list api', I18n.t('layout.build_lists.reject_publish_fail')
|
||||
|
||||
it "should not cancel build list" do
|
||||
@build_list.reload.status.should == BuildList::PROJECT_VERSION_NOT_FOUND
|
||||
|
|
Loading…
Reference in New Issue