Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix initializing resource including relationships #263

Merged
merged 2 commits into from
Jul 26, 2017

Conversation

BrunoChauvet
Copy link
Contributor

I was having an issue when loading a resource including relationships:

undefined method `parse' for #<JsonApiClient::Associations::HasOne::Association:0x0000000326c7f0>
     Shared Example Group: "jpi v1 protected action" called from ./spec/controllers/my_controller_spec.rb:37
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/resource.rb:302:in `block in initialize'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/resource.rb:300:in `each'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/resource.rb:300:in `initialize'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/resource.rb:95:in `new'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/resource.rb:95:in `load'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:69:in `block in handle_data'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:68:in `map'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:68:in `handle_data'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:12:in `block in parse'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:8:in `tap'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/parsers/parser.rb:8:in `parse'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/query/requestor.rb:60:in `request'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/query/requestor.rb:27:in `get'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/query/builder.rb:104:in `find'
     # /.rvm/gems/ruby-2.3.3/gems/json_api_client-1.5.1/lib/json_api_client/query/builder.rb:92:in `to_a'

Running the gem specs I realised this bit of code was not covered.

@chingor13
Copy link
Collaborator

Can you add a test that shows the broken behavior that this fixes?

@BrunoChauvet
Copy link
Contributor Author

Sure, test added.

@chingor13 chingor13 merged commit a4f5a74 into JsonApiClient:master Jul 26, 2017
ouranos added a commit to ouranos/mno-enterprise that referenced this pull request Nov 8, 2017
The JsonApiClient/json_api_client#263 PR has been merged and released in
1.5.2 which is the minimum version required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants