Mercurial > hg > soundsoftware-site
diff test/unit/repository_git_test.rb @ 245:051f544170fe
* Update to SVN trunk revision 4993
author | Chris Cannam |
---|---|
date | Thu, 03 Mar 2011 11:42:28 +0000 |
parents | 8661b858af72 |
children | cbce1fd3b1b7 |
line wrap: on
line diff
--- a/test/unit/repository_git_test.rb Thu Mar 03 11:40:10 2011 +0000 +++ b/test/unit/repository_git_test.rb Thu Mar 03 11:42:28 2011 +0000 @@ -18,25 +18,29 @@ require File.expand_path('../../test_helper', __FILE__) class RepositoryGitTest < ActiveSupport::TestCase - fixtures :projects, :repositories, :enabled_modules, :users, :roles - + fixtures :projects, :repositories, :enabled_modules, :users, :roles + # No '..' in the repository path REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? - + + FELIX_HEX = "Felix Sch\xC3\xA4fer" + def setup - @project = Project.find(1) - assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH) + Setting.commit_logs_encoding = 'UTF-8' + @project = Project.find(3) + @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH) + assert @repository end - + if File.directory?(REPOSITORY_PATH) def test_fetch_changesets_from_scratch @repository.fetch_changesets @repository.reload - - assert_equal 15, @repository.changesets.count - assert_equal 24, @repository.changes.count - + + assert_equal 16, @repository.changesets.count + assert_equal 25, @repository.changes.count + commit = @repository.changesets.find(:first, :order => 'committed_on ASC') assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments assert_equal "jsmith <jsmith@foo.bar>", commit.committer @@ -57,10 +61,20 @@ # Remove the 3 latest changesets @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy) @repository.reload - assert_equal 12, @repository.changesets.count - + cs1 = @repository.changesets + assert_equal 13, cs1.count + + rev_a_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') + assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.revision + # Mon Jul 5 22:34:26 2010 +0200 + rev_a_committed_on = Time.gm(2010, 7, 5, 20, 34, 26) + assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.scmid + assert_equal rev_a_committed_on, rev_a_commit.committed_on + latest_rev = @repository.latest_changeset + assert_equal rev_a_committed_on, latest_rev.committed_on + @repository.fetch_changesets - assert_equal 15, @repository.changesets.count + assert_equal 16, @repository.changesets.count end def test_find_changeset_by_name @@ -103,6 +117,17 @@ assert c.event_title.include?('abc7234c:') assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] end + + def test_log_utf8 + @repository.fetch_changesets + @repository.reload + str_felix_hex = FELIX_HEX + if str_felix_hex.respond_to?(:force_encoding) + str_felix_hex.force_encoding('UTF-8') + end + c = @repository.changesets.find_by_revision('ed5bb786bbda2dee66a2d50faf51429dbc043a7b') + assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer + end else puts "Git test repository NOT FOUND. Skipping unit tests !!!" def test_fake; assert true end