comparison test/unit/repository_subversion_test.rb @ 1526:404aa68d4227

Merge from live branch
author Chris Cannam
date Thu, 11 Sep 2014 12:46:20 +0100
parents dffacf8a6908
children
comparison
equal deleted inserted replaced
1493:a5f2bdf3b486 1526:404aa68d4227
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
18 require File.expand_path('../../test_helper', __FILE__) 18 require File.expand_path('../../test_helper', __FILE__)
19 19
20 class RepositorySubversionTest < ActiveSupport::TestCase 20 class RepositorySubversionTest < ActiveSupport::TestCase
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles
22 22
23 include Redmine::I18n
24
23 NUM_REV = 11 25 NUM_REV = 11
24 26
25 def setup 27 def setup
26 @project = Project.find(3) 28 @project = Project.find(3)
27 @repository = Repository::Subversion.create(:project => @project, 29 @repository = Repository::Subversion.create(:project => @project,
28 :url => self.class.subversion_repository_url) 30 :url => self.class.subversion_repository_url)
29 assert @repository 31 assert @repository
32 end
33
34 def test_invalid_url
35 set_language_if_valid 'en'
36 ['invalid', 'http://', 'svn://', 'svn+ssh://', 'file://'].each do |url|
37 repo = Repository::Subversion.new(
38 :project => @project,
39 :identifier => 'test',
40 :url => url
41 )
42 assert !repo.save
43 assert_equal ["is invalid"], repo.errors[:url]
44 end
45 end
46
47 def test_valid_url
48 ['http://valid', 'svn://valid', 'svn+ssh://valid', 'file://valid'].each do |url|
49 repo = Repository::Subversion.new(
50 :project => @project,
51 :identifier => 'test',
52 :url => url
53 )
54 assert repo.save
55 assert_equal [], repo.errors[:url]
56 assert repo.destroy
57 end
30 end 58 end
31 59
32 if repository_configured?('subversion') 60 if repository_configured?('subversion')
33 def test_fetch_changesets_from_scratch 61 def test_fetch_changesets_from_scratch
34 assert_equal 0, @repository.changesets.count 62 assert_equal 0, @repository.changesets.count
45 @repository.fetch_changesets 73 @repository.fetch_changesets
46 @project.reload 74 @project.reload
47 assert_equal NUM_REV, @repository.changesets.count 75 assert_equal NUM_REV, @repository.changesets.count
48 76
49 # Remove changesets with revision > 5 77 # Remove changesets with revision > 5
50 @repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5} 78 @repository.changesets.each {|c| c.destroy if c.revision.to_i > 5}
51 @project.reload 79 @project.reload
80 @repository.reload
52 assert_equal 5, @repository.changesets.count 81 assert_equal 5, @repository.changesets.count
53 82
54 @repository.fetch_changesets 83 @repository.fetch_changesets
55 @project.reload 84 @project.reload
56 assert_equal NUM_REV, @repository.changesets.count 85 assert_equal NUM_REV, @repository.changesets.count