diff options
-rw-r--r-- | activemodel/test/cases/serializers/json_serialization_test.rb | 17 | ||||
-rw-r--r-- | activemodel/test/cases/serializers/xml_serialization_test.rb | 12 | ||||
-rw-r--r-- | activemodel/test/models/contact.rb | 15 |
3 files changed, 15 insertions, 29 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index 734656b749..e2eb91eeb0 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -2,23 +2,6 @@ require 'cases/helper' require 'models/contact' require 'active_support/core_ext/object/instance_variables' -class Contact - include ActiveModel::Serializers::JSON - include ActiveModel::Validations - - def attributes=(hash) - hash.each do |k, v| - instance_variable_set("@#{k}", v) - end - end - - remove_method :attributes if method_defined?(:attributes) - - def attributes - instance_values - end -end - class JsonSerializationTest < ActiveModel::TestCase def setup @contact = Contact.new diff --git a/activemodel/test/cases/serializers/xml_serialization_test.rb b/activemodel/test/cases/serializers/xml_serialization_test.rb index 5db14c8157..22fca5bd17 100644 --- a/activemodel/test/cases/serializers/xml_serialization_test.rb +++ b/activemodel/test/cases/serializers/xml_serialization_test.rb @@ -3,18 +3,6 @@ require 'models/contact' require 'active_support/core_ext/object/instance_variables' require 'ostruct' -class Contact - include ActiveModel::Serializers::Xml - - attr_accessor :address, :friends, :contact - - remove_method :attributes if method_defined?(:attributes) - - def attributes - instance_values.except("address", "friends", "contact") - end -end - module Admin class Contact < ::Contact end diff --git a/activemodel/test/models/contact.rb b/activemodel/test/models/contact.rb index c25be28e1d..bcfd267a34 100644 --- a/activemodel/test/models/contact.rb +++ b/activemodel/test/models/contact.rb @@ -1,8 +1,13 @@ class Contact extend ActiveModel::Naming include ActiveModel::Conversion + include ActiveModel::Validations + + include ActiveModel::Serializers::JSON + include ActiveModel::Serializers::Xml attr_accessor :id, :name, :age, :created_at, :awesome, :preferences + attr_accessor :address, :friends, :contact def social %w(twitter github) @@ -23,4 +28,14 @@ class Contact def persisted? id end + + def attributes=(hash) + hash.each do |k, v| + instance_variable_set("@#{k}", v) + end + end + + def attributes + instance_values.except("address", "friends", "contact") + end end |