Adds test helpers for test repositories.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3720 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
80f7faf10a
commit
1be15816dd
|
@ -26,9 +26,6 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
|
||||||
:repositories, :issues, :issue_statuses, :changesets, :changes,
|
:repositories, :issues, :issue_statuses, :changesets, :changes,
|
||||||
:issue_categories, :enumerations, :custom_fields, :custom_values, :trackers
|
: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
|
def setup
|
||||||
@controller = RepositoriesController.new
|
@controller = RepositoriesController.new
|
||||||
@request = ActionController::TestRequest.new
|
@request = ActionController::TestRequest.new
|
||||||
|
@ -37,7 +34,7 @@ class RepositoriesSubversionControllerTest < ActionController::TestCase
|
||||||
User.current = nil
|
User.current = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.directory?(REPOSITORY_PATH)
|
if repository_configured?('subversion')
|
||||||
def test_show
|
def test_show
|
||||||
get :show, :id => 1
|
get :show, :id => 1
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|
|
@ -84,6 +84,16 @@ class ActiveSupport::TestCase
|
||||||
return nil
|
return nil
|
||||||
end
|
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
|
# Shoulda macros
|
||||||
def self.should_render_404
|
def self.should_render_404
|
||||||
should_respond_with :not_found
|
should_respond_with :not_found
|
||||||
|
|
|
@ -15,19 +15,17 @@
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
require 'mkmf'
|
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../../../../../test_helper'
|
require File.dirname(__FILE__) + '/../../../../../test_helper'
|
||||||
|
|
||||||
class SubversionAdapterTest < ActiveSupport::TestCase
|
class SubversionAdapterTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
if find_executable0('svn')
|
if repository_configured?('subversion')
|
||||||
def test_client_version
|
def test_client_version
|
||||||
v = Redmine::Scm::Adapters::SubversionAdapter.client_version
|
v = Redmine::Scm::Adapters::SubversionAdapter.client_version
|
||||||
assert v.is_a?(Array)
|
assert v.is_a?(Array)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Subversion binary NOT FOUND. Skipping unit tests !!!"
|
puts "Subversion test repository NOT FOUND. Skipping unit tests !!!"
|
||||||
def test_fake; assert true end
|
def test_fake; assert true end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,15 +20,12 @@ require File.dirname(__FILE__) + '/../test_helper'
|
||||||
class RepositorySubversionTest < ActiveSupport::TestCase
|
class RepositorySubversionTest < ActiveSupport::TestCase
|
||||||
fixtures :projects
|
fixtures :projects
|
||||||
|
|
||||||
# No '..' in the repository path for svn
|
|
||||||
REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository'
|
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@project = Project.find(1)
|
@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
|
end
|
||||||
|
|
||||||
if File.directory?(REPOSITORY_PATH)
|
if repository_configured?('subversion')
|
||||||
def test_fetch_changesets_from_scratch
|
def test_fetch_changesets_from_scratch
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
@repository.reload
|
@repository.reload
|
||||||
|
|
Loading…
Reference in New Issue