mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
Return empty hash when url_options not provided
This commit is contained in:
parent
dd5cdb6ddb
commit
754aa295ba
@ -449,7 +449,7 @@ module ActiveModel
|
|||||||
end
|
end
|
||||||
|
|
||||||
def url_options
|
def url_options
|
||||||
@options[:url_options]
|
@options[:url_options] || {}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a json representation of the serializable
|
# Returns a json representation of the serializable
|
||||||
|
|||||||
@ -143,6 +143,12 @@ class SerializerTest < ActiveModel::TestCase
|
|||||||
assert_equal({ :host => "test.local" }, user_serializer.url_options)
|
assert_equal({ :host => "test.local" }, user_serializer.url_options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_serializer_returns_empty_hash_without_url_options
|
||||||
|
user = User.new
|
||||||
|
user_serializer = UserSerializer.new(user)
|
||||||
|
assert_equal({}, user_serializer.url_options)
|
||||||
|
end
|
||||||
|
|
||||||
def test_pretty_accessors
|
def test_pretty_accessors
|
||||||
user = User.new
|
user = User.new
|
||||||
user.superuser = true
|
user.superuser = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user