Skip to content

Commit

Permalink
fix rubocop; start new testing pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Sep 11, 2016
1 parent 65c05ae commit 4485072
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
1 change: 0 additions & 1 deletion lib/active_model_serializers/lookup_chain.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module ActiveModelSerializers
module LookupChain

# Standard appending of Serializer to the resource name.
#
# Example:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require 'test_helper'

describe 'feature' do
describe 'configuration' do
describe 'serializer lookup' do
describe 'using SerializableResource' do
it 'uses the child serializer' do
class Parent < ::Model; end
class Child < ::Model; end

class ParentSerializer < ActiveModel::Serializer
class ChildSerializer < ActiveModel::Serializer
attributes :name, :child_attr
def child_attr
true
end
end

attributes :name
belongs_to :child
end

parent = Parent.new(name: 'parent', child: Child.new(name: 'child'))
resource = ActiveModelSerializers::SerializableResource.new(
parent,
adapter: :attributes
)

expected = {
name: 'parent',
child: {
name: 'child',
child_attr: true
}
}

assert_equal expected, resource.serializable_hash
end
end
end
end
end

0 comments on commit 4485072

Please sign in to comment.