#671: added API Platforms#destroy action and specs
This commit is contained in:
parent
d0bb3eebe6
commit
972877bc76
|
@ -72,6 +72,11 @@ class Api::V1::PlatformsController < Api::V1::BaseController
|
|||
render :json => json_response('Platform has been cleared successfully')
|
||||
end
|
||||
|
||||
def destroy
|
||||
@platform.destroy # later with resque
|
||||
render :json => json_response('Platform has been destroyed successfully')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def json_response(message, nullify_id = false)
|
||||
|
|
|
@ -20,7 +20,7 @@ Rosa::Application.routes.draw do
|
|||
}
|
||||
end
|
||||
resources :arches, :only => [:index]
|
||||
resources :platforms, :only => [:index, :show, :update] do
|
||||
resources :platforms, :only => [:index, :show, :update, :destroy] do
|
||||
collection {
|
||||
get :platforms_for_build
|
||||
}
|
||||
|
|
|
@ -59,6 +59,23 @@ shared_examples_for 'api platform user with writer rights' do
|
|||
@platform.members.should_not include(member)
|
||||
end
|
||||
end
|
||||
|
||||
context 'api platform user with destroy rights for main platforms only' do
|
||||
it 'should be able to perform destroy action for main platform' do
|
||||
delete :destroy, :id => @platform.id, :format => :json
|
||||
response.should be_success
|
||||
end
|
||||
it 'ensures that main platform has been destroyed' do
|
||||
lambda { delete :destroy, :id => @platform.id, :format => :json }.should change{ Platform.count }.by(-1)
|
||||
end
|
||||
it 'should not be able to perform destroy action for personal platform' do
|
||||
delete :destroy, :id => @personal_platform.id, :format => :json
|
||||
response.should_not be_success
|
||||
end
|
||||
it 'ensures that personal platform has not been destroyed' do
|
||||
lambda { delete :destroy, :id => @personal_platform.id, :format => :json }.should_not change{ Platform.count }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'api platform user without writer rights' do
|
||||
|
@ -117,6 +134,23 @@ shared_examples_for 'api platform user without writer rights' do
|
|||
end
|
||||
end
|
||||
|
||||
context 'api platform user without destroy rights' do
|
||||
it 'should not be able to perform destroy action for main platform' do
|
||||
delete :destroy, :id => @platform.id, :format => :json
|
||||
response.should_not be_success
|
||||
end
|
||||
it 'ensures that main platform has not been destroyed' do
|
||||
lambda { delete :destroy, :id => @platform.id, :format => :json }.should_not change{ Platform.count }
|
||||
end
|
||||
it 'should not be able to perform destroy action for personal platform' do
|
||||
delete :destroy, :id => @personal_platform.id, :format => :json
|
||||
response.should_not be_success
|
||||
end
|
||||
it 'ensures that personal platform has not been destroyed' do
|
||||
lambda { delete :destroy, :id => @personal_platform.id, :format => :json }.should_not change{ Platform.count }
|
||||
end
|
||||
end
|
||||
|
||||
it_should_behave_like 'api platform user without clone rights'
|
||||
it_should_behave_like 'api platform user without clear rights'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue