##// END OF EJS Templates
Rails4: replace deprecated Relation#update_all at RepositoryTest...
Toshi MARUYAMA -
r12282:95bc7bf189ca
parent child
Show More
@@ -1,393 +1,391
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
2 # Copyright (C) 2006-2013 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 RepositoryTest < ActiveSupport::TestCase
20 class RepositoryTest < ActiveSupport::TestCase
21 fixtures :projects,
21 fixtures :projects,
22 :trackers,
22 :trackers,
23 :projects_trackers,
23 :projects_trackers,
24 :enabled_modules,
24 :enabled_modules,
25 :repositories,
25 :repositories,
26 :issues,
26 :issues,
27 :issue_statuses,
27 :issue_statuses,
28 :issue_categories,
28 :issue_categories,
29 :changesets,
29 :changesets,
30 :changes,
30 :changes,
31 :users,
31 :users,
32 :members,
32 :members,
33 :member_roles,
33 :member_roles,
34 :roles,
34 :roles,
35 :enumerations
35 :enumerations
36
36
37 include Redmine::I18n
37 include Redmine::I18n
38
38
39 def setup
39 def setup
40 @repository = Project.find(1).repository
40 @repository = Project.find(1).repository
41 end
41 end
42
42
43 def test_blank_log_encoding_error_message
43 def test_blank_log_encoding_error_message
44 set_language_if_valid 'en'
44 set_language_if_valid 'en'
45 repo = Repository::Bazaar.new(
45 repo = Repository::Bazaar.new(
46 :project => Project.find(3),
46 :project => Project.find(3),
47 :url => "/test",
47 :url => "/test",
48 :log_encoding => ''
48 :log_encoding => ''
49 )
49 )
50 assert !repo.save
50 assert !repo.save
51 assert_include "Commit messages encoding can't be blank",
51 assert_include "Commit messages encoding can't be blank",
52 repo.errors.full_messages
52 repo.errors.full_messages
53 end
53 end
54
54
55 def test_blank_log_encoding_error_message_fr
55 def test_blank_log_encoding_error_message_fr
56 set_language_if_valid 'fr'
56 set_language_if_valid 'fr'
57 str = "Encodage des messages de commit doit \xc3\xaatre renseign\xc3\xa9(e)"
57 str = "Encodage des messages de commit doit \xc3\xaatre renseign\xc3\xa9(e)"
58 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
58 str.force_encoding('UTF-8') if str.respond_to?(:force_encoding)
59 repo = Repository::Bazaar.new(
59 repo = Repository::Bazaar.new(
60 :project => Project.find(3),
60 :project => Project.find(3),
61 :url => "/test"
61 :url => "/test"
62 )
62 )
63 assert !repo.save
63 assert !repo.save
64 assert_include str, repo.errors.full_messages
64 assert_include str, repo.errors.full_messages
65 end
65 end
66
66
67 def test_create
67 def test_create
68 repository = Repository::Subversion.new(:project => Project.find(3))
68 repository = Repository::Subversion.new(:project => Project.find(3))
69 assert !repository.save
69 assert !repository.save
70
70
71 repository.url = "svn://localhost"
71 repository.url = "svn://localhost"
72 assert repository.save
72 assert repository.save
73 repository.reload
73 repository.reload
74
74
75 project = Project.find(3)
75 project = Project.find(3)
76 assert_equal repository, project.repository
76 assert_equal repository, project.repository
77 end
77 end
78
78
79 def test_first_repository_should_be_set_as_default
79 def test_first_repository_should_be_set_as_default
80 repository1 = Repository::Subversion.new(
80 repository1 = Repository::Subversion.new(
81 :project => Project.find(3),
81 :project => Project.find(3),
82 :identifier => 'svn1',
82 :identifier => 'svn1',
83 :url => 'file:///svn1'
83 :url => 'file:///svn1'
84 )
84 )
85 assert repository1.save
85 assert repository1.save
86 assert repository1.is_default?
86 assert repository1.is_default?
87
87
88 repository2 = Repository::Subversion.new(
88 repository2 = Repository::Subversion.new(
89 :project => Project.find(3),
89 :project => Project.find(3),
90 :identifier => 'svn2',
90 :identifier => 'svn2',
91 :url => 'file:///svn2'
91 :url => 'file:///svn2'
92 )
92 )
93 assert repository2.save
93 assert repository2.save
94 assert !repository2.is_default?
94 assert !repository2.is_default?
95
95
96 assert_equal repository1, Project.find(3).repository
96 assert_equal repository1, Project.find(3).repository
97 assert_equal [repository1, repository2], Project.find(3).repositories.sort
97 assert_equal [repository1, repository2], Project.find(3).repositories.sort
98 end
98 end
99
99
100 def test_default_repository_should_be_one
100 def test_default_repository_should_be_one
101 assert_equal 0, Project.find(3).repositories.count
101 assert_equal 0, Project.find(3).repositories.count
102 repository1 = Repository::Subversion.new(
102 repository1 = Repository::Subversion.new(
103 :project => Project.find(3),
103 :project => Project.find(3),
104 :identifier => 'svn1',
104 :identifier => 'svn1',
105 :url => 'file:///svn1'
105 :url => 'file:///svn1'
106 )
106 )
107 assert repository1.save
107 assert repository1.save
108 assert repository1.is_default?
108 assert repository1.is_default?
109
109
110 repository2 = Repository::Subversion.new(
110 repository2 = Repository::Subversion.new(
111 :project => Project.find(3),
111 :project => Project.find(3),
112 :identifier => 'svn2',
112 :identifier => 'svn2',
113 :url => 'file:///svn2',
113 :url => 'file:///svn2',
114 :is_default => true
114 :is_default => true
115 )
115 )
116 assert repository2.save
116 assert repository2.save
117 assert repository2.is_default?
117 assert repository2.is_default?
118 repository1.reload
118 repository1.reload
119 assert !repository1.is_default?
119 assert !repository1.is_default?
120
120
121 assert_equal repository2, Project.find(3).repository
121 assert_equal repository2, Project.find(3).repository
122 assert_equal [repository2, repository1], Project.find(3).repositories.sort
122 assert_equal [repository2, repository1], Project.find(3).repositories.sort
123 end
123 end
124
124
125 def test_identifier_should_accept_letters_digits_dashes_and_underscores
125 def test_identifier_should_accept_letters_digits_dashes_and_underscores
126 r = Repository::Subversion.new(
126 r = Repository::Subversion.new(
127 :project_id => 3,
127 :project_id => 3,
128 :identifier => 'svn-123_45',
128 :identifier => 'svn-123_45',
129 :url => 'file:///svn'
129 :url => 'file:///svn'
130 )
130 )
131 assert r.save
131 assert r.save
132 end
132 end
133
133
134 def test_identifier_should_not_be_frozen_for_a_new_repository
134 def test_identifier_should_not_be_frozen_for_a_new_repository
135 assert_equal false, Repository.new.identifier_frozen?
135 assert_equal false, Repository.new.identifier_frozen?
136 end
136 end
137
137
138 def test_identifier_should_not_be_frozen_for_a_saved_repository_with_blank_identifier
138 def test_identifier_should_not_be_frozen_for_a_saved_repository_with_blank_identifier
139 Repository.update_all(["identifier = ''"], "id = 10")
139 Repository.where(:id => 10).update_all(["identifier = ''"])
140
141 assert_equal false, Repository.find(10).identifier_frozen?
140 assert_equal false, Repository.find(10).identifier_frozen?
142 end
141 end
143
142
144 def test_identifier_should_be_frozen_for_a_saved_repository_with_valid_identifier
143 def test_identifier_should_be_frozen_for_a_saved_repository_with_valid_identifier
145 Repository.update_all(["identifier = 'abc123'"], "id = 10")
144 Repository.where(:id => 10).update_all(["identifier = 'abc123'"])
146
147 assert_equal true, Repository.find(10).identifier_frozen?
145 assert_equal true, Repository.find(10).identifier_frozen?
148 end
146 end
149
147
150 def test_identifier_should_not_accept_change_if_frozen
148 def test_identifier_should_not_accept_change_if_frozen
151 r = Repository.new(:identifier => 'foo')
149 r = Repository.new(:identifier => 'foo')
152 r.stubs(:identifier_frozen?).returns(true)
150 r.stubs(:identifier_frozen?).returns(true)
153
151
154 r.identifier = 'bar'
152 r.identifier = 'bar'
155 assert_equal 'foo', r.identifier
153 assert_equal 'foo', r.identifier
156 end
154 end
157
155
158 def test_identifier_should_accept_change_if_not_frozen
156 def test_identifier_should_accept_change_if_not_frozen
159 r = Repository.new(:identifier => 'foo')
157 r = Repository.new(:identifier => 'foo')
160 r.stubs(:identifier_frozen?).returns(false)
158 r.stubs(:identifier_frozen?).returns(false)
161
159
162 r.identifier = 'bar'
160 r.identifier = 'bar'
163 assert_equal 'bar', r.identifier
161 assert_equal 'bar', r.identifier
164 end
162 end
165
163
166 def test_destroy
164 def test_destroy
167 repository = Repository.find(10)
165 repository = Repository.find(10)
168 changesets = repository.changesets.count
166 changesets = repository.changesets.count
169 changes = repository.filechanges.count
167 changes = repository.filechanges.count
170
168
171 assert_difference 'Changeset.count', -changesets do
169 assert_difference 'Changeset.count', -changesets do
172 assert_difference 'Change.count', -changes do
170 assert_difference 'Change.count', -changes do
173 Repository.find(10).destroy
171 Repository.find(10).destroy
174 end
172 end
175 end
173 end
176 end
174 end
177
175
178 def test_destroy_should_delete_parents_associations
176 def test_destroy_should_delete_parents_associations
179 changeset = Changeset.find(102)
177 changeset = Changeset.find(102)
180 changeset.parents = Changeset.find_all_by_id([100, 101])
178 changeset.parents = Changeset.find_all_by_id([100, 101])
181 assert_difference 'Changeset.connection.select_all("select * from changeset_parents").count', -2 do
179 assert_difference 'Changeset.connection.select_all("select * from changeset_parents").count', -2 do
182 Repository.find(10).destroy
180 Repository.find(10).destroy
183 end
181 end
184 end
182 end
185
183
186 def test_destroy_should_delete_issues_associations
184 def test_destroy_should_delete_issues_associations
187 changeset = Changeset.find(102)
185 changeset = Changeset.find(102)
188 changeset.issues = Issue.find_all_by_id([1, 2])
186 changeset.issues = Issue.find_all_by_id([1, 2])
189 assert_difference 'Changeset.connection.select_all("select * from changesets_issues").count', -2 do
187 assert_difference 'Changeset.connection.select_all("select * from changesets_issues").count', -2 do
190 Repository.find(10).destroy
188 Repository.find(10).destroy
191 end
189 end
192 end
190 end
193
191
194 def test_should_not_create_with_disabled_scm
192 def test_should_not_create_with_disabled_scm
195 # disable Subversion
193 # disable Subversion
196 with_settings :enabled_scm => ['Darcs', 'Git'] do
194 with_settings :enabled_scm => ['Darcs', 'Git'] do
197 repository = Repository::Subversion.new(
195 repository = Repository::Subversion.new(
198 :project => Project.find(3), :url => "svn://localhost")
196 :project => Project.find(3), :url => "svn://localhost")
199 assert !repository.save
197 assert !repository.save
200 assert_include I18n.translate('activerecord.errors.messages.invalid'),
198 assert_include I18n.translate('activerecord.errors.messages.invalid'),
201 repository.errors[:type]
199 repository.errors[:type]
202 end
200 end
203 end
201 end
204
202
205 def test_scan_changesets_for_issue_ids
203 def test_scan_changesets_for_issue_ids
206 Setting.default_language = 'en'
204 Setting.default_language = 'en'
207
205
208 Setting.commit_ref_keywords = 'refs , references, IssueID'
206 Setting.commit_ref_keywords = 'refs , references, IssueID'
209 Setting.commit_update_keywords = [
207 Setting.commit_update_keywords = [
210 {'keywords' => 'fixes , closes', 'status_id' => IssueStatus.where(:is_closed => true).first.id, 'done_ratio' => '90'}
208 {'keywords' => 'fixes , closes', 'status_id' => IssueStatus.where(:is_closed => true).first.id, 'done_ratio' => '90'}
211 ]
209 ]
212 Setting.default_language = 'en'
210 Setting.default_language = 'en'
213 ActionMailer::Base.deliveries.clear
211 ActionMailer::Base.deliveries.clear
214
212
215 # make sure issue 1 is not already closed
213 # make sure issue 1 is not already closed
216 fixed_issue = Issue.find(1)
214 fixed_issue = Issue.find(1)
217 assert !fixed_issue.status.is_closed?
215 assert !fixed_issue.status.is_closed?
218 old_status = fixed_issue.status
216 old_status = fixed_issue.status
219
217
220 with_settings :notified_events => %w(issue_added issue_updated) do
218 with_settings :notified_events => %w(issue_added issue_updated) do
221 Repository.scan_changesets_for_issue_ids
219 Repository.scan_changesets_for_issue_ids
222 end
220 end
223 assert_equal [101, 102], Issue.find(3).changeset_ids
221 assert_equal [101, 102], Issue.find(3).changeset_ids
224
222
225 # fixed issues
223 # fixed issues
226 fixed_issue.reload
224 fixed_issue.reload
227 assert fixed_issue.status.is_closed?
225 assert fixed_issue.status.is_closed?
228 assert_equal 90, fixed_issue.done_ratio
226 assert_equal 90, fixed_issue.done_ratio
229 assert_equal [101], fixed_issue.changeset_ids
227 assert_equal [101], fixed_issue.changeset_ids
230
228
231 # issue change
229 # issue change
232 journal = fixed_issue.journals.reorder('created_on desc').first
230 journal = fixed_issue.journals.reorder('created_on desc').first
233 assert_equal User.find_by_login('dlopper'), journal.user
231 assert_equal User.find_by_login('dlopper'), journal.user
234 assert_equal 'Applied in changeset r2.', journal.notes
232 assert_equal 'Applied in changeset r2.', journal.notes
235
233
236 # 2 email notifications
234 # 2 email notifications
237 assert_equal 2, ActionMailer::Base.deliveries.size
235 assert_equal 2, ActionMailer::Base.deliveries.size
238 mail = ActionMailer::Base.deliveries.first
236 mail = ActionMailer::Base.deliveries.first
239 assert_not_nil mail
237 assert_not_nil mail
240 assert mail.subject.starts_with?(
238 assert mail.subject.starts_with?(
241 "[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
239 "[#{fixed_issue.project.name} - #{fixed_issue.tracker.name} ##{fixed_issue.id}]")
242 assert_mail_body_match(
240 assert_mail_body_match(
243 "Status changed from #{old_status} to #{fixed_issue.status}", mail)
241 "Status changed from #{old_status} to #{fixed_issue.status}", mail)
244
242
245 # ignoring commits referencing an issue of another project
243 # ignoring commits referencing an issue of another project
246 assert_equal [], Issue.find(4).changesets
244 assert_equal [], Issue.find(4).changesets
247 end
245 end
248
246
249 def test_for_changeset_comments_strip
247 def test_for_changeset_comments_strip
250 repository = Repository::Mercurial.create(
248 repository = Repository::Mercurial.create(
251 :project => Project.find( 4 ),
249 :project => Project.find( 4 ),
252 :url => '/foo/bar/baz' )
250 :url => '/foo/bar/baz' )
253 comment = <<-COMMENT
251 comment = <<-COMMENT
254 This is a loooooooooooooooooooooooooooong comment
252 This is a loooooooooooooooooooooooooooong comment
255
253
256
254
257 COMMENT
255 COMMENT
258 changeset = Changeset.new(
256 changeset = Changeset.new(
259 :comments => comment, :commit_date => Time.now,
257 :comments => comment, :commit_date => Time.now,
260 :revision => 0, :scmid => 'f39b7922fb3c',
258 :revision => 0, :scmid => 'f39b7922fb3c',
261 :committer => 'foo <foo@example.com>',
259 :committer => 'foo <foo@example.com>',
262 :committed_on => Time.now, :repository => repository )
260 :committed_on => Time.now, :repository => repository )
263 assert( changeset.save )
261 assert( changeset.save )
264 assert_not_equal( comment, changeset.comments )
262 assert_not_equal( comment, changeset.comments )
265 assert_equal( 'This is a loooooooooooooooooooooooooooong comment',
263 assert_equal( 'This is a loooooooooooooooooooooooooooong comment',
266 changeset.comments )
264 changeset.comments )
267 end
265 end
268
266
269 def test_for_urls_strip_cvs
267 def test_for_urls_strip_cvs
270 repository = Repository::Cvs.create(
268 repository = Repository::Cvs.create(
271 :project => Project.find(4),
269 :project => Project.find(4),
272 :url => ' :pserver:login:password@host:/path/to/the/repository',
270 :url => ' :pserver:login:password@host:/path/to/the/repository',
273 :root_url => 'foo ',
271 :root_url => 'foo ',
274 :log_encoding => 'UTF-8')
272 :log_encoding => 'UTF-8')
275 assert repository.save
273 assert repository.save
276 repository.reload
274 repository.reload
277 assert_equal ':pserver:login:password@host:/path/to/the/repository',
275 assert_equal ':pserver:login:password@host:/path/to/the/repository',
278 repository.url
276 repository.url
279 assert_equal 'foo', repository.root_url
277 assert_equal 'foo', repository.root_url
280 end
278 end
281
279
282 def test_for_urls_strip_subversion
280 def test_for_urls_strip_subversion
283 repository = Repository::Subversion.create(
281 repository = Repository::Subversion.create(
284 :project => Project.find(4),
282 :project => Project.find(4),
285 :url => ' file:///dummy ')
283 :url => ' file:///dummy ')
286 assert repository.save
284 assert repository.save
287 repository.reload
285 repository.reload
288 assert_equal 'file:///dummy', repository.url
286 assert_equal 'file:///dummy', repository.url
289 end
287 end
290
288
291 def test_for_urls_strip_git
289 def test_for_urls_strip_git
292 repository = Repository::Git.create(
290 repository = Repository::Git.create(
293 :project => Project.find(4),
291 :project => Project.find(4),
294 :url => ' c:\dummy ')
292 :url => ' c:\dummy ')
295 assert repository.save
293 assert repository.save
296 repository.reload
294 repository.reload
297 assert_equal 'c:\dummy', repository.url
295 assert_equal 'c:\dummy', repository.url
298 end
296 end
299
297
300 def test_manual_user_mapping
298 def test_manual_user_mapping
301 assert_no_difference "Changeset.where('user_id <> 2').count" do
299 assert_no_difference "Changeset.where('user_id <> 2').count" do
302 c = Changeset.create!(
300 c = Changeset.create!(
303 :repository => @repository,
301 :repository => @repository,
304 :committer => 'foo',
302 :committer => 'foo',
305 :committed_on => Time.now,
303 :committed_on => Time.now,
306 :revision => 100,
304 :revision => 100,
307 :comments => 'Committed by foo.'
305 :comments => 'Committed by foo.'
308 )
306 )
309 assert_nil c.user
307 assert_nil c.user
310 @repository.committer_ids = {'foo' => '2'}
308 @repository.committer_ids = {'foo' => '2'}
311 assert_equal User.find(2), c.reload.user
309 assert_equal User.find(2), c.reload.user
312 # committer is now mapped
310 # committer is now mapped
313 c = Changeset.create!(
311 c = Changeset.create!(
314 :repository => @repository,
312 :repository => @repository,
315 :committer => 'foo',
313 :committer => 'foo',
316 :committed_on => Time.now,
314 :committed_on => Time.now,
317 :revision => 101,
315 :revision => 101,
318 :comments => 'Another commit by foo.'
316 :comments => 'Another commit by foo.'
319 )
317 )
320 assert_equal User.find(2), c.user
318 assert_equal User.find(2), c.user
321 end
319 end
322 end
320 end
323
321
324 def test_auto_user_mapping_by_username
322 def test_auto_user_mapping_by_username
325 c = Changeset.create!(
323 c = Changeset.create!(
326 :repository => @repository,
324 :repository => @repository,
327 :committer => 'jsmith',
325 :committer => 'jsmith',
328 :committed_on => Time.now,
326 :committed_on => Time.now,
329 :revision => 100,
327 :revision => 100,
330 :comments => 'Committed by john.'
328 :comments => 'Committed by john.'
331 )
329 )
332 assert_equal User.find(2), c.user
330 assert_equal User.find(2), c.user
333 end
331 end
334
332
335 def test_auto_user_mapping_by_email
333 def test_auto_user_mapping_by_email
336 c = Changeset.create!(
334 c = Changeset.create!(
337 :repository => @repository,
335 :repository => @repository,
338 :committer => 'john <jsmith@somenet.foo>',
336 :committer => 'john <jsmith@somenet.foo>',
339 :committed_on => Time.now,
337 :committed_on => Time.now,
340 :revision => 100,
338 :revision => 100,
341 :comments => 'Committed by john.'
339 :comments => 'Committed by john.'
342 )
340 )
343 assert_equal User.find(2), c.user
341 assert_equal User.find(2), c.user
344 end
342 end
345
343
346 def test_filesystem_avaialbe
344 def test_filesystem_avaialbe
347 klass = Repository::Filesystem
345 klass = Repository::Filesystem
348 assert klass.scm_adapter_class
346 assert klass.scm_adapter_class
349 assert_equal true, klass.scm_available
347 assert_equal true, klass.scm_available
350 end
348 end
351
349
352 def test_merge_extra_info
350 def test_merge_extra_info
353 repo = Repository::Subversion.new(:project => Project.find(3))
351 repo = Repository::Subversion.new(:project => Project.find(3))
354 assert !repo.save
352 assert !repo.save
355 repo.url = "svn://localhost"
353 repo.url = "svn://localhost"
356 assert repo.save
354 assert repo.save
357 repo.reload
355 repo.reload
358 project = Project.find(3)
356 project = Project.find(3)
359 assert_equal repo, project.repository
357 assert_equal repo, project.repository
360 assert_nil repo.extra_info
358 assert_nil repo.extra_info
361 h1 = {"test_1" => {"test_11" => "test_value_11"}}
359 h1 = {"test_1" => {"test_11" => "test_value_11"}}
362 repo.merge_extra_info(h1)
360 repo.merge_extra_info(h1)
363 assert_equal h1, repo.extra_info
361 assert_equal h1, repo.extra_info
364 h2 = {"test_2" => {
362 h2 = {"test_2" => {
365 "test_21" => "test_value_21",
363 "test_21" => "test_value_21",
366 "test_22" => "test_value_22",
364 "test_22" => "test_value_22",
367 }}
365 }}
368 repo.merge_extra_info(h2)
366 repo.merge_extra_info(h2)
369 assert_equal (h = {"test_11" => "test_value_11"}),
367 assert_equal (h = {"test_11" => "test_value_11"}),
370 repo.extra_info["test_1"]
368 repo.extra_info["test_1"]
371 assert_equal "test_value_21",
369 assert_equal "test_value_21",
372 repo.extra_info["test_2"]["test_21"]
370 repo.extra_info["test_2"]["test_21"]
373 h3 = {"test_2" => {
371 h3 = {"test_2" => {
374 "test_23" => "test_value_23",
372 "test_23" => "test_value_23",
375 "test_24" => "test_value_24",
373 "test_24" => "test_value_24",
376 }}
374 }}
377 repo.merge_extra_info(h3)
375 repo.merge_extra_info(h3)
378 assert_equal (h = {"test_11" => "test_value_11"}),
376 assert_equal (h = {"test_11" => "test_value_11"}),
379 repo.extra_info["test_1"]
377 repo.extra_info["test_1"]
380 assert_nil repo.extra_info["test_2"]["test_21"]
378 assert_nil repo.extra_info["test_2"]["test_21"]
381 assert_equal "test_value_23",
379 assert_equal "test_value_23",
382 repo.extra_info["test_2"]["test_23"]
380 repo.extra_info["test_2"]["test_23"]
383 end
381 end
384
382
385 def test_sort_should_not_raise_an_error_with_nil_identifiers
383 def test_sort_should_not_raise_an_error_with_nil_identifiers
386 r1 = Repository.new
384 r1 = Repository.new
387 r2 = Repository.new
385 r2 = Repository.new
388
386
389 assert_nothing_raised do
387 assert_nothing_raised do
390 [r1, r2].sort
388 [r1, r2].sort
391 end
389 end
392 end
390 end
393 end
391 end
General Comments 0
You need to be logged in to leave comments. Login now