#167: updated specs

This commit is contained in:
Vokhmin Alexey V 2013-06-14 12:29:12 +04:00
parent 85ff53c8fd
commit 877d5283b3
1 changed files with 28 additions and 12 deletions

View File

@ -32,8 +32,7 @@ shared_examples_for 'user without change projects in repository rights' do
it 'should not be able to perform regenerate_metadata action' do it 'should not be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(redirect_path) response.should redirect_to(redirect_path)
@redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1) regenerate_metadata_queue.should be_empty
.should be_empty
end end
it 'should not be able to remove project from repository' do it 'should not be able to remove project from repository' do
@ -52,8 +51,13 @@ shared_examples_for 'registered user or guest' do
it 'should not be able to perform regenerate_metadata action' do it 'should not be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(redirect_path) response.should redirect_to(redirect_path)
@redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1) regenerate_metadata_queue.should be_empty
.should be_empty end
it 'should not be able to perform regenerate_metadata action of personal repository' do
put :regenerate_metadata, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id
response.should redirect_to(redirect_path)
regenerate_metadata_queue.should be_empty
end end
it 'should not be able to perform create action' do it 'should not be able to perform create action' do
@ -102,8 +106,8 @@ shared_examples_for 'registered user or guest' do
end end
it 'should not be able to destroy personal repository' do it 'should not be able to destroy personal repository' do
lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}. lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}
should change{ Repository.count }.by(0) .should change{ Repository.count }.by(0)
response.should redirect_to(redirect_path) response.should redirect_to(redirect_path)
end end
end end
@ -138,8 +142,19 @@ shared_examples_for 'platform admin user' do
it 'should be able to perform regenerate_metadata action' do it 'should be able to perform regenerate_metadata action' do
put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id put :regenerate_metadata, :id => @repository.id, :platform_id => @platform.id
response.should redirect_to(platform_repository_path(@platform, @repository)) response.should redirect_to(platform_repository_path(@platform, @repository))
@redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1) regenerate_metadata_queue.should == ["#{@repository.id}-#{@platform.id}"]
.should == ["#{@repository.id}-#{@platform.id}"] end
it 'should be able to perform regenerate_metadata action of personal repository' do
put :regenerate_metadata, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id, :build_for_platform_id => @platform.id
response.should redirect_to(platform_repository_path(@personal_repository.platform, @personal_repository))
regenerate_metadata_queue.should == ["#{@personal_repository.id}-#{@platform.id}"]
end
it 'should not be able to perform regenerate_metadata action of personal repository when build_for_platform does not exist' do
put :regenerate_metadata, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id
response.should render_template(:file => "#{Rails.root}/public/404.html")
regenerate_metadata_queue.should be_empty
end end
it 'should be able to create repository' do it 'should be able to create repository' do
@ -183,14 +198,14 @@ shared_examples_for 'platform admin user' do
it 'should not be able to destroy personal repository with name "main"' do it 'should not be able to destroy personal repository with name "main"' do
# hook for "ActiveRecord::ActiveRecordError: name is marked as readonly" # hook for "ActiveRecord::ActiveRecordError: name is marked as readonly"
Repository.where(:id => @personal_repository.id).update_all("name = 'main'") Repository.where(:id => @personal_repository.id).update_all("name = 'main'")
lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}. lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}
should change{ Repository.count }.by(0) .should change{ Repository.count }.by(0)
response.should redirect_to(forbidden_path) response.should redirect_to(forbidden_path)
end end
it 'should be able to destroy personal repository with name not "main"' do it 'should be able to destroy personal repository with name not "main"' do
lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}. lambda { delete :destroy, :id => @personal_repository.id, :platform_id => @personal_repository.platform.id}
should change{ Repository.count }.by(-1) .should change{ Repository.count }.by(-1)
response.should redirect_to(platform_repositories_path(@personal_repository.platform)) response.should redirect_to(platform_repositories_path(@personal_repository.platform))
end end
@ -198,6 +213,7 @@ shared_examples_for 'platform admin user' do
end end
describe Platforms::RepositoriesController do describe Platforms::RepositoriesController do
let(:regenerate_metadata_queue) { @redis_instance.lrange(AbfWorker::BuildListsPublishTaskManager::REGENERATE_METADATA, 0, -1) }
before(:each) do before(:each) do
stub_symlink_methods stub_symlink_methods
stub_redis stub_redis