rosa-build/spec/controllers/platforms/contents_controller_spec.rb

119 lines
3.8 KiB
Ruby
Raw Normal View History

require 'spec_helper'
shared_examples_for 'content platform user without show rights for hidden platform' do
it 'should not be able to perform index action' do
@platform.update_column(:visibility, 'hidden')
2014-01-21 04:51:49 +00:00
get :index, platform_id: @platform
response.should_not be_success
end
end
shared_examples_for 'content platform user with show rights for hidden platform' do
it 'should be able to perform index action' do
@platform.update_column(:visibility, 'hidden')
2014-01-21 04:51:49 +00:00
get :index, platform_id: @platform
response.should be_success
end
end
shared_examples_for 'content platform user with show rights' do
it 'should be able to perform index action for main platform' do
2014-01-21 04:51:49 +00:00
get :index, platform_id: @platform
response.should be_success
end
it 'should be able to perform index action for personal platform' do
2014-01-21 04:51:49 +00:00
get :index, platform_id: @personal_platform
response.should be_success
end
end
shared_examples_for 'content platform user without member rights' do
2014-05-20 22:43:22 +01:00
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 member rights' do
2014-05-20 22:43:22 +01:00
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
before do
stub_symlink_methods
@platform = FactoryGirl.create(:platform)
2014-01-21 04:51:49 +00:00
@personal_platform = FactoryGirl.create(:platform, platform_type: 'personal')
2014-01-10 02:59:33 +00:00
@user = FactoryGirl.create(:user)
end
context 'for guest' do
2014-01-21 04:51:49 +00:00
it 'should not be able to perform index action for main platform', anonymous_access: false do
get :index, platform_id: @platform
response.should_not be_success
end
2014-01-21 04:51:49 +00:00
it 'should not be able to perform index action for personal platform', anonymous_access: false do
get :index, platform_id: @personal_platform
response.should_not be_success
end
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 member rights'
end
context 'for global admin' do
before do
http_login(FactoryGirl.create(:admin))
end
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 member rights'
end
context 'for member of platform' do
before do
http_login(@user)
@platform.add_member(@user)
@personal_platform.add_member(@user)
end
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 member rights'
end
context 'for simple user' do
before do
http_login(@user)
end
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 member rights'
end
end