Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test/serializer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def test_attributes_method_with_unsymbolizable_key
}, hash)
end

def test_attributes_method_with_string_args
user = User.new
user_serializer = UserAttributesDefinedByStringsSerializer.new(user, scope: {})

hash = user_serializer.as_json

assert_equal({
user_attributes_defined_by_strings: { first_name: "Jose", :last_name => "Valim" }
}, hash)
end

def test_attribute_method_with_name_as_serializer_prefix
object = SomeObject.new("something")
object_serializer = SomeSerializer.new(object, {})
Expand Down
4 changes: 4 additions & 0 deletions test/test_fakes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def serializable_hash
end
end

class UserAttributesDefinedByStringsSerializer < ActiveModel::Serializer
attributes 'first_name', 'last_name'
end

class DefaultUserSerializer < ActiveModel::Serializer
attributes :first_name, :last_name
end
Expand Down