Remove REPOSITORY_PATH constants from repo specs

* Use more idiomatic RSpec `skip` for skipping examples.

Signed-off-by: Alex Coles <alex@alexbcoles.com>
pull/2786/head
Alex Coles 10 years ago
parent 6681aa3bf7
commit 75953e21aa
  1. 16
      test/functional/repositories_git_controller_test.rb
  2. 7
      test/functional/repositories_subversion_controller_test.rb
  3. 4
      test/support/legacy_assertions.rb
  4. 11
      test/unit/lib/redmine/scm/adapters/filesystem_adapter_test.rb
  5. 12
      test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
  6. 16
      test/unit/repository_git_test.rb
  7. 7
      test/unit/repository_subversion_test.rb

@ -38,17 +38,22 @@ describe RepositoriesController, 'Git', type: :controller do
fixtures :all
# No '..' in the repository path
REPOSITORY_PATH = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
REPOSITORY_PATH.gsub!(/\//, '\\') if Redmine::Platform.mswin?
let(:git_repository_path) {
path = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
path.gsub!(/\//, '\\') if Redmine::Platform.mswin?
path
}
before do
skip 'Git test repository NOT FOUND. Skipping functional tests !!!' unless File.directory?(git_repository_path)
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
User.current = nil
@repository = Repository::Git.create(
project: Project.find(3),
url: REPOSITORY_PATH,
url: git_repository_path,
path_encoding: 'ISO-8859-1'
)
@ -61,7 +66,6 @@ describe RepositoriesController, 'Git', type: :controller do
assert @repository
end
if File.directory?(REPOSITORY_PATH)
it 'should browse root' do
@repository.fetch_changesets
@repository.reload
@ -254,8 +258,4 @@ describe RepositoriesController, 'Git', type: :controller do
assert_error_tag content: /was not found/
end
end
else
puts 'Git test repository NOT FOUND. Skipping functional tests !!!'
it 'should fake' do; assert true end
end
end

@ -40,6 +40,8 @@ describe RepositoriesController, 'Subversion', type: :controller do
PRJ_ID = 3
before do
skip 'Subversion test repository NOT FOUND. Skipping functional tests !!!' unless repository_configured?('subversion')
@controller = RepositoriesController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@ -61,7 +63,6 @@ describe RepositoriesController, 'Subversion', type: :controller do
assert @repository
end
if repository_configured?('subversion')
it 'should show' do
@repository.fetch_changesets
@repository.reload
@ -308,8 +309,4 @@ describe RepositoriesController, 'Subversion', type: :controller do
assert_template 'annotate'
assert_tag tag: 'h2', content: /@ 8/
end
else
puts 'Subversion test repository NOT FOUND. Skipping functional tests !!!'
it 'should fake' do; assert true end
end
end

@ -234,6 +234,10 @@ module LegacyAssertionsAndHelpers
{ 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(login, password) }
end
def repository_configured?(vendor)
self.class.repository_configured?(vendor)
end
module ClassMethods
def ldap_configured?
@test_ldap = Net::LDAP.new(host: '127.0.0.1', port: 389)

@ -30,11 +30,12 @@
require File.expand_path('../../../../../../test_helper', __FILE__)
describe Redmine::Scm::Adapters::FilesystemAdapter, type: :model do
REPOSITORY_PATH = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository'
let(:fs_repository_path) { Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/filesystem_repository' }
if File.directory?(REPOSITORY_PATH)
before do
@adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(REPOSITORY_PATH)
skip 'Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS.' unless File.directory?(fs_repository_path)
@adapter = Redmine::Scm::Adapters::FilesystemAdapter.new(fs_repository_path)
end
it 'should entries' do
@ -58,8 +59,4 @@ describe Redmine::Scm::Adapters::FilesystemAdapter, type: :model do
# Revision number is ignored
assert_equal "TEST CAT\n", @adapter.cat('/test', 1)
end
else
puts 'Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS.'
it 'should fake' do; assert true end
end
end

@ -33,7 +33,7 @@
require File.expand_path('../../../../../../test_helper', __FILE__)
describe Redmine::Scm::Adapters::GitAdapter, type: :model do
REPOSITORY_PATH = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
let(:git_repository_path) { Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' }
FELIX_UTF8 = 'Felix Schäfer'
FELIX_HEX = "Felix Sch\xC3\xA4fer"
@ -45,10 +45,11 @@ describe Redmine::Scm::Adapters::GitAdapter, type: :model do
# WINDOWS_PASS = Redmine::Platform.mswin?
WINDOWS_PASS = false
if File.directory?(REPOSITORY_PATH)
before do
skip 'Git test repository NOT FOUND. Skipping unit tests !!!' unless File.directory?(git_repository_path)
@adapter = Redmine::Scm::Adapters::GitAdapter.new(
REPOSITORY_PATH,
git_repository_path,
nil,
nil,
nil,
@ -250,9 +251,4 @@ describe Redmine::Scm::Adapters::GitAdapter, type: :model do
@adapter.class.should_receive(:scm_version_from_command_line).and_return(scm_command_version)
assert_equal version, @adapter.class.scm_command_version
end
else
puts 'Git test repository NOT FOUND. Skipping unit tests !!!'
it 'should fake' do; assert true end
end
end

@ -32,8 +32,11 @@ describe Repository::Git, type: :model do
fixtures :all
# No '..' in the repository path
REPOSITORY_PATH = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
REPOSITORY_PATH.gsub!(/\//, '\\') if Redmine::Platform.mswin?
let(:git_repository_path) {
path = Rails.root.to_s.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
path.gsub!(/\//, '\\') if Redmine::Platform.mswin?
path
}
FELIX_HEX = "Felix Sch\xC3\xA4fer"
CHAR_1_HEX = "\xc3\x9c"
@ -45,10 +48,12 @@ describe Repository::Git, type: :model do
WINDOWS_PASS = false
before do
skip 'Git test repository NOT FOUND. Skipping unit tests !!!' unless File.directory?(git_repository_path)
@project = Project.find(3)
@repository = Repository::Git.create(
project: @project,
url: REPOSITORY_PATH,
url: git_repository_path,
path_encoding: 'ISO-8859-1'
)
assert @repository
@ -58,7 +63,6 @@ describe Repository::Git, type: :model do
end
end
if File.directory?(REPOSITORY_PATH)
it 'should fetch changesets from scratch' do
@repository.fetch_changesets
@repository.reload
@ -321,10 +325,6 @@ describe Repository::Git, type: :model do
assert_nil changeset.next
end
end
else
puts 'Git test repository NOT FOUND. Skipping unit tests !!!'
it 'should fake' do; assert true end
end
private

@ -32,13 +32,14 @@ describe Repository::Subversion, type: :model do
fixtures :all
before do
skip 'Subversion test repository NOT FOUND. Skipping unit tests !!!' unless repository_configured?('subversion')
@project = Project.find(3)
@repository = Repository::Subversion.create(project: @project,
url: self.class.subversion_repository_url)
assert @repository
end
if repository_configured?('subversion')
it 'should fetch changesets from scratch' do
@repository.fetch_changesets
@repository.reload
@ -199,10 +200,6 @@ describe Repository::Subversion, type: :model do
changeset = @repository.find_changeset_by_name('11')
assert_nil changeset.next
end
else
puts 'Subversion test repository NOT FOUND. Skipping unit tests !!!'
it 'should fake' do; assert true end
end
private

Loading…
Cancel
Save