Skip to content
This repository
Browse code

Merge pull request #5558 from carlosantoniodasilva/fix-build-3-2

Fix build for branch 3-2-stable - Part 2
  • Loading branch information...
commit ef48cea16920a50b772eebdde1c364144380df05 2 parents ea4e021 + 0879ebd
Piotr Sarnacki authored March 23, 2012
32  activerecord/test/cases/identity_map_test.rb
@@ -301,20 +301,20 @@ def test_eager_loading_with_conditions_on_joined_table_preloads
301 301
     posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
302 302
     assert_equal [posts(:welcome)], posts
303 303
     assert_equal authors(:david), assert_no_queries { posts[0].author}
304  
-    assert_same posts.first.author, Author.first
  304
+    assert_same posts.first.author, Author.order(:id).first
305 305
 
306 306
     posts = Post.find(:all, :select => 'distinct posts.*', :include => :author, :joins => [:comments], :conditions => "comments.body like 'Thank you%'", :order => 'posts.id')
307 307
     assert_equal [posts(:welcome)], posts
308 308
     assert_equal authors(:david), assert_no_queries { posts[0].author}
309  
-    assert_same posts.first.author, Author.first
  309
+    assert_same posts.first.author, Author.order(:id).first
310 310
 
311 311
     posts = Post.find(:all, :include => :author, :joins => {:taggings => :tag}, :conditions => "tags.name = 'General'", :order => 'posts.id')
312 312
     assert_equal posts(:welcome, :thinking), posts
313  
-    assert_same posts.first.author, Author.first
  313
+    assert_same posts.first.author, Author.order(:id).first
314 314
 
315 315
     posts = Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
316 316
     assert_equal posts(:welcome, :thinking), posts
317  
-    assert_same posts.first.author, Author.first
  317
+    assert_same posts.first.author, Author.order(:id).first
318 318
   end
319 319
 
320 320
   def test_eager_loading_with_conditions_on_string_joined_table_preloads
@@ -336,12 +336,12 @@ def test_eager_loading_with_conditions_on_string_joined_table_preloads
336 336
   ##############################################################################
337 337
 
338 338
   def test_reload_object_if_save_failed
339  
-    developer = Developer.first
  339
+    developer = Developer.order(:id).first
340 340
     developer.salary = 0
341 341
 
342 342
     assert !developer.save
343 343
 
344  
-    same_developer = Developer.first
  344
+    same_developer = Developer.order(:id).first
345 345
 
346 346
     assert_not_same  developer, same_developer
347 347
     assert_not_equal 0, same_developer.salary
@@ -349,12 +349,12 @@ def test_reload_object_if_save_failed
349 349
   end
350 350
 
351 351
   def test_reload_object_if_forced_save_failed
352  
-    developer = Developer.first
  352
+    developer = Developer.order(:id).first
353 353
     developer.salary = 0
354 354
 
355 355
     assert_raise(ActiveRecord::RecordInvalid) { developer.save! }
356 356
 
357  
-    same_developer = Developer.first
  357
+    same_developer = Developer.order(:id).first
358 358
 
359 359
     assert_not_same  developer, same_developer
360 360
     assert_not_equal 0, same_developer.salary
@@ -362,12 +362,12 @@ def test_reload_object_if_forced_save_failed
362 362
   end
363 363
 
364 364
   def test_reload_object_if_update_attributes_fails
365  
-    developer = Developer.first
  365
+    developer = Developer.order(:id).first
366 366
     developer.salary = 0
367 367
 
368 368
     assert !developer.update_attributes(:salary => 0)
369 369
 
370  
-    same_developer = Developer.first
  370
+    same_developer = Developer.order(:id).first
371 371
 
372 372
     assert_not_same  developer, same_developer
373 373
     assert_not_equal 0, same_developer.salary
@@ -379,10 +379,10 @@ def test_reload_object_if_update_attributes_fails
379 379
   ##############################################################################
380 380
 
381 381
   def test_find_using_identity_map_respects_readonly_when_loading_associated_object_first
382  
-    author  = Author.first
  382
+    author  = Author.order(:id).first
383 383
     readonly_comment = author.readonly_comments.first
384 384
 
385  
-    comment = Comment.first
  385
+    comment = Comment.order(:id).first
386 386
     assert !comment.readonly?
387 387
 
388 388
     assert readonly_comment.readonly?
@@ -392,10 +392,10 @@ def test_find_using_identity_map_respects_readonly_when_loading_associated_objec
392 392
   end
393 393
 
394 394
   def test_find_using_identity_map_respects_readonly
395  
-    comment = Comment.first
  395
+    comment = Comment.order(:id).first
396 396
     assert !comment.readonly?
397 397
 
398  
-    author  = Author.first
  398
+    author  = Author.order(:id).first
399 399
     readonly_comment = author.readonly_comments.first
400 400
 
401 401
     assert readonly_comment.readonly?
@@ -405,13 +405,13 @@ def test_find_using_identity_map_respects_readonly
405 405
   end
406 406
 
407 407
   def test_find_using_select_and_identity_map
408  
-    author_id, author = Author.select('id').first, Author.first
  408
+    author_id, author = Author.select('id').order(:id).first, Author.order(:id).first
409 409
 
410 410
     assert_equal author_id, author
411 411
     assert_same author_id, author
412 412
     assert_not_nil author.name
413 413
 
414  
-    post, post_id = Post.first, Post.select('id').first
  414
+    post, post_id = Post.order(:id).first, Post.select('id').order(:id).first
415 415
 
416 416
     assert_equal post_id, post
417 417
     assert_same post_id, post

0 notes on commit ef48cea

Please sign in to comment.
Something went wrong with that request. Please try again.