diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-01-02 09:45:05 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2011-01-02 09:45:05 +0000 |
commit | 2e1bcb2abff6f78f028064299125480cbf3c2c2a (patch) | |
tree | 0e277b38e1f527d703466a2857c56953f12cf7ff /test | |
parent | 2ae2d3ef834c4d17b1c7a4e09f299b537f91d3cc (diff) | |
download | redmine-2e1bcb2abff6f78f028064299125480cbf3c2c2a.tar.gz redmine-2e1bcb2abff6f78f028064299125480cbf3c2c2a.zip |
Changing revision label and identifier at SCM adapter level (#3724, #6092)
Contributed by Yuya Nishihara.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4613 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/changeset_test.rb | 5 | ||||
-rw-r--r-- | test/unit/repository_bazaar_test.rb | 2 | ||||
-rw-r--r-- | test/unit/repository_git_test.rb | 28 | ||||
-rw-r--r-- | test/unit/repository_subversion_test.rb | 53 |
4 files changed, 85 insertions, 3 deletions
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb index 9265fe9c5..2f0415d3a 100644 --- a/test/unit/changeset_test.rb +++ b/test/unit/changeset_test.rb @@ -218,4 +218,9 @@ class ChangesetTest < ActiveSupport::TestCase c.comments = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt") assert_equal "Texte encod en ISO-8859-1.", c.comments end + + def test_identifier + c = Changeset.find_by_revision('1') + assert_equal c.revision, c.identifier + end end diff --git a/test/unit/repository_bazaar_test.rb b/test/unit/repository_bazaar_test.rb index bd1c9a9b4..5cd7da13c 100644 --- a/test/unit/repository_bazaar_test.rb +++ b/test/unit/repository_bazaar_test.rb @@ -77,7 +77,7 @@ class RepositoryBazaarTest < ActiveSupport::TestCase def test_annotate annotate = @repository.scm.annotate('doc-mkdir.txt') assert_equal 17, annotate.lines.size - assert_equal 1, annotate.revisions[0].identifier + assert_equal '1', annotate.revisions[0].identifier assert_equal 'jsmith@', annotate.revisions[0].author assert_equal 'mkdir', annotate.lines[0] end diff --git a/test/unit/repository_git_test.rb b/test/unit/repository_git_test.rb index acf4f174a..cec091760 100644 --- a/test/unit/repository_git_test.rb +++ b/test/unit/repository_git_test.rb @@ -18,7 +18,7 @@ require File.expand_path('../../test_helper', __FILE__) class RepositoryGitTest < ActiveSupport::TestCase - fixtures :projects + fixtures :projects, :repositories, :enabled_modules, :users, :roles # No '..' in the repository path REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' @@ -62,6 +62,32 @@ class RepositoryGitTest < ActiveSupport::TestCase @repository.fetch_changesets assert_equal 15, @repository.changesets.count end + + def test_identifier + @repository.fetch_changesets + @repository.reload + c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') + assert_equal c.scmid, c.identifier + end + + def test_format_identifier + @repository.fetch_changesets + @repository.reload + c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') + assert_equal c.format_identifier, '7234cb27' + end + + def test_activities + @repository.fetch_changesets + @repository.reload + f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) + f.scope = ['changesets'] + events = f.events + assert_kind_of Array, events + eve = events[-9] + assert eve.event_title.include?('7234cb27:') + assert_equal eve.event_url[:rev], '7234cb2750b63f47bff735edc50a1c0a433c2518' + end else puts "Git test repository NOT FOUND. Skipping unit tests !!!" def test_fake; assert true end diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb index 903cdd049..5034c30cf 100644 --- a/test/unit/repository_subversion_test.rb +++ b/test/unit/repository_subversion_test.rb @@ -18,7 +18,7 @@ require File.expand_path('../../test_helper', __FILE__) class RepositorySubversionTest < ActiveSupport::TestCase - fixtures :projects, :repositories + fixtures :projects, :repositories, :enabled_modules, :users, :roles def setup @project = Project.find(1) @@ -88,6 +88,57 @@ class RepositorySubversionTest < ActiveSupport::TestCase assert_equal 1, entries.size, 'Expect a single entry' assert_equal 'README.txt', entries.first.name end + + def test_identifier + @repository.fetch_changesets + @repository.reload + c = @repository.changesets.find_by_revision('1') + assert_equal c.revision, c.identifier + end + + def test_identifier_nine_digit + c = Changeset.new(:repository => @repository, :committed_on => Time.now, + :revision => '123456789', :comments => 'test') + assert_equal c.identifier, c.revision + end + + def test_format_identifier + @repository.fetch_changesets + @repository.reload + c = @repository.changesets.find_by_revision('1') + assert_equal c.format_identifier, c.revision + end + + def test_format_identifier_nine_digit + c = Changeset.new(:repository => @repository, :committed_on => Time.now, + :revision => '123456789', :comments => 'test') + assert_equal c.format_identifier, c.revision + end + + def test_activities + @repository.fetch_changesets + @repository.reload + f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) + f.scope = ['changesets'] + events = f.events + assert_kind_of Array, events + eve = events[-9] + assert eve.event_title.include?('1:') + assert_equal eve.event_url[:rev], '1' + end + + def test_activities_nine_digit + c = Changeset.new(:repository => @repository, :committed_on => Time.now, + :revision => '123456789', :comments => 'test') + assert( c.save ) + f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) + f.scope = ['changesets'] + events = f.events + assert_kind_of Array, events + eve = events[-11] + assert eve.event_title.include?('123456789:') + assert_equal eve.event_url[:rev], '123456789' + end else puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" def test_fake; assert true end |