Skip to content

Commit dc96280

Browse files
Fix missing Location header in 0.9.x (#1362)
* Add failing test to demonstrate regression It looks like this test was originally added as part of the Location header work, but was subsequently removed. See: cerebris/jsonapi-resources@933750c * Fix location header to be set correctly, fixes #1361 Previously, a change had been make to use string keys instead of symbol keys, see cerebris/jsonapi-resources@010f024 The change did not update how the location header was set to also use string keys. This PR resolves the issue by also using a string key.
1 parent 8cdc9dd commit dc96280

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/jsonapi/acts_as_resource_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def render_results(operation_results)
234234
render_options[:body] = JSON.generate(content)
235235
end
236236

237-
render_options[:location] = content[:data]["links"][:self] if (
237+
render_options[:location] = content[:data]["links"]["self"] if (
238238
response_doc.status == :created && content[:data].class != Array && content[:data]["links"]
239239
)
240240

test/controllers/controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,7 @@ def test_create_simple
591591
assert_equal 'JR is Great', json_response['data']['attributes']['title']
592592
assert_equal 'JSONAPIResources is the greatest thing since unsliced bread.', json_response['data']['attributes']['body']
593593
assert_equal "http://test.host/posts/#{json_response['data']['id']}", json_response['data']['links']['self']
594+
assert_equal json_response['data']['links']['self'], response.location
594595
end
595596

596597
def test_create_simple_id_not_allowed

0 commit comments

Comments
 (0)