##// END OF EJS Templates
Adds test helpers for test repositories....
Jean-Philippe Lang -
r3606:1be15816dd30
parent child
Show More
@@ -26,9 +26,6 class RepositoriesSubversionControllerTest < ActionController::TestCase
26 :repositories, :issues, :issue_statuses, :changesets, :changes,
26 :repositories, :issues, :issue_statuses, :changesets, :changes,
27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
27 :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
28
28
29 # No '..' in the repository path for svn
30 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
31
32 def setup
29 def setup
33 @controller = RepositoriesController.new
30 @controller = RepositoriesController.new
34 @request = ActionController::TestRequest.new
31 @request = ActionController::TestRequest.new
@@ -37,7 +34,7 class RepositoriesSubversionControllerTest < ActionController::TestCase
37 User.current = nil
34 User.current = nil
38 end
35 end
39
36
40 if File.directory?(REPOSITORY_PATH)
37 if repository_configured?('subversion')
41 def test_show
38 def test_show
42 get :show, :id => 1
39 get :show, :id => 1
43 assert_response :success
40 assert_response :success
@@ -84,6 +84,16 class ActiveSupport::TestCase
84 return nil
84 return nil
85 end
85 end
86
86
87 # Returns the path to the test +vendor+ repository
88 def self.repository_path(vendor)
89 File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
90 end
91
92 # Returns true if the +vendor+ test repository is configured
93 def self.repository_configured?(vendor)
94 File.directory?(repository_path(vendor))
95 end
96
87 # Shoulda macros
97 # Shoulda macros
88 def self.should_render_404
98 def self.should_render_404
89 should_respond_with :not_found
99 should_respond_with :not_found
@@ -15,19 +15,17
15 # along with this program; if not, write to the Free Software
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require 'mkmf'
19
20 require File.dirname(__FILE__) + '/../../../../../test_helper'
18 require File.dirname(__FILE__) + '/../../../../../test_helper'
21
19
22 class SubversionAdapterTest < ActiveSupport::TestCase
20 class SubversionAdapterTest < ActiveSupport::TestCase
23
21
24 if find_executable0('svn')
22 if repository_configured?('subversion')
25 def test_client_version
23 def test_client_version
26 v = Redmine::Scm::Adapters::SubversionAdapter.client_version
24 v = Redmine::Scm::Adapters::SubversionAdapter.client_version
27 assert v.is_a?(Array)
25 assert v.is_a?(Array)
28 end
26 end
29 else
27 else
30 puts "Subversion binary NOT FOUND. Skipping unit tests !!!"
28 puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
31 def test_fake; assert true end
29 def test_fake; assert true end
32 end
30 end
33 end
31 end
@@ -20,15 +20,12 require File.dirname(__FILE__) + '/../test_helper'
20 class RepositorySubversionTest < ActiveSupport::TestCase
20 class RepositorySubversionTest < ActiveSupport::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path for svn
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
25
26 def setup
23 def setup
27 @project = Project.find(1)
24 @project = Project.find(1)
28 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}")
25 assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{self.class.repository_path('subversion')}")
29 end
26 end
30
27
31 if File.directory?(REPOSITORY_PATH)
28 if repository_configured?('subversion')
32 def test_fetch_changesets_from_scratch
29 def test_fetch_changesets_from_scratch
33 @repository.fetch_changesets
30 @repository.fetch_changesets
34 @repository.reload
31 @repository.reload
General Comments 0
You need to be logged in to leave comments. Login now