Permalink
Browse files

Fix relation tests for postgres

  • Loading branch information...
1 parent 51a1d5a commit 630dc5073075ba73251400400caae802f8d97d41 @lifo lifo committed Dec 27, 2009
Showing with 9 additions and 8 deletions.
  1. +9 −8 activerecord/test/cases/relations_test.rb
@@ -38,7 +38,7 @@ def test_loaded_all
end
def test_scoped_first
- topics = Topic.scoped
+ topics = Topic.scoped.order('id ASC')
assert_queries(1) do
2.times { assert_equal "The First Topic", topics.first.title }
@@ -48,7 +48,7 @@ def test_scoped_first
end
def test_loaded_first
- topics = Topic.scoped
+ topics = Topic.scoped.order('id ASC')
assert_queries(1) do
topics.all # force load
@@ -244,7 +244,7 @@ def test_dynamic_find_by_attributes_bang
author = Author.scoped.find_by_id!(authors(:david).id)
assert_equal "David", author.name
- assert_raises(ActiveRecord::RecordNotFound) { Author.scoped.find_by_id_and_name!('invalid', 'wt') }
+ assert_raises(ActiveRecord::RecordNotFound) { Author.scoped.find_by_id_and_name!(20, 'invalid') }
end
def test_dynamic_find_all_by_attributes
@@ -281,7 +281,7 @@ def test_find_id
david = authors.find(authors(:david).id)
assert_equal 'David', david.name
- assert_raises(ActiveRecord::RecordNotFound) { authors.where(:name => 'lifo').find('invalid') }
+ assert_raises(ActiveRecord::RecordNotFound) { authors.where(:name => 'lifo').find('42') }
end
def test_find_ids
@@ -294,16 +294,17 @@ def test_find_ids
assert_equal 'Mary', results[1].name
assert_equal results, authors.find([authors(:david).id, authors(:mary).id])
- assert_raises(ActiveRecord::RecordNotFound) { authors.where(:name => 'lifo').find(authors(:david).id, 'invalid') }
- assert_raises(ActiveRecord::RecordNotFound) { authors.find(['invalid', 'oops']) }
+ assert_raises(ActiveRecord::RecordNotFound) { authors.where(:name => 'lifo').find(authors(:david).id, '42') }
+ assert_raises(ActiveRecord::RecordNotFound) { authors.find(['42', 43]) }
end
def test_exists
davids = Author.where(:name => 'David')
assert davids.exists?
assert davids.exists?(authors(:david).id)
assert ! davids.exists?(authors(:mary).id)
- assert ! davids.exists?("hax'id")
+ assert ! davids.exists?("42")
+ assert ! davids.exists?(42)
fake = Author.where(:name => 'fake author')
assert ! fake.exists?
@@ -332,7 +333,7 @@ def test_relation_merging
devs = Developer.where("salary >= 80000") & Developer.limit(2) & Developer.order('id ASC').where("id < 3")
assert_equal [developers(:david), developers(:jamis)], devs.to_a
- dev_with_count = Developer.limit(1) & Developer.order('id DESC') & Developer.select('developers.*').group('id')
+ dev_with_count = Developer.limit(1) & Developer.order('id DESC') & Developer.select('developers.*')
assert_equal [developers(:poor_jamis)], dev_with_count.to_a
end

0 comments on commit 630dc50

Please sign in to comment.