1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure we always define attribute methods

This commit is contained in:
Sean Griffin 2014-06-13 10:52:39 -06:00
parent 1c41d3b982
commit 6ea1481d69
2 changed files with 9 additions and 0 deletions

View file

@ -259,6 +259,7 @@ module ActiveRecord
init_internals
initialize_internals_callback
self.class.define_attribute_methods
# +options+ argument is only needed to make protected_attributes gem easier to hook.
# Remove it when we drop support to this gem.
init_attributes(attributes, options) if attributes

View file

@ -69,6 +69,14 @@ class SerializationTest < ActiveRecord::TestCase
ActiveRecord::Base.include_root_in_json = original_root_in_json
end
def test_read_attribute_for_serialization_with_format_without_method_missing
klazz = Class.new(ActiveRecord::Base)
klazz.table_name = 'books'
book = klazz.new
assert_nil book.read_attribute_for_serialization(:format)
end
def test_read_attribute_for_serialization_with_format_after_init
klazz = Class.new(ActiveRecord::Base)
klazz.table_name = 'books'