#167: added specs for controller

This commit is contained in:
Vokhmin Alexey V 2013-06-14 03:03:02 +04:00
parent 28a503ecda
commit 4699086f29
1 changed files with 20 additions and 0 deletions

View File

@ -29,6 +29,11 @@ shared_examples_for 'user without change projects in repository rights' do
@repository.projects.should_not include(@project) @repository.projects.should_not include(@project)
end end
it 'should not be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(redirect_path)
end
it 'should not be able to remove project from repository' do it 'should not be able to remove project from repository' do
delete :remove_project, :id => @repository.id, :platform_id => @platform.id, :project_id => @project.id delete :remove_project, :id => @repository.id, :platform_id => @platform.id, :project_id => @project.id
response.should redirect_to(redirect_path) response.should redirect_to(redirect_path)
@ -42,6 +47,13 @@ shared_examples_for 'registered user or guest' do
response.should redirect_to(redirect_path) response.should redirect_to(redirect_path)
end end
it 'should not be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(redirect_path)
@redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1)
.should be_empty
end
it 'should not be able to perform create action' do it 'should not be able to perform create action' do
post :create, @create_params post :create, @create_params
lambda { post :create, @create_params }.should change{ Repository.count }.by(0) lambda { post :create, @create_params }.should change{ Repository.count }.by(0)
@ -121,6 +133,13 @@ shared_examples_for 'platform admin user' do
response.should render_template(:new) response.should render_template(:new)
end end
it 'should be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(platform_repository_path(@platform, @repository))
@redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1)
.should == ["#{@repository.id}-#{@platform.id}"]
end
it 'should be able to create repository' do it 'should be able to create repository' do
lambda { post :create, @create_params }.should change{ Repository.count }.by(1) lambda { post :create, @create_params }.should change{ Repository.count }.by(1)
response.should redirect_to(platform_repository_path(@platform, Repository.last)) response.should redirect_to(platform_repository_path(@platform, Repository.last))
@ -179,6 +198,7 @@ end
describe Platforms::RepositoriesController do describe Platforms::RepositoriesController do
before(:each) do before(:each) do
stub_symlink_methods stub_symlink_methods
stub_redis
@platform = FactoryGirl.create(:platform) @platform = FactoryGirl.create(:platform)
@repository = FactoryGirl.create(:repository, :platform => @platform) @repository = FactoryGirl.create(:repository, :platform => @platform)