mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
Tests refactor
This commit is contained in:
parent
b6f9c5ee43
commit
45453f638b
@ -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)
|
||||
@ -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
|
||||
@ -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
|
||||
Loading…
Reference in New Issue
Block a user