diff --git a/CHANGELOG.md b/CHANGELOG.md index e3372f7b..d8162984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- [#351](https://github.com/JsonApiClient/json_api_client/pull/351) - Remove rudimental `last_result_set` relationship from serializer + ## 1.13.0 - [#348](https://github.com/JsonApiClient/json_api_client/pull/348) - add NestedParamPaginator to address inconsistency in handling of pagination query string params (issue [#347](https://github.com/JsonApiClient/json_api_client/issues/347)). diff --git a/lib/json_api_client/resource.rb b/lib/json_api_client/resource.rb index bae824e4..ed03eab3 100644 --- a/lib/json_api_client/resource.rb +++ b/lib/json_api_client/resource.rb @@ -458,7 +458,6 @@ def save self.attributes = updated.attributes self.links.attributes = updated.links.attributes self.relationships.attributes = updated.relationships.attributes - self.relationships.last_result_set = last_result_set clear_changes_information self.relationships.clear_changes_information _clear_cached_relationships @@ -477,7 +476,6 @@ def destroy false else mark_as_destroyed! - self.relationships.last_result_set = nil _clear_cached_relationships _clear_belongs_to_params true diff --git a/test/unit/serializing_test.rb b/test/unit/serializing_test.rb index 9fc14fca..e2460809 100644 --- a/test/unit/serializing_test.rb +++ b/test/unit/serializing_test.rb @@ -52,6 +52,29 @@ def test_as_json assert_equal expected, resource.first.as_json end + def test_as_json_involving_last_result_set + expected = { + 'type' => 'articles', + 'id' => '1', + 'attributes' => { + 'title' => 'Rails is Omakase' + } + } + stub_request(:post, "http://example.com/articles") + .to_return(headers: {content_type: "application/vnd.api+json"}, body: { + data: [{ + type: "articles", + id: "1", + attributes: { + title: "Rails is Omakase" + } + }] + }.to_json) + + resource = Article.create + assert_equal expected, resource.as_json + end + def test_as_json_api expected = { 'type' => 'articles',