summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-26 17:56:26 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-04-26 17:56:26 +0000
commitffbdc6b25bdce8abe83ee165b7a2ad6c7171f74b (patch)
tree0895aca8eab46a283069ddbb252b29a9dd5fb58e
parent64474802f9dd6ad97aaf00e795fa1489c0af0042 (diff)
downloadredmine-ffbdc6b25bdce8abe83ee165b7a2ad6c7171f74b.tar.gz
redmine-ffbdc6b25bdce8abe83ee165b7a2ad6c7171f74b.zip
Postgresql 8.3 compatibility fix (#834).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1363 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--app/models/changeset.rb4
-rw-r--r--test/unit/changeset_test.rb12
-rw-r--r--test/unit/repository_bazaar_test.rb4
-rw-r--r--test/unit/repository_darcs_test.rb4
-rw-r--r--test/unit/repository_mercurial_test.rb4
-rw-r--r--test/unit/repository_subversion_test.rb4
6 files changed, 18 insertions, 14 deletions
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index ce9ea28ca..3e95ce111 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -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
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb
index 2442a8b8c..bbfe6952d 100644
--- a/test/unit/changeset_test.rb
+++ b/test/unit/changeset_test.rb
@@ -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
diff --git a/test/unit/repository_bazaar_test.rb b/test/unit/repository_bazaar_test.rb
index 15fcc8672..b7a3cf98e 100644
--- a/test/unit/repository_bazaar_test.rb
+++ b/test/unit/repository_bazaar_test.rb
@@ -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
diff --git a/test/unit/repository_darcs_test.rb b/test/unit/repository_darcs_test.rb
index 1228976f1..1c8c1b8dd 100644
--- a/test/unit/repository_darcs_test.rb
+++ b/test/unit/repository_darcs_test.rb
@@ -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
diff --git a/test/unit/repository_mercurial_test.rb b/test/unit/repository_mercurial_test.rb
index e6cfdf9b2..21ddf1e3a 100644
--- a/test/unit/repository_mercurial_test.rb
+++ b/test/unit/repository_mercurial_test.rb
@@ -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
diff --git a/test/unit/repository_subversion_test.rb b/test/unit/repository_subversion_test.rb
index 879feece8..7a1c9df4a 100644
--- a/test/unit/repository_subversion_test.rb
+++ b/test/unit/repository_subversion_test.rb
@@ -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