Mercurial > hg > soundsoftware-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
244:8972b600f4fb | 245:051f544170fe |
---|---|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.expand_path('../../test_helper', __FILE__) | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class RepositoryGitTest < ActiveSupport::TestCase | 20 class RepositoryGitTest < ActiveSupport::TestCase |
21 fixtures :projects, :repositories, :enabled_modules, :users, :roles | 21 fixtures :projects, :repositories, :enabled_modules, :users, :roles |
22 | 22 |
23 # No '..' in the repository path | 23 # No '..' in the repository path |
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' | 24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository' |
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | 25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
26 | 26 |
27 FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
28 | |
27 def setup | 29 def setup |
28 @project = Project.find(1) | 30 Setting.commit_logs_encoding = 'UTF-8' |
29 assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH) | 31 @project = Project.find(3) |
32 @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH) | |
33 assert @repository | |
30 end | 34 end |
31 | 35 |
32 if File.directory?(REPOSITORY_PATH) | 36 if File.directory?(REPOSITORY_PATH) |
33 def test_fetch_changesets_from_scratch | 37 def test_fetch_changesets_from_scratch |
34 @repository.fetch_changesets | 38 @repository.fetch_changesets |
35 @repository.reload | 39 @repository.reload |
36 | 40 |
37 assert_equal 15, @repository.changesets.count | 41 assert_equal 16, @repository.changesets.count |
38 assert_equal 24, @repository.changes.count | 42 assert_equal 25, @repository.changes.count |
39 | 43 |
40 commit = @repository.changesets.find(:first, :order => 'committed_on ASC') | 44 commit = @repository.changesets.find(:first, :order => 'committed_on ASC') |
41 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments | 45 assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
42 assert_equal "jsmith <jsmith@foo.bar>", commit.committer | 46 assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
43 assert_equal User.find_by_login('jsmith'), commit.user | 47 assert_equal User.find_by_login('jsmith'), commit.user |
44 # TODO: add a commit with commit time <> author time to the test repository | 48 # TODO: add a commit with commit time <> author time to the test repository |
55 def test_fetch_changesets_incremental | 59 def test_fetch_changesets_incremental |
56 @repository.fetch_changesets | 60 @repository.fetch_changesets |
57 # Remove the 3 latest changesets | 61 # Remove the 3 latest changesets |
58 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy) | 62 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy) |
59 @repository.reload | 63 @repository.reload |
60 assert_equal 12, @repository.changesets.count | 64 cs1 = @repository.changesets |
61 | 65 assert_equal 13, cs1.count |
66 | |
67 rev_a_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') | |
68 assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.revision | |
69 # Mon Jul 5 22:34:26 2010 +0200 | |
70 rev_a_committed_on = Time.gm(2010, 7, 5, 20, 34, 26) | |
71 assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.scmid | |
72 assert_equal rev_a_committed_on, rev_a_commit.committed_on | |
73 latest_rev = @repository.latest_changeset | |
74 assert_equal rev_a_committed_on, latest_rev.committed_on | |
75 | |
62 @repository.fetch_changesets | 76 @repository.fetch_changesets |
63 assert_equal 15, @repository.changesets.count | 77 assert_equal 16, @repository.changesets.count |
64 end | 78 end |
65 | 79 |
66 def test_find_changeset_by_name | 80 def test_find_changeset_by_name |
67 @repository.fetch_changesets | 81 @repository.fetch_changesets |
68 @repository.reload | 82 @repository.reload |
101 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | 115 :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
102 :comments => 'test') | 116 :comments => 'test') |
103 assert c.event_title.include?('abc7234c:') | 117 assert c.event_title.include?('abc7234c:') |
104 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] | 118 assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] |
105 end | 119 end |
120 | |
121 def test_log_utf8 | |
122 @repository.fetch_changesets | |
123 @repository.reload | |
124 str_felix_hex = FELIX_HEX | |
125 if str_felix_hex.respond_to?(:force_encoding) | |
126 str_felix_hex.force_encoding('UTF-8') | |
127 end | |
128 c = @repository.changesets.find_by_revision('ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |
129 assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer | |
130 end | |
106 else | 131 else |
107 puts "Git test repository NOT FOUND. Skipping unit tests !!!" | 132 puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
108 def test_fake; assert true end | 133 def test_fake; assert true end |
109 end | 134 end |
110 end | 135 end |