aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/attribute_methods_test.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-07-30 00:07:10 -0500
committerJoshua Peek <josh@joshpeek.com>2009-07-30 17:54:00 -0500
commit3e58f8e19117346ce459b7531379525d3143608a (patch)
treea4a882b7dbb5fa79b677bdd1cc77f16e2e929de4 /activerecord/test/cases/attribute_methods_test.rb
parente129c5673a99a09ae64759dafbe907aade16cf2b (diff)
downloadrails-3e58f8e19117346ce459b7531379525d3143608a.tar.gz
rails-3e58f8e19117346ce459b7531379525d3143608a.tar.bz2
rails-3e58f8e19117346ce459b7531379525d3143608a.zip
Restore DangerousAttributeError
Diffstat (limited to 'activerecord/test/cases/attribute_methods_test.rb')
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 77e406bbba..183be1e2f9 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -74,6 +74,10 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
+ def test_primary_key_implemented
+ assert Class.new(ActiveRecord::Base).instance_method_already_implemented?('id')
+ end
+
def test_defined_kernel_methods_implemented_in_model
%w(test name display y).each do |method|
klass = Class.new ActiveRecord::Base
@@ -92,6 +96,16 @@ class AttributeMethodsTest < ActiveRecord::TestCase
end
end
+ def test_raises_dangerous_attribute_error_when_defining_activerecord_method_in_model
+ %w(save create_or_update).each do |method|
+ klass = Class.new ActiveRecord::Base
+ klass.class_eval "def #{method}() 'defined #{method}' end"
+ assert_raise ActiveRecord::DangerousAttributeError do
+ klass.instance_method_already_implemented?(method)
+ end
+ end
+ end
+
def test_only_time_related_columns_are_meant_to_be_cached_by_default
expected = %w(datetime timestamp time date).sort
assert_equal expected, ActiveRecord::Base.attribute_types_cached_by_default.map(&:to_s).sort