annotate .svn/pristine/45/45db780cec4e0c72778412b47b7cf78b370991c8.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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