File tree 2 files changed +21
-1
lines changed
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)
156
156
#
157
157
# @return [Hash] Headers
158
158
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 )
160
162
end
161
163
162
164
# 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
59
59
end
60
60
end
61
61
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
+
62
80
def test_multiple_threads
63
81
thread_count = 10
64
82
You can’t perform that action at this time.
0 commit comments