#388: added specs
This commit is contained in:
parent
870867c326
commit
6694634d9b
|
@ -21,6 +21,7 @@ class Platforms::ContentsController < Platforms::BaseController
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_file
|
def remove_file
|
||||||
|
authorize!(:remove_file, @platform)
|
||||||
PlatformContent.remove_file(@platform, params[:path])
|
PlatformContent.remove_file(@platform, params[:path])
|
||||||
render nothing: true
|
render nothing: true
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,34 @@ shared_examples_for 'content platform user with show rights' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'content platform user without owner rights' do
|
||||||
|
it 'should not be able to perform remove_file action for main platform' do
|
||||||
|
get :remove_file, platform_id: @platform, path: '/test'
|
||||||
|
response.should_not be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not be able to perform index remove_file for personal platform' do
|
||||||
|
get :remove_file, platform_id: @personal_platform, path: '/test'
|
||||||
|
response.should_not be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'content platform user with owner rights' do
|
||||||
|
before do
|
||||||
|
allow(PlatformContent).to receive(:remove_file)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be able to perform remove_file action for main platform' do
|
||||||
|
get :remove_file, platform_id: @platform, path: '/test'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be able to perform remove_file action for personal platform' do
|
||||||
|
get :remove_file, platform_id: @personal_platform, path: '/test'
|
||||||
|
response.should be_success
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe Platforms::ContentsController do
|
describe Platforms::ContentsController do
|
||||||
before do
|
before do
|
||||||
stub_symlink_methods
|
stub_symlink_methods
|
||||||
|
@ -52,6 +80,7 @@ describe Platforms::ContentsController do
|
||||||
|
|
||||||
it_should_behave_like 'content platform user with show rights' if APP_CONFIG['anonymous_access']
|
it_should_behave_like 'content platform user with show rights' if APP_CONFIG['anonymous_access']
|
||||||
it_should_behave_like 'content platform user without show rights for hidden platform'
|
it_should_behave_like 'content platform user without show rights for hidden platform'
|
||||||
|
it_should_behave_like 'content platform user without owner rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for global admin' do
|
context 'for global admin' do
|
||||||
|
@ -61,17 +90,20 @@ describe Platforms::ContentsController do
|
||||||
|
|
||||||
it_should_behave_like 'content platform user with show rights'
|
it_should_behave_like 'content platform user with show rights'
|
||||||
it_should_behave_like 'content platform user with show rights for hidden platform'
|
it_should_behave_like 'content platform user with show rights for hidden platform'
|
||||||
|
it_should_behave_like 'content platform user with owner rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for owner user' do
|
context 'for owner user' do
|
||||||
before do
|
before do
|
||||||
http_login(@user)
|
http_login(@user)
|
||||||
@platform.owner = @user; @platform.save
|
allow(Platform).to receive(:find).and_return(@platform)
|
||||||
|
allow(@platform).to receive(:owner).and_return(@user)
|
||||||
create_relation(@platform, @user, 'admin')
|
create_relation(@platform, @user, 'admin')
|
||||||
end
|
end
|
||||||
|
|
||||||
it_should_behave_like 'content platform user with show rights'
|
it_should_behave_like 'content platform user with show rights'
|
||||||
it_should_behave_like 'content platform user with show rights for hidden platform'
|
it_should_behave_like 'content platform user with show rights for hidden platform'
|
||||||
|
it_should_behave_like 'content platform user with owner rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for member of platform' do
|
context 'for member of platform' do
|
||||||
|
@ -83,6 +115,7 @@ describe Platforms::ContentsController do
|
||||||
|
|
||||||
it_should_behave_like 'content platform user with show rights'
|
it_should_behave_like 'content platform user with show rights'
|
||||||
it_should_behave_like 'content platform user with show rights for hidden platform'
|
it_should_behave_like 'content platform user with show rights for hidden platform'
|
||||||
|
it_should_behave_like 'content platform user without owner rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'for simple user' do
|
context 'for simple user' do
|
||||||
|
@ -92,6 +125,7 @@ describe Platforms::ContentsController do
|
||||||
|
|
||||||
it_should_behave_like 'content platform user with show rights'
|
it_should_behave_like 'content platform user with show rights'
|
||||||
it_should_behave_like 'content platform user without show rights for hidden platform'
|
it_should_behave_like 'content platform user without show rights for hidden platform'
|
||||||
|
it_should_behave_like 'content platform user without owner rights'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue