File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed
lib/active_model_serializers
test/active_model_serializers Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ Features:
12
12
Fixes:
13
13
14
14
- [ #1833 ] ( https://github.com/rails-api/active_model_serializers/pull/1833 ) Remove relationship links if they are null (@groyoh )
15
+ - [ #1881 ] ( https://github.com/rails-api/active_model_serializers/pull/1881 ) ActiveModelSerializers::Model correctly works with string keys (@yevhene )
15
16
16
17
Misc:
17
18
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Model
9
9
attr_reader :attributes , :errors
10
10
11
11
def initialize ( attributes = { } )
12
- @attributes = attributes
12
+ @attributes = attributes && attributes . symbolize_keys
13
13
@errors = ActiveModel ::Errors . new ( self )
14
14
super
15
15
end
Original file line number Diff line number Diff line change @@ -7,5 +7,16 @@ class ModelTest < ActiveSupport::TestCase
7
7
def setup
8
8
@resource = ActiveModelSerializers ::Model . new
9
9
end
10
+
11
+ def test_initialization_with_string_keys
12
+ klass = Class . new ( ActiveModelSerializers ::Model ) do
13
+ attr_accessor :key
14
+ end
15
+ value = 'value'
16
+
17
+ model_instance = klass . new ( 'key' => value )
18
+
19
+ assert_equal model_instance . read_attribute_for_serialization ( :key ) , value
20
+ end
10
21
end
11
22
end
You can’t perform that action at this time.
0 commit comments