annotate .svn/pristine/45/45db780cec4e0c72778412b47b7cf78b370991c8.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
rev   line source
Chris@1295 1 # encoding: utf-8
Chris@1295 2 #
Chris@1295 3 # Redmine - project management software
Chris@1295 4 # Copyright (C) 2006-2012 Jean-Philippe Lang
Chris@1295 5 #
Chris@1295 6 # This program is free software; you can redistribute it and/or
Chris@1295 7 # modify it under the terms of the GNU General Public License
Chris@1295 8 # as published by the Free Software Foundation; either version 2
Chris@1295 9 # of the License, or (at your option) any later version.
Chris@1295 10 #
Chris@1295 11 # This program is distributed in the hope that it will be useful,
Chris@1295 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1295 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1295 14 # GNU General Public License for more details.
Chris@1295 15 #
Chris@1295 16 # You should have received a copy of the GNU General Public License
Chris@1295 17 # along with this program; if not, write to the Free Software
Chris@1295 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1295 19
Chris@1295 20 require File.expand_path('../../test_helper', __FILE__)
Chris@1295 21
Chris@1295 22 class ChangesetTest < ActiveSupport::TestCase
Chris@1295 23 fixtures :projects, :repositories,
Chris@1295 24 :issues, :issue_statuses, :issue_categories,
Chris@1295 25 :changesets, :changes,
Chris@1295 26 :enumerations,
Chris@1295 27 :custom_fields, :custom_values,
Chris@1295 28 :users, :members, :member_roles, :trackers,
Chris@1295 29 :enabled_modules, :roles
Chris@1295 30
Chris@1295 31 def test_ref_keywords_any
Chris@1295 32 ActionMailer::Base.deliveries.clear
Chris@1295 33 Setting.commit_fix_status_id = IssueStatus.find(
Chris@1295 34 :first, :conditions => ["is_closed = ?", true]).id
Chris@1295 35 Setting.commit_fix_done_ratio = '90'
Chris@1295 36 Setting.commit_ref_keywords = '*'
Chris@1295 37 Setting.commit_fix_keywords = 'fixes , closes'
Chris@1295 38
Chris@1295 39 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 40 :committed_on => Time.now,
Chris@1295 41 :comments => 'New commit (#2). Fixes #1',
Chris@1295 42 :revision => '12345')
Chris@1295 43 assert c.save
Chris@1295 44 assert_equal [1, 2], c.issue_ids.sort
Chris@1295 45 fixed = Issue.find(1)
Chris@1295 46 assert fixed.closed?
Chris@1295 47 assert_equal 90, fixed.done_ratio
Chris@1295 48 assert_equal 1, ActionMailer::Base.deliveries.size
Chris@1295 49 end
Chris@1295 50
Chris@1295 51 def test_ref_keywords
Chris@1295 52 Setting.commit_ref_keywords = 'refs'
Chris@1295 53 Setting.commit_fix_keywords = ''
Chris@1295 54 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 55 :committed_on => Time.now,
Chris@1295 56 :comments => 'Ignores #2. Refs #1',
Chris@1295 57 :revision => '12345')
Chris@1295 58 assert c.save
Chris@1295 59 assert_equal [1], c.issue_ids.sort
Chris@1295 60 end
Chris@1295 61
Chris@1295 62 def test_ref_keywords_any_only
Chris@1295 63 Setting.commit_ref_keywords = '*'
Chris@1295 64 Setting.commit_fix_keywords = ''
Chris@1295 65 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 66 :committed_on => Time.now,
Chris@1295 67 :comments => 'Ignores #2. Refs #1',
Chris@1295 68 :revision => '12345')
Chris@1295 69 assert c.save
Chris@1295 70 assert_equal [1, 2], c.issue_ids.sort
Chris@1295 71 end
Chris@1295 72
Chris@1295 73 def test_ref_keywords_any_with_timelog
Chris@1295 74 Setting.commit_ref_keywords = '*'
Chris@1295 75 Setting.commit_logtime_enabled = '1'
Chris@1295 76
Chris@1295 77 {
Chris@1295 78 '2' => 2.0,
Chris@1295 79 '2h' => 2.0,
Chris@1295 80 '2hours' => 2.0,
Chris@1295 81 '15m' => 0.25,
Chris@1295 82 '15min' => 0.25,
Chris@1295 83 '3h15' => 3.25,
Chris@1295 84 '3h15m' => 3.25,
Chris@1295 85 '3h15min' => 3.25,
Chris@1295 86 '3:15' => 3.25,
Chris@1295 87 '3.25' => 3.25,
Chris@1295 88 '3.25h' => 3.25,
Chris@1295 89 '3,25' => 3.25,
Chris@1295 90 '3,25h' => 3.25,
Chris@1295 91 }.each do |syntax, expected_hours|
Chris@1295 92 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 93 :committed_on => 24.hours.ago,
Chris@1295 94 :comments => "Worked on this issue #1 @#{syntax}",
Chris@1295 95 :revision => '520',
Chris@1295 96 :user => User.find(2))
Chris@1295 97 assert_difference 'TimeEntry.count' do
Chris@1295 98 c.scan_comment_for_issue_ids
Chris@1295 99 end
Chris@1295 100 assert_equal [1], c.issue_ids.sort
Chris@1295 101
Chris@1295 102 time = TimeEntry.first(:order => 'id desc')
Chris@1295 103 assert_equal 1, time.issue_id
Chris@1295 104 assert_equal 1, time.project_id
Chris@1295 105 assert_equal 2, time.user_id
Chris@1295 106 assert_equal expected_hours, time.hours,
Chris@1295 107 "@#{syntax} should be logged as #{expected_hours} hours but was #{time.hours}"
Chris@1295 108 assert_equal Date.yesterday, time.spent_on
Chris@1295 109 assert time.activity.is_default?
Chris@1295 110 assert time.comments.include?('r520'),
Chris@1295 111 "r520 was expected in time_entry comments: #{time.comments}"
Chris@1295 112 end
Chris@1295 113 end
Chris@1295 114
Chris@1295 115 def test_ref_keywords_closing_with_timelog
Chris@1295 116 Setting.commit_fix_status_id = IssueStatus.find(
Chris@1295 117 :first, :conditions => ["is_closed = ?", true]).id
Chris@1295 118 Setting.commit_ref_keywords = '*'
Chris@1295 119 Setting.commit_fix_keywords = 'fixes , closes'
Chris@1295 120 Setting.commit_logtime_enabled = '1'
Chris@1295 121
Chris@1295 122 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 123 :committed_on => Time.now,
Chris@1295 124 :comments => 'This is a comment. Fixes #1 @4.5, #2 @1',
Chris@1295 125 :user => User.find(2))
Chris@1295 126 assert_difference 'TimeEntry.count', 2 do
Chris@1295 127 c.scan_comment_for_issue_ids
Chris@1295 128 end
Chris@1295 129
Chris@1295 130 assert_equal [1, 2], c.issue_ids.sort
Chris@1295 131 assert Issue.find(1).closed?
Chris@1295 132 assert Issue.find(2).closed?
Chris@1295 133
Chris@1295 134 times = TimeEntry.all(:order => 'id desc', :limit => 2)
Chris@1295 135 assert_equal [1, 2], times.collect(&:issue_id).sort
Chris@1295 136 end
Chris@1295 137
Chris@1295 138 def test_ref_keywords_any_line_start
Chris@1295 139 Setting.commit_ref_keywords = '*'
Chris@1295 140 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 141 :committed_on => Time.now,
Chris@1295 142 :comments => '#1 is the reason of this commit',
Chris@1295 143 :revision => '12345')
Chris@1295 144 assert c.save
Chris@1295 145 assert_equal [1], c.issue_ids.sort
Chris@1295 146 end
Chris@1295 147
Chris@1295 148 def test_ref_keywords_allow_brackets_around_a_issue_number
Chris@1295 149 Setting.commit_ref_keywords = '*'
Chris@1295 150 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 151 :committed_on => Time.now,
Chris@1295 152 :comments => '[#1] Worked on this issue',
Chris@1295 153 :revision => '12345')
Chris@1295 154 assert c.save
Chris@1295 155 assert_equal [1], c.issue_ids.sort
Chris@1295 156 end
Chris@1295 157
Chris@1295 158 def test_ref_keywords_allow_brackets_around_multiple_issue_numbers
Chris@1295 159 Setting.commit_ref_keywords = '*'
Chris@1295 160 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 161 :committed_on => Time.now,
Chris@1295 162 :comments => '[#1 #2, #3] Worked on these',
Chris@1295 163 :revision => '12345')
Chris@1295 164 assert c.save
Chris@1295 165 assert_equal [1,2,3], c.issue_ids.sort
Chris@1295 166 end
Chris@1295 167
Chris@1295 168 def test_commit_referencing_a_subproject_issue
Chris@1295 169 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 170 :committed_on => Time.now,
Chris@1295 171 :comments => 'refs #5, a subproject issue',
Chris@1295 172 :revision => '12345')
Chris@1295 173 assert c.save
Chris@1295 174 assert_equal [5], c.issue_ids.sort
Chris@1295 175 assert c.issues.first.project != c.project
Chris@1295 176 end
Chris@1295 177
Chris@1295 178 def test_commit_closing_a_subproject_issue
Chris@1295 179 with_settings :commit_fix_status_id => 5, :commit_fix_keywords => 'closes',
Chris@1295 180 :default_language => 'en' do
Chris@1295 181 issue = Issue.find(5)
Chris@1295 182 assert !issue.closed?
Chris@1295 183 assert_difference 'Journal.count' do
Chris@1295 184 c = Changeset.new(:repository => Project.find(1).repository,
Chris@1295 185 :committed_on => Time.now,
Chris@1295 186 :comments => 'closes #5, a subproject issue',
Chris@1295 187 :revision => '12345')
Chris@1295 188 assert c.save
Chris@1295 189 end
Chris@1295 190 assert issue.reload.closed?
Chris@1295 191 journal = Journal.first(:order => 'id DESC')
Chris@1295 192 assert_equal issue, journal.issue
Chris@1295 193 assert_include "Applied in changeset ecookbook:r12345.", journal.notes
Chris@1295 194 end
Chris@1295 195 end
Chris@1295 196
Chris@1295 197 def test_commit_referencing_a_parent_project_issue
Chris@1295 198 # repository of child project
Chris@1295 199 r = Repository::Subversion.create!(
Chris@1295 200 :project => Project.find(3),
Chris@1295 201 :url => 'svn://localhost/test')
Chris@1295 202 c = Changeset.new(:repository => r,
Chris@1295 203 :committed_on => Time.now,
Chris@1295 204 :comments => 'refs #2, an issue of a parent project',
Chris@1295 205 :revision => '12345')
Chris@1295 206 assert c.save
Chris@1295 207 assert_equal [2], c.issue_ids.sort
Chris@1295 208 assert c.issues.first.project != c.project
Chris@1295 209 end
Chris@1295 210
Chris@1295 211 def test_commit_referencing_a_project_with_commit_cross_project_ref_disabled
Chris@1295 212 r = Repository::Subversion.create!(
Chris@1295 213 :project => Project.find(3),
Chris@1295 214 :url => 'svn://localhost/test')
Chris@1295 215
Chris@1295 216 with_settings :commit_cross_project_ref => '0' do
Chris@1295 217 c = Changeset.new(:repository => r,
Chris@1295 218 :committed_on => Time.now,
Chris@1295 219 :comments => 'refs #4, an issue of a different project',
Chris@1295 220 :revision => '12345')
Chris@1295 221 assert c.save
Chris@1295 222 assert_equal [], c.issue_ids
Chris@1295 223 end
Chris@1295 224 end
Chris@1295 225
Chris@1295 226 def test_commit_referencing_a_project_with_commit_cross_project_ref_enabled
Chris@1295 227 r = Repository::Subversion.create!(
Chris@1295 228 :project => Project.find(3),
Chris@1295 229 :url => 'svn://localhost/test')
Chris@1295 230
Chris@1295 231 with_settings :commit_cross_project_ref => '1' do
Chris@1295 232 c = Changeset.new(:repository => r,
Chris@1295 233 :committed_on => Time.now,
Chris@1295 234 :comments => 'refs #4, an issue of a different project',
Chris@1295 235 :revision => '12345')
Chris@1295 236 assert c.save
Chris@1295 237 assert_equal [4], c.issue_ids
Chris@1295 238 end
Chris@1295 239 end
Chris@1295 240
Chris@1295 241 def test_text_tag_revision
Chris@1295 242 c = Changeset.new(:revision => '520')
Chris@1295 243 assert_equal 'r520', c.text_tag
Chris@1295 244 end
Chris@1295 245
Chris@1295 246 def test_text_tag_revision_with_same_project
Chris@1295 247 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository)
Chris@1295 248 assert_equal 'r520', c.text_tag(Project.find(1))
Chris@1295 249 end
Chris@1295 250
Chris@1295 251 def test_text_tag_revision_with_different_project
Chris@1295 252 c = Changeset.new(:revision => '520', :repository => Project.find(1).repository)
Chris@1295 253 assert_equal 'ecookbook:r520', c.text_tag(Project.find(2))
Chris@1295 254 end
Chris@1295 255
Chris@1295 256 def test_text_tag_revision_with_repository_identifier
Chris@1295 257 r = Repository::Subversion.create!(
Chris@1295 258 :project_id => 1,
Chris@1295 259 :url => 'svn://localhost/test',
Chris@1295 260 :identifier => 'documents')
Chris@1295 261
Chris@1295 262 c = Changeset.new(:revision => '520', :repository => r)
Chris@1295 263 assert_equal 'documents|r520', c.text_tag
Chris@1295 264 assert_equal 'ecookbook:documents|r520', c.text_tag(Project.find(2))
Chris@1295 265 end
Chris@1295 266
Chris@1295 267 def test_text_tag_hash
Chris@1295 268 c = Changeset.new(
Chris@1295 269 :scmid => '7234cb2750b63f47bff735edc50a1c0a433c2518',
Chris@1295 270 :revision => '7234cb2750b63f47bff735edc50a1c0a433c2518')
Chris@1295 271 assert_equal 'commit:7234cb2750b63f47bff735edc50a1c0a433c2518', c.text_tag
Chris@1295 272 end
Chris@1295 273
Chris@1295 274 def test_text_tag_hash_with_same_project
Chris@1295 275 c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository)
Chris@1295 276 assert_equal 'commit:7234cb27', c.text_tag(Project.find(1))
Chris@1295 277 end
Chris@1295 278
Chris@1295 279 def test_text_tag_hash_with_different_project
Chris@1295 280 c = Changeset.new(:revision => '7234cb27', :scmid => '7234cb27', :repository => Project.find(1).repository)
Chris@1295 281 assert_equal 'ecookbook:commit:7234cb27', c.text_tag(Project.find(2))
Chris@1295 282 end
Chris@1295 283
Chris@1295 284 def test_text_tag_hash_all_number
Chris@1295 285 c = Changeset.new(:scmid => '0123456789', :revision => '0123456789')
Chris@1295 286 assert_equal 'commit:0123456789', c.text_tag
Chris@1295 287 end
Chris@1295 288
Chris@1295 289 def test_previous
Chris@1295 290 changeset = Changeset.find_by_revision('3')
Chris@1295 291 assert_equal Changeset.find_by_revision('2'), changeset.previous
Chris@1295 292 end
Chris@1295 293
Chris@1295 294 def test_previous_nil
Chris@1295 295 changeset = Changeset.find_by_revision('1')
Chris@1295 296 assert_nil changeset.previous
Chris@1295 297 end
Chris@1295 298
Chris@1295 299 def test_next
Chris@1295 300 changeset = Changeset.find_by_revision('2')
Chris@1295 301 assert_equal Changeset.find_by_revision('3'), changeset.next
Chris@1295 302 end
Chris@1295 303
Chris@1295 304 def test_next_nil
Chris@1295 305 changeset = Changeset.find_by_revision('10')
Chris@1295 306 assert_nil changeset.next
Chris@1295 307 end
Chris@1295 308
Chris@1295 309 def test_comments_should_be_converted_to_utf8
Chris@1295 310 proj = Project.find(3)
Chris@1295 311 # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
Chris@1295 312 str = "Texte encod\xe9 en ISO-8859-1."
Chris@1295 313 str.force_encoding("ASCII-8BIT") if str.respond_to?(:force_encoding)
Chris@1295 314 r = Repository::Bazaar.create!(
Chris@1295 315 :project => proj,
Chris@1295 316 :url => '/tmp/test/bazaar',
Chris@1295 317 :log_encoding => 'ISO-8859-1' )
Chris@1295 318 assert r
Chris@1295 319 c = Changeset.new(:repository => r,
Chris@1295 320 :committed_on => Time.now,
Chris@1295 321 :revision => '123',
Chris@1295 322 :scmid => '12345',
Chris@1295 323 :comments => str)
Chris@1295 324 assert( c.save )
Chris@1295 325 str_utf8 = "Texte encod\xc3\xa9 en ISO-8859-1."
Chris@1295 326 str_utf8.force_encoding("UTF-8") if str_utf8.respond_to?(:force_encoding)
Chris@1295 327 assert_equal str_utf8, c.comments
Chris@1295 328 end
Chris@1295 329
Chris@1295 330 def test_invalid_utf8_sequences_in_comments_should_be_replaced_latin1
Chris@1295 331 proj = Project.find(3)
Chris@1295 332 # str = File.read("#{RAILS_ROOT}/test/fixtures/encoding/iso-8859-1.txt")
Chris@1295 333 str1 = "Texte encod\xe9 en ISO-8859-1."
Chris@1295 334 str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test"
Chris@1295 335 str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding)
Chris@1295 336 str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
Chris@1295 337 r = Repository::Bazaar.create!(
Chris@1295 338 :project => proj,
Chris@1295 339 :url => '/tmp/test/bazaar',
Chris@1295 340 :log_encoding => 'UTF-8' )
Chris@1295 341 assert r
Chris@1295 342 c = Changeset.new(:repository => r,
Chris@1295 343 :committed_on => Time.now,
Chris@1295 344 :revision => '123',
Chris@1295 345 :scmid => '12345',
Chris@1295 346 :comments => str1,
Chris@1295 347 :committer => str2)
Chris@1295 348 assert( c.save )
Chris@1295 349 assert_equal "Texte encod? en ISO-8859-1.", c.comments
Chris@1295 350 assert_equal "?a?b?c?d?e test", c.committer
Chris@1295 351 end
Chris@1295 352
Chris@1295 353 def test_invalid_utf8_sequences_in_comments_should_be_replaced_ja_jis
Chris@1295 354 proj = Project.find(3)
Chris@1295 355 str = "test\xb5\xfetest\xb5\xfe"
Chris@1295 356 if str.respond_to?(:force_encoding)
Chris@1295 357 str.force_encoding('ASCII-8BIT')
Chris@1295 358 end
Chris@1295 359 r = Repository::Bazaar.create!(
Chris@1295 360 :project => proj,
Chris@1295 361 :url => '/tmp/test/bazaar',
Chris@1295 362 :log_encoding => 'ISO-2022-JP' )
Chris@1295 363 assert r
Chris@1295 364 c = Changeset.new(:repository => r,
Chris@1295 365 :committed_on => Time.now,
Chris@1295 366 :revision => '123',
Chris@1295 367 :scmid => '12345',
Chris@1295 368 :comments => str)
Chris@1295 369 assert( c.save )
Chris@1295 370 assert_equal "test??test??", c.comments
Chris@1295 371 end
Chris@1295 372
Chris@1295 373 def test_comments_should_be_converted_all_latin1_to_utf8
Chris@1295 374 s1 = "\xC2\x80"
Chris@1295 375 s2 = "\xc3\x82\xc2\x80"
Chris@1295 376 s4 = s2.dup
Chris@1295 377 if s1.respond_to?(:force_encoding)
Chris@1295 378 s3 = s1.dup
Chris@1295 379 s1.force_encoding('ASCII-8BIT')
Chris@1295 380 s2.force_encoding('ASCII-8BIT')
Chris@1295 381 s3.force_encoding('ISO-8859-1')
Chris@1295 382 s4.force_encoding('UTF-8')
Chris@1295 383 assert_equal s3.encode('UTF-8'), s4
Chris@1295 384 end
Chris@1295 385 proj = Project.find(3)
Chris@1295 386 r = Repository::Bazaar.create!(
Chris@1295 387 :project => proj,
Chris@1295 388 :url => '/tmp/test/bazaar',
Chris@1295 389 :log_encoding => 'ISO-8859-1' )
Chris@1295 390 assert r
Chris@1295 391 c = Changeset.new(:repository => r,
Chris@1295 392 :committed_on => Time.now,
Chris@1295 393 :revision => '123',
Chris@1295 394 :scmid => '12345',
Chris@1295 395 :comments => s1)
Chris@1295 396 assert( c.save )
Chris@1295 397 assert_equal s4, c.comments
Chris@1295 398 end
Chris@1295 399
Chris@1295 400 def test_invalid_utf8_sequences_in_paths_should_be_replaced
Chris@1295 401 proj = Project.find(3)
Chris@1295 402 str1 = "Texte encod\xe9 en ISO-8859-1"
Chris@1295 403 str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test"
Chris@1295 404 str1.force_encoding("UTF-8") if str1.respond_to?(:force_encoding)
Chris@1295 405 str2.force_encoding("ASCII-8BIT") if str2.respond_to?(:force_encoding)
Chris@1295 406 r = Repository::Bazaar.create!(
Chris@1295 407 :project => proj,
Chris@1295 408 :url => '/tmp/test/bazaar',
Chris@1295 409 :log_encoding => 'UTF-8' )
Chris@1295 410 assert r
Chris@1295 411 cs = Changeset.new(
Chris@1295 412 :repository => r,
Chris@1295 413 :committed_on => Time.now,
Chris@1295 414 :revision => '123',
Chris@1295 415 :scmid => '12345',
Chris@1295 416 :comments => "test")
Chris@1295 417 assert(cs.save)
Chris@1295 418 ch = Change.new(
Chris@1295 419 :changeset => cs,
Chris@1295 420 :action => "A",
Chris@1295 421 :path => str1,
Chris@1295 422 :from_path => str2,
Chris@1295 423 :from_revision => "345")
Chris@1295 424 assert(ch.save)
Chris@1295 425 assert_equal "Texte encod? en ISO-8859-1", ch.path
Chris@1295 426 assert_equal "?a?b?c?d?e test", ch.from_path
Chris@1295 427 end
Chris@1295 428
Chris@1295 429 def test_comments_nil
Chris@1295 430 proj = Project.find(3)
Chris@1295 431 r = Repository::Bazaar.create!(
Chris@1295 432 :project => proj,
Chris@1295 433 :url => '/tmp/test/bazaar',
Chris@1295 434 :log_encoding => 'ISO-8859-1' )
Chris@1295 435 assert r
Chris@1295 436 c = Changeset.new(:repository => r,
Chris@1295 437 :committed_on => Time.now,
Chris@1295 438 :revision => '123',
Chris@1295 439 :scmid => '12345',
Chris@1295 440 :comments => nil,
Chris@1295 441 :committer => nil)
Chris@1295 442 assert( c.save )
Chris@1295 443 assert_equal "", c.comments
Chris@1295 444 assert_equal nil, c.committer
Chris@1295 445 if c.comments.respond_to?(:force_encoding)
Chris@1295 446 assert_equal "UTF-8", c.comments.encoding.to_s
Chris@1295 447 end
Chris@1295 448 end
Chris@1295 449
Chris@1295 450 def test_comments_empty
Chris@1295 451 proj = Project.find(3)
Chris@1295 452 r = Repository::Bazaar.create!(
Chris@1295 453 :project => proj,
Chris@1295 454 :url => '/tmp/test/bazaar',
Chris@1295 455 :log_encoding => 'ISO-8859-1' )
Chris@1295 456 assert r
Chris@1295 457 c = Changeset.new(:repository => r,
Chris@1295 458 :committed_on => Time.now,
Chris@1295 459 :revision => '123',
Chris@1295 460 :scmid => '12345',
Chris@1295 461 :comments => "",
Chris@1295 462 :committer => "")
Chris@1295 463 assert( c.save )
Chris@1295 464 assert_equal "", c.comments
Chris@1295 465 assert_equal "", c.committer
Chris@1295 466 if c.comments.respond_to?(:force_encoding)
Chris@1295 467 assert_equal "UTF-8", c.comments.encoding.to_s
Chris@1295 468 assert_equal "UTF-8", c.committer.encoding.to_s
Chris@1295 469 end
Chris@1295 470 end
Chris@1295 471
Chris@1295 472 def test_identifier
Chris@1295 473 c = Changeset.find_by_revision('1')
Chris@1295 474 assert_equal c.revision, c.identifier
Chris@1295 475 end
Chris@1295 476 end