File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -156,7 +156,9 @@ def with_headers(headers)
156156 #
157157 # @return [Hash] Headers
158158 def custom_headers
159- _header_store . to_h
159+ return _header_store . to_h if superclass == Object
160+
161+ superclass . custom_headers . merge ( _header_store . to_h )
160162 end
161163
162164 # Returns the requestor for this resource class
Original file line number Diff line number Diff line change @@ -59,6 +59,24 @@ def test_class_method_headers
5959 end
6060 end
6161
62+ def test_custom_headers_are_inherited
63+ stub_request ( :get , "http://example.com/custom_header_resources/1" )
64+ . with ( headers : { "X-My-Header" => "asdf" } )
65+ . to_return ( headers : { content_type : "application/vnd.api+json" } , body : {
66+ data : {
67+ type : "custom_header_resources" ,
68+ id : "1" ,
69+ attributes : {
70+ title : "Rails is Omakase"
71+ }
72+ }
73+ } . to_json )
74+
75+ JsonApiClient ::Resource . with_headers ( x_my_header : "asdf" ) do
76+ CustomHeaderResource . find ( 1 )
77+ end
78+ end
79+
6280 def test_multiple_threads
6381 thread_count = 10
6482
You can’t perform that action at this time.
0 commit comments