Postgresql 8.3 compatibility fix (#834).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1363 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2008-04-26 17:56:26 +00:00
parent 64474802f9
commit ffbdc6b25b
6 changed files with 18 additions and 14 deletions

View File

@ -35,6 +35,10 @@ class Changeset < ActiveRecord::Base
validates_uniqueness_of :revision, :scope => :repository_id
validates_uniqueness_of :scmid, :scope => :repository_id, :allow_nil => true
def revision=(r)
write_attribute :revision, (r.nil? ? nil : r.to_s)
end
def comments=(comment)
write_attribute(:comments, comment.strip)
end

View File

@ -41,22 +41,22 @@ class ChangesetTest < Test::Unit::TestCase
end
def test_previous
changeset = Changeset.find_by_revision(3)
assert_equal Changeset.find_by_revision(2), changeset.previous
changeset = Changeset.find_by_revision('3')
assert_equal Changeset.find_by_revision('2'), changeset.previous
end
def test_previous_nil
changeset = Changeset.find_by_revision(1)
changeset = Changeset.find_by_revision('1')
assert_nil changeset.previous
end
def test_next
changeset = Changeset.find_by_revision(2)
assert_equal Changeset.find_by_revision(3), changeset.next
changeset = Changeset.find_by_revision('2')
assert_equal Changeset.find_by_revision('3'), changeset.next
end
def test_next_nil
changeset = Changeset.find_by_revision(4)
changeset = Changeset.find_by_revision('4')
assert_nil changeset.next
end
end

View File

@ -36,13 +36,13 @@ class RepositoryBazaarTest < Test::Unit::TestCase
assert_equal 4, @repository.changesets.count
assert_equal 9, @repository.changes.count
assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments
assert_equal 'Initial import', @repository.changesets.find_by_revision('1').comments
end
def test_fetch_changesets_incremental
@repository.fetch_changesets
# Remove changesets with revision > 5
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
@repository.reload
assert_equal 2, @repository.changesets.count

View File

@ -35,13 +35,13 @@ class RepositoryDarcsTest < Test::Unit::TestCase
assert_equal 6, @repository.changesets.count
assert_equal 13, @repository.changes.count
assert_equal "Initial commit.", @repository.changesets.find_by_revision(1).comments
assert_equal "Initial commit.", @repository.changesets.find_by_revision('1').comments
end
def test_fetch_changesets_incremental
@repository.fetch_changesets
# Remove changesets with revision > 3
@repository.changesets.find(:all, :conditions => 'revision > 3').each(&:destroy)
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 3}
@repository.reload
assert_equal 3, @repository.changesets.count

View File

@ -35,13 +35,13 @@ class RepositoryMercurialTest < Test::Unit::TestCase
assert_equal 6, @repository.changesets.count
assert_equal 11, @repository.changes.count
assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision(0).comments
assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find_by_revision('0').comments
end
def test_fetch_changesets_incremental
@repository.fetch_changesets
# Remove changesets with revision > 2
@repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy)
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 2}
@repository.reload
assert_equal 3, @repository.changesets.count

View File

@ -35,13 +35,13 @@ class RepositorySubversionTest < Test::Unit::TestCase
assert_equal 8, @repository.changesets.count
assert_equal 16, @repository.changes.count
assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments
assert_equal 'Initial import.', @repository.changesets.find_by_revision('1').comments
end
def test_fetch_changesets_incremental
@repository.fetch_changesets
# Remove changesets with revision > 5
@repository.changesets.find(:all, :conditions => 'revision > 5').each(&:destroy)
@repository.changesets.find(:all).each {|c| c.destroy if c.revision.to_i > 5}
@repository.reload
assert_equal 5, @repository.changesets.count