@@ -1,315 +1,315 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 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. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
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" |
|
27 | FELIX_HEX = "Felix Sch\xC3\xA4fer" | |
28 | CHAR_1_HEX = "\xc3\x9c" |
|
28 | CHAR_1_HEX = "\xc3\x9c" | |
29 |
|
29 | |||
30 | ## Ruby uses ANSI api to fork a process on Windows. |
|
30 | ## Ruby uses ANSI api to fork a process on Windows. | |
31 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem |
|
31 | ## Japanese Shift_JIS and Traditional Chinese Big5 have 0x5c(backslash) problem | |
32 | ## and these are incompatible with ASCII. |
|
32 | ## and these are incompatible with ASCII. | |
33 | # WINDOWS_PASS = Redmine::Platform.mswin? |
|
33 | # WINDOWS_PASS = Redmine::Platform.mswin? | |
34 | WINDOWS_PASS = false |
|
34 | WINDOWS_PASS = false | |
35 |
|
35 | |||
36 | def setup |
|
36 | def setup | |
37 | @project = Project.find(3) |
|
37 | @project = Project.find(3) | |
38 | @repository = Repository::Git.create( |
|
38 | @repository = Repository::Git.create( | |
39 | :project => @project, |
|
39 | :project => @project, | |
40 | :url => REPOSITORY_PATH, |
|
40 | :url => REPOSITORY_PATH, | |
41 | :path_encoding => 'ISO-8859-1' |
|
41 | :path_encoding => 'ISO-8859-1' | |
42 | ) |
|
42 | ) | |
43 | assert @repository |
|
43 | assert @repository | |
44 | @char_1 = CHAR_1_HEX.dup |
|
44 | @char_1 = CHAR_1_HEX.dup | |
45 | if @char_1.respond_to?(:force_encoding) |
|
45 | if @char_1.respond_to?(:force_encoding) | |
46 | @char_1.force_encoding('UTF-8') |
|
46 | @char_1.force_encoding('UTF-8') | |
47 | end |
|
47 | end | |
48 | end |
|
48 | end | |
49 |
|
49 | |||
50 | if File.directory?(REPOSITORY_PATH) |
|
50 | if File.directory?(REPOSITORY_PATH) | |
51 | def test_fetch_changesets_from_scratch |
|
51 | def test_fetch_changesets_from_scratch | |
52 | @repository.fetch_changesets |
|
52 | @repository.fetch_changesets | |
53 | @repository.reload |
|
53 | @repository.reload | |
54 |
|
54 | |||
55 | assert_equal 21, @repository.changesets.count |
|
55 | assert_equal 21, @repository.changesets.count | |
56 | assert_equal 33, @repository.changes.count |
|
56 | assert_equal 33, @repository.changes.count | |
57 |
|
57 | |||
58 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') |
|
58 | commit = @repository.changesets.find(:first, :order => 'committed_on ASC') | |
59 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments |
|
59 | assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments | |
60 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer |
|
60 | assert_equal "jsmith <jsmith@foo.bar>", commit.committer | |
61 | assert_equal User.find_by_login('jsmith'), commit.user |
|
61 | assert_equal User.find_by_login('jsmith'), commit.user | |
62 | # TODO: add a commit with commit time <> author time to the test repository |
|
62 | # TODO: add a commit with commit time <> author time to the test repository | |
63 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on |
|
63 | assert_equal "2007-12-14 09:22:52".to_time, commit.committed_on | |
64 | assert_equal "2007-12-14".to_date, commit.commit_date |
|
64 | assert_equal "2007-12-14".to_date, commit.commit_date | |
65 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision |
|
65 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.revision | |
66 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid |
|
66 | assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518", commit.scmid | |
67 | assert_equal 3, commit.changes.count |
|
67 | assert_equal 3, commit.changes.count | |
68 | change = commit.changes.sort_by(&:path).first |
|
68 | change = commit.changes.sort_by(&:path).first | |
69 | assert_equal "README", change.path |
|
69 | assert_equal "README", change.path | |
70 | assert_equal "A", change.action |
|
70 | assert_equal "A", change.action | |
71 | end |
|
71 | end | |
72 |
|
72 | |||
73 | def test_fetch_changesets_incremental |
|
73 | def test_fetch_changesets_incremental | |
74 | @repository.fetch_changesets |
|
74 | @repository.fetch_changesets | |
75 | # Remove the 3 latest changesets |
|
75 | # Remove the 3 latest changesets | |
76 | @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 8).each(&:destroy) |
|
76 | @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 8).each(&:destroy) | |
77 | @repository.reload |
|
77 | @repository.reload | |
78 | cs1 = @repository.changesets |
|
78 | cs1 = @repository.changesets | |
79 | assert_equal 13, cs1.count |
|
79 | assert_equal 13, cs1.count | |
80 |
|
80 | |||
81 | rev_a_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') |
|
81 | rev_a_commit = @repository.changesets.find(:first, :order => 'committed_on DESC') | |
82 | assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.revision |
|
82 | assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.revision | |
83 | # Mon Jul 5 22:34:26 2010 +0200 |
|
83 | # Mon Jul 5 22:34:26 2010 +0200 | |
84 | rev_a_committed_on = Time.gm(2010, 7, 5, 20, 34, 26) |
|
84 | rev_a_committed_on = Time.gm(2010, 7, 5, 20, 34, 26) | |
85 | assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.scmid |
|
85 | assert_equal '4f26664364207fa8b1af9f8722647ab2d4ac5d43', rev_a_commit.scmid | |
86 | assert_equal rev_a_committed_on, rev_a_commit.committed_on |
|
86 | assert_equal rev_a_committed_on, rev_a_commit.committed_on | |
87 | latest_rev = @repository.latest_changeset |
|
87 | latest_rev = @repository.latest_changeset | |
88 | assert_equal rev_a_committed_on, latest_rev.committed_on |
|
88 | assert_equal rev_a_committed_on, latest_rev.committed_on | |
89 |
|
89 | |||
90 | @repository.fetch_changesets |
|
90 | @repository.fetch_changesets | |
91 | assert_equal 21, @repository.changesets.count |
|
91 | assert_equal 21, @repository.changesets.count | |
92 | end |
|
92 | end | |
93 |
|
93 | |||
94 | def test_latest_changesets |
|
94 | def test_latest_changesets | |
95 | @repository.fetch_changesets |
|
95 | @repository.fetch_changesets | |
96 | @repository.reload |
|
96 | @repository.reload | |
97 | # with limit |
|
97 | # with limit | |
98 | changesets = @repository.latest_changesets('', nil, 2) |
|
98 | changesets = @repository.latest_changesets('', nil, 2) | |
99 | assert_equal 2, changesets.size |
|
99 | assert_equal 2, changesets.size | |
100 |
|
100 | |||
101 | # with path |
|
101 | # with path | |
102 | changesets = @repository.latest_changesets('images', nil) |
|
102 | changesets = @repository.latest_changesets('images', nil) | |
103 | assert_equal [ |
|
103 | assert_equal [ | |
104 | 'deff712f05a90d96edbd70facc47d944be5897e3', |
|
104 | 'deff712f05a90d96edbd70facc47d944be5897e3', | |
105 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
105 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
106 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
106 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
107 | ], changesets.collect(&:revision) |
|
107 | ], changesets.collect(&:revision) | |
108 |
|
108 | |||
109 | changesets = @repository.latest_changesets('README', nil) |
|
109 | changesets = @repository.latest_changesets('README', nil) | |
110 | assert_equal [ |
|
110 | assert_equal [ | |
111 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', |
|
111 | '32ae898b720c2f7eec2723d5bdd558b4cb2d3ddf', | |
112 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', |
|
112 | '4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8', | |
113 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
113 | '713f4944648826f558cf548222f813dabe7cbb04', | |
114 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
114 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
115 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
115 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
116 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
116 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
117 | ], changesets.collect(&:revision) |
|
117 | ], changesets.collect(&:revision) | |
118 |
|
118 | |||
119 | # with path, revision and limit |
|
119 | # with path, revision and limit | |
120 | changesets = @repository.latest_changesets('images', '899a15dba') |
|
120 | changesets = @repository.latest_changesets('images', '899a15dba') | |
121 | assert_equal [ |
|
121 | assert_equal [ | |
122 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
122 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
123 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
123 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
124 | ], changesets.collect(&:revision) |
|
124 | ], changesets.collect(&:revision) | |
125 |
|
125 | |||
126 | changesets = @repository.latest_changesets('images', '899a15dba', 1) |
|
126 | changesets = @repository.latest_changesets('images', '899a15dba', 1) | |
127 | assert_equal [ |
|
127 | assert_equal [ | |
128 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
128 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
129 | ], changesets.collect(&:revision) |
|
129 | ], changesets.collect(&:revision) | |
130 |
|
130 | |||
131 | changesets = @repository.latest_changesets('README', '899a15dba') |
|
131 | changesets = @repository.latest_changesets('README', '899a15dba') | |
132 | assert_equal [ |
|
132 | assert_equal [ | |
133 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
133 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
134 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
134 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
135 | ], changesets.collect(&:revision) |
|
135 | ], changesets.collect(&:revision) | |
136 |
|
136 | |||
137 | changesets = @repository.latest_changesets('README', '899a15dba', 1) |
|
137 | changesets = @repository.latest_changesets('README', '899a15dba', 1) | |
138 | assert_equal [ |
|
138 | assert_equal [ | |
139 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
139 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
140 | ], changesets.collect(&:revision) |
|
140 | ], changesets.collect(&:revision) | |
141 |
|
141 | |||
142 | # with path, tag and limit |
|
142 | # with path, tag and limit | |
143 | changesets = @repository.latest_changesets('images', 'tag01.annotated') |
|
143 | changesets = @repository.latest_changesets('images', 'tag01.annotated') | |
144 | assert_equal [ |
|
144 | assert_equal [ | |
145 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
145 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
146 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
146 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
147 | ], changesets.collect(&:revision) |
|
147 | ], changesets.collect(&:revision) | |
148 |
|
148 | |||
149 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) |
|
149 | changesets = @repository.latest_changesets('images', 'tag01.annotated', 1) | |
150 | assert_equal [ |
|
150 | assert_equal [ | |
151 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
151 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
152 | ], changesets.collect(&:revision) |
|
152 | ], changesets.collect(&:revision) | |
153 |
|
153 | |||
154 | changesets = @repository.latest_changesets('README', 'tag01.annotated') |
|
154 | changesets = @repository.latest_changesets('README', 'tag01.annotated') | |
155 | assert_equal [ |
|
155 | assert_equal [ | |
156 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
156 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
157 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
157 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
158 | ], changesets.collect(&:revision) |
|
158 | ], changesets.collect(&:revision) | |
159 |
|
159 | |||
160 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) |
|
160 | changesets = @repository.latest_changesets('README', 'tag01.annotated', 1) | |
161 | assert_equal [ |
|
161 | assert_equal [ | |
162 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
162 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
163 | ], changesets.collect(&:revision) |
|
163 | ], changesets.collect(&:revision) | |
164 |
|
164 | |||
165 | # with path, branch and limit |
|
165 | # with path, branch and limit | |
166 | changesets = @repository.latest_changesets('images', 'test_branch') |
|
166 | changesets = @repository.latest_changesets('images', 'test_branch') | |
167 | assert_equal [ |
|
167 | assert_equal [ | |
168 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
168 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
169 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
169 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
170 | ], changesets.collect(&:revision) |
|
170 | ], changesets.collect(&:revision) | |
171 |
|
171 | |||
172 | changesets = @repository.latest_changesets('images', 'test_branch', 1) |
|
172 | changesets = @repository.latest_changesets('images', 'test_branch', 1) | |
173 | assert_equal [ |
|
173 | assert_equal [ | |
174 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
174 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
175 | ], changesets.collect(&:revision) |
|
175 | ], changesets.collect(&:revision) | |
176 |
|
176 | |||
177 | changesets = @repository.latest_changesets('README', 'test_branch') |
|
177 | changesets = @repository.latest_changesets('README', 'test_branch') | |
178 | assert_equal [ |
|
178 | assert_equal [ | |
179 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
179 | '713f4944648826f558cf548222f813dabe7cbb04', | |
180 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
180 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
181 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', |
|
181 | '899a15dba03a3b350b89c3f537e4bbe02a03cdc9', | |
182 | '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
182 | '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
183 | ], changesets.collect(&:revision) |
|
183 | ], changesets.collect(&:revision) | |
184 |
|
184 | |||
185 | changesets = @repository.latest_changesets('README', 'test_branch', 2) |
|
185 | changesets = @repository.latest_changesets('README', 'test_branch', 2) | |
186 | assert_equal [ |
|
186 | assert_equal [ | |
187 | '713f4944648826f558cf548222f813dabe7cbb04', |
|
187 | '713f4944648826f558cf548222f813dabe7cbb04', | |
188 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', |
|
188 | '61b685fbe55ab05b5ac68402d5720c1a6ac973d1', | |
189 | ], changesets.collect(&:revision) |
|
189 | ], changesets.collect(&:revision) | |
190 |
|
190 | |||
191 | # latin-1 encoding path |
|
191 | # latin-1 encoding path | |
192 | changesets = @repository.latest_changesets( |
|
192 | changesets = @repository.latest_changesets( | |
193 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') |
|
193 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89') | |
194 | assert_equal [ |
|
194 | assert_equal [ | |
195 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
195 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
196 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', |
|
196 | '4fc55c43bf3d3dc2efb66145365ddc17639ce81e', | |
197 | ], changesets.collect(&:revision) |
|
197 | ], changesets.collect(&:revision) | |
198 |
|
198 | |||
199 | changesets = @repository.latest_changesets( |
|
199 | changesets = @repository.latest_changesets( | |
200 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) |
|
200 | "latin-1-dir/test-#{@char_1}-2.txt", '64f1f3e89', 1) | |
201 | assert_equal [ |
|
201 | assert_equal [ | |
202 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', |
|
202 | '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', | |
203 | ], changesets.collect(&:revision) |
|
203 | ], changesets.collect(&:revision) | |
204 | end |
|
204 | end | |
205 |
|
205 | |||
206 | def test_latest_changesets_latin_1_dir |
|
206 | def test_latest_changesets_latin_1_dir | |
207 | if WINDOWS_PASS |
|
207 | if WINDOWS_PASS | |
208 | # |
|
208 | # | |
209 | else |
|
209 | else | |
210 | @repository.fetch_changesets |
|
210 | @repository.fetch_changesets | |
211 | @repository.reload |
|
211 | @repository.reload | |
212 | changesets = @repository.latest_changesets( |
|
212 | changesets = @repository.latest_changesets( | |
213 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') |
|
213 | "latin-1-dir/test-#{@char_1}-subdir", '1ca7f5ed') | |
214 | assert_equal [ |
|
214 | assert_equal [ | |
215 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', |
|
215 | '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', | |
216 | ], changesets.collect(&:revision) |
|
216 | ], changesets.collect(&:revision) | |
217 | end |
|
217 | end | |
218 | end |
|
218 | end | |
219 |
|
219 | |||
220 | def test_find_changeset_by_name |
|
220 | def test_find_changeset_by_name | |
221 | @repository.fetch_changesets |
|
221 | @repository.fetch_changesets | |
222 | @repository.reload |
|
222 | @repository.reload | |
223 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| |
|
223 | ['7234cb2750b63f47bff735edc50a1c0a433c2518', '7234cb2750b'].each do |r| | |
224 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', |
|
224 | assert_equal '7234cb2750b63f47bff735edc50a1c0a433c2518', | |
225 | @repository.find_changeset_by_name(r).revision |
|
225 | @repository.find_changeset_by_name(r).revision | |
226 | end |
|
226 | end | |
227 | end |
|
227 | end | |
228 |
|
228 | |||
229 | def test_find_changeset_by_empty_name |
|
229 | def test_find_changeset_by_empty_name | |
230 | @repository.fetch_changesets |
|
230 | @repository.fetch_changesets | |
231 | @repository.reload |
|
231 | @repository.reload | |
232 | ['', ' ', nil].each do |r| |
|
232 | ['', ' ', nil].each do |r| | |
233 | assert_nil @repository.find_changeset_by_name(r) |
|
233 | assert_nil @repository.find_changeset_by_name(r) | |
234 | end |
|
234 | end | |
235 | end |
|
235 | end | |
236 |
|
236 | |||
237 | def test_identifier |
|
237 | def test_identifier | |
238 | @repository.fetch_changesets |
|
238 | @repository.fetch_changesets | |
239 | @repository.reload |
|
239 | @repository.reload | |
240 | c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
240 | c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') | |
241 | assert_equal c.scmid, c.identifier |
|
241 | assert_equal c.scmid, c.identifier | |
242 | end |
|
242 | end | |
243 |
|
243 | |||
244 | def test_format_identifier |
|
244 | def test_format_identifier | |
245 | @repository.fetch_changesets |
|
245 | @repository.fetch_changesets | |
246 | @repository.reload |
|
246 | @repository.reload | |
247 | c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') |
|
247 | c = @repository.changesets.find_by_revision('7234cb2750b63f47bff735edc50a1c0a433c2518') | |
248 | assert_equal '7234cb27', c.format_identifier |
|
248 | assert_equal '7234cb27', c.format_identifier | |
249 | end |
|
249 | end | |
250 |
|
250 | |||
251 | def test_activities |
|
251 | def test_activities | |
252 | c = Changeset.new(:repository => @repository, |
|
252 | c = Changeset.new(:repository => @repository, | |
253 | :committed_on => Time.now, |
|
253 | :committed_on => Time.now, | |
254 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
254 | :revision => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
255 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', |
|
255 | :scmid => 'abc7234cb2750b63f47bff735edc50a1c0a433c2', | |
256 | :comments => 'test') |
|
256 | :comments => 'test') | |
257 | assert c.event_title.include?('abc7234c:') |
|
257 | assert c.event_title.include?('abc7234c:') | |
258 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] |
|
258 | assert_equal 'abc7234cb2750b63f47bff735edc50a1c0a433c2', c.event_url[:rev] | |
259 | end |
|
259 | end | |
260 |
|
260 | |||
261 | def test_log_utf8 |
|
261 | def test_log_utf8 | |
262 | @repository.fetch_changesets |
|
262 | @repository.fetch_changesets | |
263 | @repository.reload |
|
263 | @repository.reload | |
264 | str_felix_hex = FELIX_HEX |
|
264 | str_felix_hex = FELIX_HEX | |
265 | if str_felix_hex.respond_to?(:force_encoding) |
|
265 | if str_felix_hex.respond_to?(:force_encoding) | |
266 | str_felix_hex.force_encoding('UTF-8') |
|
266 | str_felix_hex.force_encoding('UTF-8') | |
267 | end |
|
267 | end | |
268 | c = @repository.changesets.find_by_revision('ed5bb786bbda2dee66a2d50faf51429dbc043a7b') |
|
268 | c = @repository.changesets.find_by_revision('ed5bb786bbda2dee66a2d50faf51429dbc043a7b') | |
269 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer |
|
269 | assert_equal "#{str_felix_hex} <felix@fachschaften.org>", c.committer | |
270 | end |
|
270 | end | |
271 |
|
271 | |||
272 | def test_previous |
|
272 | def test_previous | |
273 | @repository.fetch_changesets |
|
273 | @repository.fetch_changesets | |
274 | @repository.reload |
|
274 | @repository.reload | |
275 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
275 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
276 | changeset = @repository.find_changeset_by_name(r1) |
|
276 | changeset = @repository.find_changeset_by_name(r1) | |
277 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
277 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
278 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous |
|
278 | assert_equal @repository.find_changeset_by_name(r2), changeset.previous | |
279 | end |
|
279 | end | |
280 | end |
|
280 | end | |
281 | end |
|
281 | end | |
282 |
|
282 | |||
283 | def test_previous_nil |
|
283 | def test_previous_nil | |
284 | @repository.fetch_changesets |
|
284 | @repository.fetch_changesets | |
285 | @repository.reload |
|
285 | @repository.reload | |
286 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1| |
|
286 | %w|7234cb2750b63f47bff735edc50a1c0a433c2518 7234cb2|.each do |r1| | |
287 | changeset = @repository.find_changeset_by_name(r1) |
|
287 | changeset = @repository.find_changeset_by_name(r1) | |
288 | assert_nil changeset.previous |
|
288 | assert_nil changeset.previous | |
289 | end |
|
289 | end | |
290 | end |
|
290 | end | |
291 |
|
291 | |||
292 | def test_next |
|
292 | def test_next | |
293 | @repository.fetch_changesets |
|
293 | @repository.fetch_changesets | |
294 | @repository.reload |
|
294 | @repository.reload | |
295 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| |
|
295 | %w|64f1f3e89ad1cb57976ff0ad99a107012ba3481d 64f1f3e89ad1|.each do |r2| | |
296 | changeset = @repository.find_changeset_by_name(r2) |
|
296 | changeset = @repository.find_changeset_by_name(r2) | |
297 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
297 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
298 | assert_equal @repository.find_changeset_by_name(r1), changeset.next |
|
298 | assert_equal @repository.find_changeset_by_name(r1), changeset.next | |
299 | end |
|
299 | end | |
300 | end |
|
300 | end | |
301 | end |
|
301 | end | |
302 |
|
302 | |||
303 | def test_next_nil |
|
303 | def test_next_nil | |
304 | @repository.fetch_changesets |
|
304 | @repository.fetch_changesets | |
305 | @repository.reload |
|
305 | @repository.reload | |
306 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| |
|
306 | %w|1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127 1ca7f5ed|.each do |r1| | |
307 | changeset = @repository.find_changeset_by_name(r1) |
|
307 | changeset = @repository.find_changeset_by_name(r1) | |
308 | assert_nil changeset.next |
|
308 | assert_nil changeset.next | |
309 | end |
|
309 | end | |
310 | end |
|
310 | end | |
311 | else |
|
311 | else | |
312 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" |
|
312 | puts "Git test repository NOT FOUND. Skipping unit tests !!!" | |
313 | def test_fake; assert true end |
|
313 | def test_fake; assert true end | |
314 | end |
|
314 | end | |
315 | end |
|
315 | end |
General Comments 0
You need to be logged in to leave comments.
Login now