File tree Expand file tree Collapse file tree 5 files changed +9
-5
lines changed Expand file tree Collapse file tree 5 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ Gem::Specification.new do |s|
2020
2121 s . add_development_dependency "webmock" , '~> 3.5.1'
2222 s . add_development_dependency "mocha"
23+ s . add_development_dependency "pry"
2324
2425 s . license = "MIT"
2526
Original file line number Diff line number Diff line change @@ -67,11 +67,11 @@ def last
6767 end
6868
6969 def build ( attrs = { } )
70- klass . new @path_params . merge ( attrs . symbolize_keys )
70+ klass . new @path_params . merge ( attrs . with_indifferent_access )
7171 end
7272
7373 def create ( attrs = { } )
74- klass . create @path_params . merge ( attrs . symbolize_keys )
74+ klass . create @path_params . merge ( attrs . with_indifferent_access )
7575 end
7676
7777 def params
Original file line number Diff line number Diff line change @@ -152,6 +152,7 @@ def path(params = nil)
152152 parts = [ resource_path ]
153153 if params && _prefix_path . present?
154154 path_params = params . delete ( :path ) || params
155+
155156 parts . unshift ( _set_prefix_path ( path_params . symbolize_keys ) )
156157 else
157158 parts . unshift ( _prefix_path )
@@ -348,7 +349,7 @@ def _build_connection(rebuild = false)
348349 #
349350 # @param params [Hash] Attributes, links, and relationships
350351 def initialize ( params = { } )
351- params = params . symbolize_keys
352+ params = params . with_indifferent_access
352353 @persisted = nil
353354 @destroyed = nil
354355 self . links = self . class . linker . new ( params . delete ( :links ) || { } )
@@ -538,7 +539,7 @@ def reset_request_select!(*resource_types)
538539 end
539540
540541 def path_attributes
541- _belongs_to_params . merge attributes . slice ( self . class . primary_key ) . symbolize_keys
542+ _belongs_to_params . merge attributes . slice ( self . class . primary_key ) . with_indifferent_access
542543 end
543544
544545 protected
Original file line number Diff line number Diff line change 55require 'webmock/minitest'
66require 'mocha/minitest'
77require 'pp'
8+ require 'pry'
89
910# shim for ActiveSupport 4.0.x requiring minitest 4.2
1011unless defined? ( Minitest ::Test )
Original file line number Diff line number Diff line change @@ -308,7 +308,8 @@ def test_build_propagate_only_path_params
308308 query = ArticleNested . where ( author_id : '123' , name : 'John' )
309309 record = query . build
310310 assert_equal [ ] , record . changed
311- assert_equal ( { author_id : '123' } , record . __belongs_to_params )
311+ assert_equal ( record . __belongs_to_params [ :author_id ] , '123' )
312+ assert_equal ( record . __belongs_to_params [ 'author_id' ] , '123' )
312313 assert_equal '123' , record . author_id
313314 assert_equal [ ] , record . relationships . changed
314315 end
You can’t perform that action at this time.
0 commit comments