diff --git a/app/models/platform.rb b/app/models/platform.rb index b848e91b7..375789fc2 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -108,8 +108,8 @@ class Platform < ActiveRecord::Base def mount_directory_for_rsync #FileUtils.rm_rf "#{ Rails.root.join('tmp', 'umount', self.name) }" if File.exist? "#{ Rails.root.join('tmp', 'umount', name) }" #FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'mount', name) }" - system("sudo mkdir -p \"#{ Rails.root.join("public", "downloads") }/#{ name }\"") - system("sudo mount --bind \"/home/share/platforms/#{ name }\" \"#{ Rails.root.join("public", "downloads") }/#{ name }\"") + system("sudo mkdir -p #{ Rails.root.join("public", "downloads") }/#{ name }") + system("sudo mount --bind /home/share/platforms/#{ name } #{ Rails.root.join("public", "downloads") }/#{ name }") #system("sudo cp -f /srv/rosa_build/current/tmp/mount/#{ name }/* /home/share/platforms/#{ name }/repository/") #system("sudo rm -Rf \"/srv/rosa_build/current/tmp/mount/#{ name }\"") Arch.all.each do |arch| @@ -121,8 +121,8 @@ class Platform < ActiveRecord::Base end def umount_directory_for_rsync - system("umount \"#{ Rails.root.join("public", "downloads") }/#{ name }\"") - system("rm -Rf \"#{ Rails.root.join("public", "downloads") }/#{ name }\"") + system("sudo umount #{ Rails.root.join("public", "downloads") }/#{ name }") + system("sudo rm -Rf #{ Rails.root.join("public", "downloads") }/#{ name }") #system("rm -Rf \"/srv/rosa_build/current/tmp/umount/#{ name }\"") #FileUtils.rm_rf "#{ Rails.root.join('tmp', 'mount', name) }" if File.exist? "#{ Rails.root.join('tmp', 'mount', name) }" #FileUtils.mkdir_p "#{ Rails.root.join('tmp', 'umount', name) }" diff --git a/spec/controllers/collaborators_controller_spec.rb b/spec/controllers/collaborators_controller_spec.rb index f8a2d8819..4fece56ed 100644 --- a/spec/controllers/collaborators_controller_spec.rb +++ b/spec/controllers/collaborators_controller_spec.rb @@ -26,9 +26,9 @@ describe CollaboratorsController do set_session_for(@admin) end - it_should_behave_like 'be_able_to_perform_index#collaborators' - it_should_behave_like 'be_able_to_perform_update#collaborators' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'show collaborators list' + it_should_behave_like 'update collaborators' + it_should_behave_like 'update collaborator relation' end context 'for admin user' do @@ -39,9 +39,9 @@ describe CollaboratorsController do @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') end - it_should_behave_like 'be_able_to_perform_index#collaborators' - it_should_behave_like 'be_able_to_perform_update#collaborators' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'show collaborators list' + it_should_behave_like 'update collaborators' + it_should_behave_like 'update collaborator relation' end context 'for owner user' do @@ -52,9 +52,9 @@ describe CollaboratorsController do @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') end - it_should_behave_like 'be_able_to_perform_index#collaborators' - it_should_behave_like 'be_able_to_perform_update#collaborators' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'show collaborators list' + it_should_behave_like 'update collaborators' + it_should_behave_like 'update collaborator relation' end context 'for reader user' do @@ -65,9 +65,9 @@ describe CollaboratorsController do @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') end - it_should_behave_like 'not_be_able_to_perform_index#collaborators' - it_should_behave_like 'not_be_able_to_perform_update#collaborators' - it_should_behave_like 'not_update_collaborator_relation' + it_should_behave_like 'not show collaborators list' + it_should_behave_like 'not update collaborators' + it_should_behave_like 'not update collaborator relation' end context 'for writer user' do @@ -78,8 +78,8 @@ describe CollaboratorsController do @project.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'writer') end - it_should_behave_like 'not_be_able_to_perform_index#collaborators' - it_should_behave_like 'not_be_able_to_perform_update#collaborators' - it_should_behave_like 'not_update_collaborator_relation' + it_should_behave_like 'not show collaborators list' + it_should_behave_like 'not update collaborators' + it_should_behave_like 'not update collaborator relation' end end diff --git a/spec/controllers/personal_repositories_controller_spec.rb b/spec/controllers/personal_repositories_controller_spec.rb index a944ad78a..09395e483 100644 --- a/spec/controllers/personal_repositories_controller_spec.rb +++ b/spec/controllers/personal_repositories_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe PersonalRepositoriesController do before(:each) do + stub_rsync_methods + @repository = Factory(:personal_repository) @platform = Factory(:platform) @project = Factory(:project) @@ -25,15 +27,14 @@ describe PersonalRepositoriesController do set_session_for(@admin) end - it_should_behave_like 'be_able_to_perform_show#personal_repositories' - it_should_behave_like 'be_able_to_perform_add_project#personal_repositories' - it_should_behave_like 'be_able_to_perform_add_project#personal_repositories_with_project_id_param' + it_should_behave_like 'show personal repository' + it_should_behave_like 'add project to personal repository' + it_should_behave_like 'add project personal repository with project_id param' it_should_behave_like 'add_project_to_repository' - it_should_behave_like 'be_able_to_perform_remove_project#personal_repositories' - it_should_behave_like 'remove_project_from_repository' - it_should_behave_like 'be_able_to_perform_settings#personal_repositories' - it_should_behave_like 'be_able_to_perform_change_visibility' - it_should_behave_like 'be_able_to_change_visibility' + it_should_behave_like 'remove project from repository' + it_should_behave_like 'remove project from personal repository' + it_should_behave_like 'change visibility' + it_should_behave_like 'settings personal repository' end context 'for anyone except admin' do @@ -56,15 +57,14 @@ describe PersonalRepositoriesController do @repository.platform.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'admin') end - it_should_behave_like 'be_able_to_perform_settings#personal_repositories' - it_should_behave_like 'be_able_to_perform_change_visibility' - it_should_behave_like 'be_able_to_change_visibility' - it_should_behave_like 'be_able_to_perform_show#personal_repositories' - it_should_behave_like 'be_able_to_perform_add_project#personal_repositories' - it_should_behave_like 'be_able_to_perform_add_project#personal_repositories_with_project_id_param' + it_should_behave_like 'show personal repository' + it_should_behave_like 'change visibility' + it_should_behave_like 'add project to personal repository' + it_should_behave_like 'add project personal repository with project_id param' it_should_behave_like 'add_project_to_repository' - it_should_behave_like 'be_able_to_perform_remove_project#personal_repositories' - it_should_behave_like 'remove_project_from_repository' + it_should_behave_like 'remove project from personal repository' + it_should_behave_like 'remove project from repository' + it_should_behave_like 'settings personal repository' end context 'for reader user' do @@ -74,7 +74,7 @@ describe PersonalRepositoriesController do @repository.relations.create!(:object_type => 'User', :object_id => @user.id, :role => 'reader') end - it_should_behave_like 'be_able_to_perform_show#personal_repositories' + it_should_behave_like 'show personal repository' it 'should not be able to perform add_project action' do get :add_project, :id => @repository.id diff --git a/spec/controllers/platforms_controller_spec.rb b/spec/controllers/platforms_controller_spec.rb index c0ac1fb15..a0e81f387 100644 --- a/spec/controllers/platforms_controller_spec.rb +++ b/spec/controllers/platforms_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe PlatformsController do before(:each) do + stub_rsync_methods + @platform = Factory(:platform) @personal_platform = Factory(:platform, :platform_type => 'personal') @user = Factory(:user) diff --git a/spec/controllers/product_build_lists_controller_spec.rb b/spec/controllers/product_build_lists_controller_spec.rb index a0655f773..09be0d63c 100644 --- a/spec/controllers/product_build_lists_controller_spec.rb +++ b/spec/controllers/product_build_lists_controller_spec.rb @@ -1,6 +1,10 @@ require 'spec_helper' describe ProductBuildListsController do + before(:each) do + stub_rsync_methods + end + context 'crud' do def valid_attributes {:product_id => product.id, :platform_id => product.platform_id} diff --git a/spec/controllers/products_controller_spec.rb b/spec/controllers/products_controller_spec.rb index 4dc30c407..7b6e4f4f6 100644 --- a/spec/controllers/products_controller_spec.rb +++ b/spec/controllers/products_controller_spec.rb @@ -2,6 +2,8 @@ require 'spec_helper' describe ProductsController do before(:each) do + stub_rsync_methods + @another_user = Factory(:user) @platform = Factory(:platform) @product = Factory(:product, :platform => @platform) diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 4567822d2..eded2b56c 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe ProjectsController do before(:each) do + stub_rsync_methods + @project = Factory(:project) @another_user = Factory(:user) @create_params = {:project => {:name => 'pro'}} @@ -40,7 +42,7 @@ describe ProjectsController do it_should_behave_like 'be_able_to_perform_index#projects' it_should_behave_like 'be_able_to_perform_update#projects' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'update collaborator relation' it 'should be able to perform create action' do post :create, @create_params @@ -63,7 +65,7 @@ describe ProjectsController do end it_should_behave_like 'be_able_to_perform_update#projects' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'update collaborator relation' it_should_behave_like 'be_able_to_perform_build#projects' it_should_behave_like 'be_able_to_perform_process_build#projects' @@ -107,7 +109,7 @@ describe ProjectsController do end it_should_behave_like 'be_able_to_perform_update#projects' - it_should_behave_like 'update_collaborator_relation' + it_should_behave_like 'update collaborator relation' it_should_behave_like 'be_able_to_perform_build#projects' it_should_behave_like 'be_able_to_perform_process_build#projects' it_should_behave_like 'be_able_to_fork_project' diff --git a/spec/controllers/repositories_controller_spec.rb b/spec/controllers/repositories_controller_spec.rb index 6521b6292..6cb672d00 100644 --- a/spec/controllers/repositories_controller_spec.rb +++ b/spec/controllers/repositories_controller_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe RepositoriesController do before(:each) do + stub_rsync_methods + @repository = Factory(:repository) @personal_repository = Factory(:personal_repository) @platform = Factory(:platform) @@ -56,8 +58,8 @@ describe RepositoriesController do it_should_behave_like 'be_able_to_perform_add_project#repositories_with_project_id_param' it_should_behave_like 'add_project_to_repository' it_should_behave_like 'be_able_to_perform_remove_project#repositories' - it_should_behave_like 'remove_project_from_repository' - it_should_behave_like 'not_be_able_to_destroy_personal_repository' + it_should_behave_like 'remove project from repository' + it_should_behave_like 'destroy personal repository' end context 'for anyone except admin' do @@ -80,7 +82,7 @@ describe RepositoriesController do lambda { post :create, @create_params }.should change{ Repository.count }.by(0) end - it_should_behave_like 'not_be_able_to_destroy_personal_repository' + it_should_behave_like 'not destroy personal repository' end context 'for owner user' do @@ -97,7 +99,7 @@ describe RepositoriesController do it_should_behave_like 'be_able_to_perform_add_project#repositories_with_project_id_param' it_should_behave_like 'add_project_to_repository' it_should_behave_like 'be_able_to_perform_remove_project#repositories' - it_should_behave_like 'remove_project_from_repository' + it_should_behave_like 'remove project from repository' it_should_behave_like 'be_able_to_perform_destroy#repositories' it_should_behave_like 'change_repositories_count_after_destroy' end diff --git a/spec/models/cancan_spec.rb b/spec/models/cancan_spec.rb index 8187fe613..fa34d7845 100644 --- a/spec/models/cancan_spec.rb +++ b/spec/models/cancan_spec.rb @@ -22,6 +22,10 @@ describe CanCan do let(:open_platform) { Factory(:platform, :visibility => 'open') } let(:hidden_platform) { Factory(:platform, :visibility => 'hidden') } + before(:each) do + stub_rsync_methods + end + context 'Site admin' do before(:each) do admin_create @@ -246,4 +250,4 @@ describe CanCan do end -end \ No newline at end of file +end diff --git a/spec/models/platform_spec.rb b/spec/models/platform_spec.rb index ac691f491..a79ce4699 100644 --- a/spec/models/platform_spec.rb +++ b/spec/models/platform_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' describe Platform do before(:each) do + stub_rsync_methods Platform.delete_all FileUtils.rm_rf(APP_CONFIG['root_path']) end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 61707543e..0f7545d4a 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -4,6 +4,7 @@ describe Repository do context 'when create with same owner that platform' do before (:each) do + stub_rsync_methods @platform = Factory(:platform) @params = {:name => 'tst_platform', :description => 'test platform'} end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a7804d8f5..e15db9c3b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,7 +32,14 @@ def set_session_for(user=nil) sign_in current_user end +def stub_rsync_methods + any_instance_of(Platform, :mount_directory_for_rsync => true) + any_instance_of(Platform, :umount_directory_for_rsync => true) +end + # Add testing root_path %x(rm -Rf #{Rails.root}/tmp/test_root) %x(mkdir -p #{Rails.root}/tmp/test_root) APP_CONFIG['root_path'] = "#{Rails.root}/tmp/test_root" + + diff --git a/spec/support/shared_examples/collaborators_controller.rb b/spec/support/shared_examples/collaborators_controller.rb index 0ceb5e263..bca0bc2de 100644 --- a/spec/support/shared_examples/collaborators_controller.rb +++ b/spec/support/shared_examples/collaborators_controller.rb @@ -1,38 +1,38 @@ -shared_examples_for 'be_able_to_perform_index#collaborators' do +shared_examples_for 'show collaborators list' do it 'should be able to perform index action' do get :index, :project_id => @project.id response.should redirect_to(edit_project_collaborators_path(@project)) end end -shared_examples_for 'be_able_to_perform_update#collaborators' do +shared_examples_for 'update collaborators' do it 'should be able to perform update action' do post :update, {:project_id => @project.id}.merge(@update_params) response.should redirect_to(project_path(@project)) end end -shared_examples_for 'update_collaborator_relation' do +shared_examples_for 'update collaborator relation' do it 'should update collaborator relation' do @another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read' end end -shared_examples_for 'not_be_able_to_perform_index#collaborators' do +shared_examples_for 'not show collaborators list' do it 'should be able to perform index action' do get :index, :project_id => @project.id response.should redirect_to(edit_project_collaborators_path(@project)) end end -shared_examples_for 'not_be_able_to_perform_update#collaborators' do +shared_examples_for 'not update collaborators' do it 'should be able to perform update action' do post :update, {:project_id => @project.id}.merge(@update_params) response.should redirect_to(project_path(@project)) end end -shared_examples_for 'not_update_collaborator_relation' do +shared_examples_for 'not update collaborator relation' do it 'should set flash notice on update success' do !@another_user.relations.exists? :target_id => @project.id, :target_type => 'Project', :role => 'read' end diff --git a/spec/support/shared_examples/personal_repositories_controller.rb b/spec/support/shared_examples/personal_repositories_controller.rb index 6b371e534..43b5e2d36 100644 --- a/spec/support/shared_examples/personal_repositories_controller.rb +++ b/spec/support/shared_examples/personal_repositories_controller.rb @@ -1,60 +1,58 @@ -shared_examples_for 'be_able_to_perform_show#personal_repositories' do +shared_examples_for 'show personal repository' do it 'should be able to perform show action' do get :show, :id => @repository.id response.should render_template(:show) end end -shared_examples_for 'be_able_to_perform_add_project#personal_repositories' do +shared_examples_for 'add project to personal repository' do it 'should be able to perform add_project action' do get :add_project, :id => @repository.id response.should render_template(:projects_list) end end -shared_examples_for 'be_able_to_perform_add_project#personal_repositories_with_project_id_param' do +shared_examples_for 'add project personal repository with project_id param' do it 'should be able to perform add_project action with project_id param' do get :add_project, :id => @repository.id, :project_id => @project.id response.should redirect_to(personal_repository_path(@repository)) end end -shared_examples_for 'be_able_to_perform_remove_project#personal_repositories' do +shared_examples_for 'remove project from personal repository' do it 'should be able to perform remove_project action' do get :remove_project, :id => @repository.id, :project_id => @project.id response.should redirect_to(personal_repository_path(@repository)) end end -shared_examples_for 'be_able_to_perform_destroy#personal_repositories' do +shared_examples_for 'destroy personal repository' do it 'should be able to perform destroy action' do delete :destroy, :id => @repository.id response.should redirect_to(platform_path(@repository.platform.id)) end end -shared_examples_for 'not_be_able_to_destroy_personal_repository' do +shared_examples_for 'not destroy personal repository' do it 'should not be able to destroy personal repository' do delete :destroy, :id => @personal_repository.id response.should redirect_to(forbidden_path) end end -shared_examples_for 'be_able_to_perform_settings#personal_repositories' do +shared_examples_for 'settings personal repository' do it 'should be able to perform settings action' do get :settings, :id => @repository.id response.should render_template(:settings) end end -shared_examples_for 'be_able_to_perform_change_visibility' do +shared_examples_for 'change visibility' do it 'should be able to perform change_visibility action' do get :change_visibility, :id => @repository.id response.should redirect_to(settings_personal_repository_path(@repository)) end -end -shared_examples_for 'be_able_to_change_visibility' do it 'should change visibility of repository' do get :change_visibility, :id => @repository.id @repository.platform.reload.visibility.should == 'open' diff --git a/spec/support/shared_examples/repositories_controller.rb b/spec/support/shared_examples/repositories_controller.rb index 4e480173c..2f6865ea3 100644 --- a/spec/support/shared_examples/repositories_controller.rb +++ b/spec/support/shared_examples/repositories_controller.rb @@ -40,7 +40,7 @@ shared_examples_for 'be_able_to_perform_remove_project#repositories' do end end -shared_examples_for 'remove_project_from_repository' do +shared_examples_for 'remove project from repository' do it 'should be able to remove project from repository' do get :remove_project, :id => @repository.id, :project_id => @project.id !@repository.projects.exists? :id => @project.id