aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-23 02:14:42 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-03-23 02:21:49 -0300
commit0879ebdf36a2d7322de7d6c2ee00c2cb129534d3 (patch)
tree8e5d84ab22f43efd3262f3d0348a3b32b4fe60c9 /activerecord/test
parentea4e021dceea10ba1b98ac9b33e36cabf735ce82 (diff)
downloadrails-0879ebdf36a2d7322de7d6c2ee00c2cb129534d3.tar.gz
rails-0879ebdf36a2d7322de7d6c2ee00c2cb129534d3.tar.bz2
rails-0879ebdf36a2d7322de7d6c2ee00c2cb129534d3.zip
Fix identity map tests
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/identity_map_test.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb
index 3efc8bf559..24132c7617 100644
--- a/activerecord/test/cases/identity_map_test.rb
+++ b/activerecord/test/cases/identity_map_test.rb
@@ -301,20 +301,20 @@ class IdentityMapTest < ActiveRecord::TestCase
posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
posts = Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
assert_equal posts(:welcome, :thinking), posts
- assert_same posts.first.author, Author.first
+ assert_same posts.first.author, Author.order(:id).first
end
def test_eager_loading_with_conditions_on_string_joined_table_preloads
@@ -336,12 +336,12 @@ class IdentityMapTest < ActiveRecord::TestCase
##############################################################################
def test_reload_object_if_save_failed
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert !developer.save
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
@@ -349,12 +349,12 @@ class IdentityMapTest < ActiveRecord::TestCase
end
def test_reload_object_if_forced_save_failed
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert_raise(ActiveRecord::RecordInvalid) { developer.save! }
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
@@ -362,12 +362,12 @@ class IdentityMapTest < ActiveRecord::TestCase
end
def test_reload_object_if_update_attributes_fails
- developer = Developer.first
+ developer = Developer.order(:id).first
developer.salary = 0
assert !developer.update_attributes(:salary => 0)
- same_developer = Developer.first
+ same_developer = Developer.order(:id).first
assert_not_same developer, same_developer
assert_not_equal 0, same_developer.salary
@@ -379,10 +379,10 @@ class IdentityMapTest < ActiveRecord::TestCase
##############################################################################
def test_find_using_identity_map_respects_readonly_when_loading_associated_object_first
- author = Author.first
+ author = Author.order(:id).first
readonly_comment = author.readonly_comments.first
- comment = Comment.first
+ comment = Comment.order(:id).first
assert !comment.readonly?
assert readonly_comment.readonly?
@@ -392,10 +392,10 @@ class IdentityMapTest < ActiveRecord::TestCase
end
def test_find_using_identity_map_respects_readonly
- comment = Comment.first
+ comment = Comment.order(:id).first
assert !comment.readonly?
- author = Author.first
+ author = Author.order(:id).first
readonly_comment = author.readonly_comments.first
assert readonly_comment.readonly?
@@ -405,13 +405,13 @@ class IdentityMapTest < ActiveRecord::TestCase
end
def test_find_using_select_and_identity_map
- author_id, author = Author.select('id').first, Author.first
+ author_id, author = Author.select('id').order(:id).first, Author.order(:id).first
assert_equal author_id, author
assert_same author_id, author
assert_not_nil author.name
- post, post_id = Post.first, Post.select('id').first
+ post, post_id = Post.order(:id).first, Post.select('id').order(:id).first
assert_equal post_id, post
assert_same post_id, post