From 1be15816dd30d10339a0dcf2faf44da31fc3e8e5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 1 May 2010 08:32:21 +0000 Subject: [PATCH] Adds test helpers for test repositories. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3720 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../repositories_subversion_controller_test.rb | 5 +---- test/test_helper.rb | 10 ++++++++++ .../redmine/scm/adapters/subversion_adapter_test.rb | 6 ++---- test/unit/repository_subversion_test.rb | 7 ++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/test/functional/repositories_subversion_controller_test.rb b/test/functional/repositories_subversion_controller_test.rb index f07c7ea1a..d28646d44 100644 --- a/test/functional/repositories_subversion_controller_test.rb +++ b/test/functional/repositories_subversion_controller_test.rb @@ -26,9 +26,6 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers - # No '..' in the repository path for svn - REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' - def setup @controller = RepositoriesController.new @request = ActionController::TestRequest.new @@ -37,7 +34,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase User.current = nil end - if File.directory?(REPOSITORY_PATH) + if repository_configured?('subversion') def test_show get :show, :id => 1 assert_response :success diff --git a/test/test_helper.rb b/test/test_helper.rb index 48e2c999a..cb043fa89 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -83,6 +83,16 @@ class ActiveSupport::TestCase # LDAP is not listening return nil end + + # Returns the path to the test +vendor+ repository + def self.repository_path(vendor) + File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository") + end + + # Returns true if the +vendor+ test repository is configured + def self.repository_configured?(vendor) + File.directory?(repository_path(vendor)) + end # Shoulda macros def self.should_render_404 diff --git a/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb b/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb index e44d12f2d..4fc56cbc3 100644 --- a/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb +++ b/test/unit/lib/redmine/scm/adapters/subversion_adapter_test.rb @@ -15,19 +15,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -require 'mkmf' - require File.dirname(__FILE__) + '/../../../../../test_helper' class SubversionAdapterTest < ActiveSupport::TestCase - if find_executable0('svn') + if repository_configured?('subversion') def test_client_version v = Redmine::Scm::Adapters::SubversionAdapter.client_version assert v.is_a?(Array) end else - puts "Subversion binary NOT FOUND. Skipping unit tests !!!" + puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" def test_fake; assert true end end end diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb index fb5580c42..a2394facd 100644 --- a/test/unit/repository_subversion_test.rb +++ b/test/unit/repository_subversion_test.rb @@ -20,15 +20,12 @@ require File.dirname(__FILE__) + '/../test_helper' class RepositorySubversionTest < ActiveSupport::TestCase fixtures :projects - # No '..' in the repository path for svn - REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' - def setup @project = Project.find(1) - assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") + assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}") end - if File.directory?(REPOSITORY_PATH) + if repository_configured?('subversion') def test_fetch_changesets_from_scratch @repository.fetch_changesets @repository.reload