aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-02-21 11:09:21 +0100
committerJosé Valim <jose.valim@gmail.com>2010-02-21 11:12:14 +0100
commit250c8092461f5e6bf62751b313f6605a37fd1b2b (patch)
tree7ef84aa83bd41eb023b9d4323d7208bd75d1b994 /activerecord/test/cases/base_test.rb
parent9dd67fce25d3993a0ee494506ba246a45d395e3f (diff)
downloadrails-250c8092461f5e6bf62751b313f6605a37fd1b2b.tar.gz
rails-250c8092461f5e6bf62751b313f6605a37fd1b2b.tar.bz2
rails-250c8092461f5e6bf62751b313f6605a37fd1b2b.zip
Require persisted? in ActiveModel::Lint and remove new_record? and destroyed? methods. ActionPack does not care if the resource is new or if it was destroyed, it cares only if it's persisted somewhere or not.
Diffstat (limited to 'activerecord/test/cases/base_test.rb')
-rwxr-xr-xactiverecord/test/cases/base_test.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 1441b4278d..2c4e1a3c0f 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -1330,11 +1330,6 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_destroyed_returns_boolean
- developer = Developer.new
- assert_equal developer.destroyed?, false
- developer.destroy
- assert_equal developer.destroyed?, true
-
developer = Developer.first
assert_equal developer.destroyed?, false
developer.destroy
@@ -1346,6 +1341,23 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal developer.destroyed?, true
end
+ def test_persisted_returns_boolean
+ developer = Developer.new(:name => "Jose")
+ assert_equal developer.persisted?, false
+ developer.save!
+ assert_equal developer.persisted?, true
+
+ developer = Developer.first
+ assert_equal developer.persisted?, true
+ developer.destroy
+ assert_equal developer.persisted?, false
+
+ developer = Developer.last
+ assert_equal developer.persisted?, true
+ developer.delete
+ assert_equal developer.persisted?, false
+ end
+
def test_clone
topic = Topic.find(1)
cloned_topic = nil