Merge pull request #324 from abf/rosa-build:322-update-build-list-api
#322: [API] Add publish_into_testing action into BuildList API
This commit is contained in:
commit
00e8a518da
|
@ -5,7 +5,7 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
skip_before_filter :authenticate_user!, :only => [:show, :index] if APP_CONFIG['anonymous_access']
|
||||
|
||||
load_and_authorize_resource :project, :only => :index
|
||||
load_and_authorize_resource :build_list, :only => [:show, :create, :cancel, :publish, :reject_publish, :create_container]
|
||||
load_and_authorize_resource :build_list, :only => [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing]
|
||||
|
||||
def index
|
||||
filter = BuildList::Filter.new(@project, current_user, current_ability, params[:filter] || {})
|
||||
|
@ -46,6 +46,11 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
render_json :create_container, :publish_container
|
||||
end
|
||||
|
||||
def publish_into_testing
|
||||
@build_list.publisher = current_user
|
||||
render_json :publish_into_testing
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_json(action_name, action_method = nil)
|
||||
|
|
|
@ -82,7 +82,9 @@ en:
|
|||
create_container_success: 'Container is queued for creating'
|
||||
create_container_fail: 'Errors during container creating!'
|
||||
publish_success: 'Build is queued for publishing'
|
||||
publish_into_testing_success: 'Build is queued for publishing'
|
||||
publish_fail: 'Errors during build publishing!'
|
||||
publish_into_testing_fail: 'Errors during build publishing!'
|
||||
publish_with_extra_fail: 'All extra build lists should be published before publishing this build list!'
|
||||
cancel_success: 'Build canceled'
|
||||
cancel_fail: 'Errors during build cancelation!'
|
||||
|
|
|
@ -83,7 +83,9 @@ ru:
|
|||
cancel_success: 'Сборка отменена.'
|
||||
cancel_fail: 'При отмене сборки произошла ошибка!'
|
||||
publish_success: 'Сборка поставлена в очередь на публикацию.'
|
||||
publish_into_testing_success: 'Сборка поставлена в очередь на публикацию.'
|
||||
publish_fail: 'При публикации сборки произошла ошибка!'
|
||||
publish_into_testing_fail: 'При публикации сборки произошла ошибка!'
|
||||
publish_with_extra_fail: 'Все дополнительные сборки должны быть опубликованы до публикации этой сборки!'
|
||||
reject_publish_success: 'Публикация отклонена'
|
||||
reject_publish_fail: 'Не удалось отклонить публикацию сборки'
|
||||
|
|
|
@ -23,6 +23,7 @@ Rosa::Application.routes.draw do
|
|||
put :reject_publish
|
||||
put :cancel
|
||||
put :create_container
|
||||
put :publish_into_testing
|
||||
}
|
||||
end
|
||||
resources :arches, :only => [:index]
|
||||
|
|
|
@ -238,6 +238,107 @@ describe Api::V1::BuildListsController do
|
|||
end
|
||||
end
|
||||
|
||||
context 'do publish_into_testing' do
|
||||
def do_publish_into_testing
|
||||
put :publish_into_testing, :id => @build_list, :format => :json
|
||||
end
|
||||
|
||||
context 'if user is project && platform owner' do
|
||||
before(:each) do
|
||||
http_login(@owner_user)
|
||||
end
|
||||
|
||||
context "if it has :failed_publish status" do
|
||||
before do
|
||||
@build_list.update_column(:status, BuildList::FAILED_PUBLISH)
|
||||
do_publish_into_testing
|
||||
end
|
||||
it "should return correct json message" do
|
||||
response.body.should == { :build_list => {:id => @build_list.id, :message => I18n.t('layout.build_lists.publish_success')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 200 response code' do
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "should change status of build list" do
|
||||
@build_list.reload.status.should == BuildList::BUILD_PUBLISH_INTO_TESTING
|
||||
end
|
||||
end
|
||||
|
||||
context "if it has :build_published_into_testing status" do
|
||||
before do
|
||||
@build_list.update_column(:status, BuildList::BUILD_PUBLISHED_INTO_TESTING)
|
||||
do_publish_into_testing
|
||||
end
|
||||
|
||||
it "should return correct json message" do
|
||||
response.body.should == { :build_list => {:id => @build_list.id, :message => I18n.t('layout.build_lists.publish_success')} }.to_json
|
||||
end
|
||||
|
||||
it 'should return 200 response code' do
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it "should change status of build list" do
|
||||
@build_list.reload.status.should == BuildList::BUILD_PUBLISH_INTO_TESTING
|
||||
end
|
||||
end
|
||||
|
||||
context "if it has another status" do
|
||||
before(:each) do
|
||||
@build_list.update_column(:status, BuildList::BUILD_CANCELED)
|
||||
do_publish_into_testing
|
||||
end
|
||||
|
||||
it "should return access violation message" do
|
||||
response.body.should == {"message" => "Access violation to this page!"}.to_json
|
||||
end
|
||||
|
||||
it "should not change status of build list" do
|
||||
@build_list.reload.status.should == BuildList::BUILD_CANCELED
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'if user is not project owner' do
|
||||
|
||||
context "if it has :build_published_into_testing status" do
|
||||
before do
|
||||
@build_list.update_column(:status, BuildList::BUILD_PUBLISHED_INTO_TESTING)
|
||||
do_publish_into_testing
|
||||
end
|
||||
|
||||
it 'should not be able to perform create action' do
|
||||
response.body.should == {"message" => "Access violation to this page!"}.to_json
|
||||
end
|
||||
|
||||
it 'should return 403 response code' do
|
||||
response.status.should == 403
|
||||
end
|
||||
|
||||
it "should not change status of build list" do
|
||||
@build_list.reload.status.should == BuildList::BUILD_PUBLISHED_INTO_TESTING
|
||||
end
|
||||
end
|
||||
|
||||
context "if it has :failed_publish status" do
|
||||
before do
|
||||
@build_list.update_column(:status, BuildList::FAILED_PUBLISH_INTO_TESTING)
|
||||
do_publish_into_testing
|
||||
end
|
||||
it "should return access violation message" do
|
||||
response.body.should == {"message" => "Access violation to this page!"}.to_json
|
||||
end
|
||||
|
||||
it "should not change status of build list" do
|
||||
@build_list.reload.status.should == BuildList::FAILED_PUBLISH_INTO_TESTING
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "do publish" do
|
||||
def do_publish
|
||||
put :publish, :id => @build_list, :format => :json
|
||||
|
|
Loading…
Reference in New Issue