From 1306a26884affc13d01ab7e985475553179653e9 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Tue, 18 Dec 2012 21:59:18 +0600 Subject: [PATCH] [refs #777] fixed git trees specs --- .../projects/git/git_trees_controller_spec.rb | 14 ++++++-------- spec/spec_helper.rb | 13 ++++++++++--- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/spec/controllers/projects/git/git_trees_controller_spec.rb b/spec/controllers/projects/git/git_trees_controller_spec.rb index 5bf420e11..9ac75106f 100644 --- a/spec/controllers/projects/git/git_trees_controller_spec.rb +++ b/spec/controllers/projects/git/git_trees_controller_spec.rb @@ -3,10 +3,6 @@ require 'spec_helper' describe Projects::Git::TreesController do - def fill_project - %x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.repo.path}) # maybe FIXME ? - end - before(:each) do stub_symlink_methods @@ -23,7 +19,7 @@ describe Projects::Git::TreesController do get :archive, @params.merge(:format => 'tar.gz') response.should be_success end - + it 'should not be able to perform archive action without anonymous acccess', :anonymous_access => false do fill_project get :archive, @params.merge(:format => 'tar.gz') @@ -39,25 +35,27 @@ describe Projects::Git::TreesController do end it 'should not be able to injection code with format' do + fill_project @user = FactoryGirl.create(:user) set_session_for(@user) - fill_project expect { get :archive, @params.merge(:format => "tar.gz master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActionController::RoutingError) end it 'should not be able to injection code with treeish' do + fill_project @user = FactoryGirl.create(:user) set_session_for(@user) - fill_project expect { get :archive, @params.merge(:treeish => "master > /dev/null; echo 'I am hacker!';\#") }.to raise_error(ActionController::RoutingError) end it 'should be able to perform archive action' do + fill_project @user = FactoryGirl.create(:user) set_session_for(@user) - fill_project get :archive, @params.merge(:format => 'tar.gz') response.should be_success end end + + after(:all) {clean_projects_dir} end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e168084b3..8cd5c474f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -60,6 +60,13 @@ end Resque.inline = true # 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" +%x(rm -Rf #{APP_CONFIG['git_path']}) +%x(mkdir -p #{APP_CONFIG['git_path']}) + +def fill_project + %x(cp -Rf #{Rails.root}/spec/tests.git/* #{@project.path}) # maybe FIXME ? +end + +def clean_projects_dir + FileUtils.rm_rf "#{APP_CONFIG['git_path']}" +end