comparison test/unit/changeset_test.rb @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents e248c7af89ec
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
94 assert_difference 'TimeEntry.count' do 94 assert_difference 'TimeEntry.count' do
95 c.scan_comment_for_issue_ids 95 c.scan_comment_for_issue_ids
96 end 96 end
97 assert_equal [1], c.issue_ids.sort 97 assert_equal [1], c.issue_ids.sort
98 98
99 time = TimeEntry.first(:order => 'id desc') 99 time = TimeEntry.order('id desc').first
100 assert_equal 1, time.issue_id 100 assert_equal 1, time.issue_id
101 assert_equal 1, time.project_id 101 assert_equal 1, time.project_id
102 assert_equal 2, time.user_id 102 assert_equal 2, time.user_id
103 assert_equal expected_hours, time.hours, 103 assert_equal expected_hours, time.hours,
104 "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}" 104 "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}"
109 end 109 end
110 end 110 end
111 111
112 def test_ref_keywords_closing_with_timelog 112 def test_ref_keywords_closing_with_timelog
113 Setting.commit_ref_keywords = '*' 113 Setting.commit_ref_keywords = '*'
114 Setting.commit_update_keywords = [{'keywords' => 'fixes , closes', 'status_id' => IssueStatus.where(:is_closed => true).first.id.to_s}] 114 Setting.commit_update_keywords = [{'keywords' => 'fixes , closes',
115 'status_id' => IssueStatus.where(:is_closed => true).first.id.to_s}]
115 Setting.commit_logtime_enabled = '1' 116 Setting.commit_logtime_enabled = '1'
116 117
117 c = Changeset.new(:repository => Project.find(1).repository, 118 c = Changeset.new(:repository => Project.find(1).repository,
118 :committed_on => Time.now, 119 :committed_on => Time.now,
119 :comments => 'This is a comment. Fixes #1 @4.5, #2 @1', 120 :comments => 'This is a comment. Fixes #1 @4.5, #2 @1',
124 125
125 assert_equal [1, 2], c.issue_ids.sort 126 assert_equal [1, 2], c.issue_ids.sort
126 assert Issue.find(1).closed? 127 assert Issue.find(1).closed?
127 assert Issue.find(2).closed? 128 assert Issue.find(2).closed?
128 129
129 times = TimeEntry.all(:order => 'id desc', :limit => 2) 130 times = TimeEntry.order('id desc').limit(2)
130 assert_equal [1, 2], times.collect(&:issue_id).sort 131 assert_equal [1, 2], times.collect(&:issue_id).sort
131 end 132 end
132 133
133 def test_ref_keywords_any_line_start 134 def test_ref_keywords_any_line_start
134 Setting.commit_ref_keywords = '*' 135 Setting.commit_ref_keywords = '*'
223 :comments => 'closes #5, a subproject issue', 224 :comments => 'closes #5, a subproject issue',
224 :revision => '12345') 225 :revision => '12345')
225 assert c.save 226 assert c.save
226 end 227 end
227 assert issue.reload.closed? 228 assert issue.reload.closed?
228 journal = Journal.first(:order => 'id DESC') 229 journal = Journal.order('id DESC').first
229 assert_equal issue, journal.issue 230 assert_equal issue, journal.issue
230 assert_include "Applied in changeset ecookbook:r12345.", journal.notes 231 assert_include "Applied in changeset ecookbook:r12345.", journal.notes
231 end 232 end
232 end 233 end
233 234
247 248
248 def test_commit_referencing_a_project_with_commit_cross_project_ref_disabled 249 def test_commit_referencing_a_project_with_commit_cross_project_ref_disabled
249 r = Repository::Subversion.create!( 250 r = Repository::Subversion.create!(
250 :project => Project.find(3), 251 :project => Project.find(3),
251 :url => 'svn://localhost/test') 252 :url => 'svn://localhost/test')
252
253 with_settings :commit_cross_project_ref => '0' do 253 with_settings :commit_cross_project_ref => '0' do
254 c = Changeset.new(:repository => r, 254 c = Changeset.new(:repository => r,
255 :committed_on => Time.now, 255 :committed_on => Time.now,
256 :comments => 'refs #4, an issue of a different project', 256 :comments => 'refs #4, an issue of a different project',
257 :revision => '12345') 257 :revision => '12345')
262 262
263 def test_commit_referencing_a_project_with_commit_cross_project_ref_enabled 263 def test_commit_referencing_a_project_with_commit_cross_project_ref_enabled
264 r = Repository::Subversion.create!( 264 r = Repository::Subversion.create!(
265 :project => Project.find(3), 265 :project => Project.find(3),
266 :url => 'svn://localhost/test') 266 :url => 'svn://localhost/test')
267
268 with_settings :commit_cross_project_ref => '1' do 267 with_settings :commit_cross_project_ref => '1' do
269 c = Changeset.new(:repository => r, 268 c = Changeset.new(:repository => r,
270 :committed_on => Time.now, 269 :committed_on => Time.now,
271 :comments => 'refs #4, an issue of a different project', 270 :comments => 'refs #4, an issue of a different project',
272 :revision => '12345') 271 :revision => '12345')
315 def test_text_tag_revision_with_repository_identifier 314 def test_text_tag_revision_with_repository_identifier
316 r = Repository::Subversion.create!( 315 r = Repository::Subversion.create!(
317 :project_id => 1, 316 :project_id => 1,
318 :url => 'svn://localhost/test', 317 :url => 'svn://localhost/test',
319 :identifier => 'documents') 318 :identifier => 'documents')
320
321 c = Changeset.new(:revision => '520', :repository => r) 319 c = Changeset.new(:revision => '520', :repository => r)
322 assert_equal 'documents|r520', c.text_tag 320 assert_equal 'documents|r520', c.text_tag
323 assert_equal 'ecookbook:documents|r520', c.text_tag(Project.find(2)) 321 assert_equal 'ecookbook:documents|r520', c.text_tag(Project.find(2))
324 end 322 end
325 323
536 assert_equal "UTF-8", c.comments.encoding.to_s 534 assert_equal "UTF-8", c.comments.encoding.to_s
537 assert_equal "UTF-8", c.committer.encoding.to_s 535 assert_equal "UTF-8", c.committer.encoding.to_s
538 end 536 end
539 end 537 end
540 538
539 def test_comments_should_accept_more_than_64k
540 c = Changeset.new(:repository => Repository.first,
541 :committed_on => Time.now,
542 :revision => '123',
543 :scmid => '12345',
544 :comments => "a" * 500.kilobyte)
545 assert c.save
546 c.reload
547 assert_equal 500.kilobyte, c.comments.size
548 end
549
541 def test_identifier 550 def test_identifier
542 c = Changeset.find_by_revision('1') 551 c = Changeset.find_by_revision('1')
543 assert_equal c.revision, c.identifier 552 assert_equal c.revision, c.identifier
544 end 553 end
545 end 554 end