diff --git a/test/serializer/attributes_test.rb b/test/unit/active_model/serializer/attributes_test.rb similarity index 69% rename from test/serializer/attributes_test.rb rename to test/unit/active_model/serializer/attributes_test.rb index bff76e41..0d4469aa 100644 --- a/test/serializer/attributes_test.rb +++ b/test/unit/active_model/serializer/attributes_test.rb @@ -1,23 +1,23 @@ require 'newbase/test_helper' require 'newbase/active_model/serializer' -module SerializerTest - module Attributes - class Model - def initialize(hash={}) - @attributes = hash +module ActiveModel + class Serializer + class AttributesTest < ActiveModel::TestCase + class Model + def initialize(hash={}) + @attributes = hash + end + + def read_attribute_for_serialization(name) + @attributes[name] + end end - def read_attribute_for_serialization(name) - @attributes[name] + class ModelSerializer < ActiveModel::Serializer + attributes :attr1, :attr2 end - end - class ModelSerializer < ActiveModel::Serializer - attributes :attr1, :attr2 - end - - class Test < ActiveModel::TestCase def setup model = Model.new({ :attr1 => 'value1', :attr2 => 'value2', :attr3 => 'value3' }) @model_serializer = ModelSerializer.new(model) diff --git a/test/serializer/root_test.rb b/test/unit/active_model/serializer/root_test.rb similarity index 86% rename from test/serializer/root_test.rb rename to test/unit/active_model/serializer/root_test.rb index 74a3cc37..36944aab 100644 --- a/test/serializer/root_test.rb +++ b/test/unit/active_model/serializer/root_test.rb @@ -1,19 +1,19 @@ require 'newbase/test_helper' require 'newbase/active_model/serializer' -module SerializerTest - module Root - class Model - def initialize(hash={}) - @attributes = hash - end - - def read_attribute_for_serialization(name) - @attributes[name] - end - end - +module ActiveModel + class Serializer class RootAsOptionTest < ActiveModel::TestCase + class Model + def initialize(hash={}) + @attributes = hash + end + + def read_attribute_for_serialization(name) + @attributes[name] + end + end + class ModelSerializer < ActiveModel::Serializer attributes :attr1, :attr2 end @@ -58,6 +58,16 @@ module SerializerTest end class RootInSerializerTest < ActiveModel::TestCase + class Model + def initialize(hash={}) + @attributes = hash + end + + def read_attribute_for_serialization(name) + @attributes[name] + end + end + class ModelSerializer < ActiveModel::Serializer root :in_serializer attributes :attr1, :attr2 diff --git a/test/serializer/scope_test.rb b/test/unit/active_model/serializer/scope_test.rb similarity index 52% rename from test/serializer/scope_test.rb rename to test/unit/active_model/serializer/scope_test.rb index 95e16ff8..52c1655e 100644 --- a/test/serializer/scope_test.rb +++ b/test/unit/active_model/serializer/scope_test.rb @@ -1,22 +1,22 @@ require 'newbase/test_helper' require 'newbase/active_model/serializer' -module SerializerTest - module Scope - class Model - def initialize(hash={}) - @attributes = hash +module ActiveModel + class Serializer + class ScopeTest < ActiveModel::TestCase + class Model + def initialize(hash={}) + @attributes = hash + end + + def read_attribute_for_serialization(name) + @attributes[name] + end end - def read_attribute_for_serialization(name) - @attributes[name] + class ModelSerializer < ActiveModel::Serializer end - end - class ModelSerializer < ActiveModel::Serializer - end - - class Test < ActiveModel::TestCase def setup @serializer = ModelSerializer.new(nil, scope: current_user) end