#83: added specs for repositories_controller

This commit is contained in:
Vokhmin Alexey V 2013-07-29 13:50:45 +04:00
parent ad46e25654
commit afb0bb40e6
1 changed files with 24 additions and 0 deletions

View File

@ -20,6 +20,25 @@ shared_examples_for 'user with change projects in repository rights' do
@repository.projects.should_not include(@project)
end
end
shared_examples_for 'user with rights of lock/unlock sync of repository' do
[:lock_sync, :unlock_sync].each do |action|
it "should be able to perform #{action} action" do
put action, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(edit_platform_repository_path(@platform, @repository))
end
end
end
shared_examples_for 'user without rights of lock/unlock sync of repository' do
[:lock_sync, :unlock_sync].each do |action|
it "should not be able to perform #{action} action" do
put action, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(redirect_path)
end
end
end
shared_examples_for 'user without change projects in repository rights' do
@ -133,6 +152,7 @@ end
shared_examples_for 'platform admin user' do
it_should_behave_like 'registered user'
it_should_behave_like 'user with rights of lock/unlock sync of repository'
it 'should be able to perform new action' do
get :new, :platform_id => @platform.id
@ -240,6 +260,7 @@ describe Platforms::RepositoriesController do
let(:redirect_path) { new_user_session_path }
it_should_behave_like 'registered user or guest'
it_should_behave_like 'user without change projects in repository rights'
it_should_behave_like 'user without rights of lock/unlock sync of repository'
it "should not be able to perform show action", :anonymous_access => false do
get :show, :id => @repository
@ -264,6 +285,7 @@ describe Platforms::RepositoriesController do
let(:redirect_path) { forbidden_path }
it_should_behave_like 'registered user or guest'
it_should_behave_like 'user without change projects in repository rights'
it_should_behave_like 'user without rights of lock/unlock sync of repository'
end
context 'for admin' do
@ -311,6 +333,7 @@ describe Platforms::RepositoriesController do
let(:redirect_path) { forbidden_path }
it_should_behave_like 'registered user or guest'
it_should_behave_like 'user with change projects in repository rights'
it_should_behave_like 'user without rights of lock/unlock sync of repository'
context 'for hidden platform' do
before do
@ -322,6 +345,7 @@ describe Platforms::RepositoriesController do
let(:redirect_path) { forbidden_path }
it_should_behave_like 'registered user or guest'
it_should_behave_like 'user with change projects in repository rights'
it_should_behave_like 'user without rights of lock/unlock sync of repository'
end
end