aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/relations_test.rb
diff options
context:
space:
mode:
authorDavid Chelimsky <dchelimsky@gmail.com>2010-11-07 08:05:18 -0600
committerSantiago Pastorino <santiago@wyeworks.com>2010-11-09 13:54:04 -0200
commit1f06652a57e727700c3a673dc1f86e3b1e07ce1f (patch)
tree6ab5165939c2fcae615bd586ea0254e352f6715a /activerecord/test/cases/relations_test.rb
parentf57b5197b3215d9dd66196e960ef5d78b7a62de1 (diff)
downloadrails-1f06652a57e727700c3a673dc1f86e3b1e07ce1f.tar.gz
rails-1f06652a57e727700c3a673dc1f86e3b1e07ce1f.tar.bz2
rails-1f06652a57e727700c3a673dc1f86e3b1e07ce1f.zip
use persisted? instead of new_record? wherever possible
- persisted? is the API defined in ActiveModel - makes it easier for extension libraries to conform to ActiveModel APIs without concern for whether the extended object is specifically ActiveRecord [#5927 state:committed] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord/test/cases/relations_test.rb')
-rw-r--r--activerecord/test/cases/relations_test.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 0fd2b99937..b44c716db8 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -383,7 +383,7 @@ class RelationTest < ActiveRecord::TestCase
lifo = authors.find_or_initialize_by_name('Lifo')
assert_equal "Lifo", lifo.name
- assert lifo.new_record?
+ assert !lifo.persisted?
assert_equal authors(:david), authors.find_or_initialize_by_name(:name => 'David')
end
@@ -393,7 +393,7 @@ class RelationTest < ActiveRecord::TestCase
lifo = authors.find_or_create_by_name('Lifo')
assert_equal "Lifo", lifo.name
- assert ! lifo.new_record?
+ assert lifo.persisted?
assert_equal authors(:david), authors.find_or_create_by_name(:name => 'David')
end
@@ -627,10 +627,10 @@ class RelationTest < ActiveRecord::TestCase
sparrow = birds.create
assert_kind_of Bird, sparrow
- assert sparrow.new_record?
+ assert !sparrow.persisted?
hen = birds.where(:name => 'hen').create
- assert ! hen.new_record?
+ assert hen.persisted?
assert_equal 'hen', hen.name
end
@@ -641,7 +641,7 @@ class RelationTest < ActiveRecord::TestCase
hen = birds.where(:name => 'hen').create!
assert_kind_of Bird, hen
- assert ! hen.new_record?
+ assert hen.persisted?
assert_equal 'hen', hen.name
end