Skip to content

Commit 86543f2

Browse files
authored
Merge branch 'master' into feature/implement_hash
2 parents dbadb81 + 23c337e commit 86543f2

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- [#338](https://github.com/JsonApiClient/json_api_client/pull/338) - implement hash and eql? for builder class
6+
- [#351](https://github.com/JsonApiClient/json_api_client/pull/351) - Remove rudimental `last_result_set` relationship from serializer
67

78
## 1.13.0
89

lib/json_api_client/resource.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ def save
458458
self.attributes = updated.attributes
459459
self.links.attributes = updated.links.attributes
460460
self.relationships.attributes = updated.relationships.attributes
461-
self.relationships.last_result_set = last_result_set
462461
clear_changes_information
463462
self.relationships.clear_changes_information
464463
_clear_cached_relationships
@@ -477,7 +476,6 @@ def destroy
477476
false
478477
else
479478
mark_as_destroyed!
480-
self.relationships.last_result_set = nil
481479
_clear_cached_relationships
482480
_clear_belongs_to_params
483481
true

test/unit/serializing_test.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,29 @@ def test_as_json
5252
assert_equal expected, resource.first.as_json
5353
end
5454

55+
def test_as_json_involving_last_result_set
56+
expected = {
57+
'type' => 'articles',
58+
'id' => '1',
59+
'attributes' => {
60+
'title' => 'Rails is Omakase'
61+
}
62+
}
63+
stub_request(:post, "http://example.com/articles")
64+
.to_return(headers: {content_type: "application/vnd.api+json"}, body: {
65+
data: [{
66+
type: "articles",
67+
id: "1",
68+
attributes: {
69+
title: "Rails is Omakase"
70+
}
71+
}]
72+
}.to_json)
73+
74+
resource = Article.create
75+
assert_equal expected, resource.as_json
76+
end
77+
5578
def test_as_json_api
5679
expected = {
5780
'type' => 'articles',

0 commit comments

Comments
 (0)