2012-05-29 13:40:25 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
shared_examples_for 'guest user' do
|
2012-08-31 23:00:39 +01:00
|
|
|
|
2012-09-06 19:48:36 +01:00
|
|
|
it "should be able to view maintainers list(index)" do
|
2014-01-21 04:51:49 +00:00
|
|
|
get :index, platform_id: @platform.id
|
2012-09-06 19:48:36 +01:00
|
|
|
response.should be_success
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-19 01:12:08 +00:00
|
|
|
describe Platforms::MaintainersController, type: :controller do
|
2012-05-31 12:43:40 +01:00
|
|
|
before(:each) do
|
2012-05-29 13:40:25 +01:00
|
|
|
stub_symlink_methods
|
|
|
|
|
|
|
|
@platform = FactoryGirl.create(:platform)
|
2012-09-06 19:48:36 +01:00
|
|
|
@user = FactoryGirl.create(:user)
|
|
|
|
set_session_for(@user)
|
2012-05-31 12:43:40 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'for guest' do
|
2012-09-06 19:48:36 +01:00
|
|
|
before {set_session_for(User.new)}
|
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
it "should be able to view maintainers list(index)", anonymous_access: true do
|
|
|
|
get :index, platform_id: @platform.id
|
2012-09-07 10:41:49 +01:00
|
|
|
response.should be_success
|
|
|
|
end
|
2012-09-06 19:48:36 +01:00
|
|
|
|
2014-01-21 04:51:49 +00:00
|
|
|
it "should not be able to view maintainers list(index)", anonymous_access: false do
|
|
|
|
get :index, platform_id: @platform.id
|
2012-09-07 10:41:49 +01:00
|
|
|
response.should redirect_to(new_user_session_path)
|
2012-09-06 19:48:36 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for global admin' do
|
|
|
|
before(:each) do
|
|
|
|
@user.role = "admin"
|
|
|
|
@user.save
|
|
|
|
end
|
|
|
|
|
|
|
|
it_should_behave_like 'guest user'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'for registrated user' do
|
|
|
|
|
|
|
|
it_should_behave_like 'guest user'
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'for platform owner' do
|
|
|
|
before(:each) do
|
|
|
|
@user = @platform.owner
|
|
|
|
set_session_for(@user)
|
|
|
|
end
|
|
|
|
|
2012-05-29 13:40:25 +01:00
|
|
|
it_should_behave_like 'guest user'
|
|
|
|
end
|
2012-05-31 12:43:40 +01:00
|
|
|
|
2012-09-06 19:48:36 +01:00
|
|
|
context 'for platform member' do
|
|
|
|
before(:each) do
|
2014-03-18 09:31:01 +00:00
|
|
|
create_relation(@platform, @user, 'admin')
|
2012-05-31 12:43:40 +01:00
|
|
|
end
|
2012-09-06 19:48:36 +01:00
|
|
|
|
|
|
|
it_should_behave_like 'guest user'
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|
2012-09-06 19:48:36 +01:00
|
|
|
|
2012-05-29 13:40:25 +01:00
|
|
|
end
|