GeezerVison is showing github.com — [bugfix] Missing client in the response of the object created by WaKeMaTTa · Pull Request #516 · intercom/intercom-ruby
Conversation
WaKeMaTTa
commented
Mar 6, 2020
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Issue
Missing client in the response of the object created.
Then you can not use the nested resources.
Example
contact = INTERCOM_CLIENT.contacts.new(email: "[email protected]")
INTERCOM_CLIENT.contacts.save(contact)
company = INTERCOM_CLIENT.contacts.new(company_id: "abc-company-example")
contact.add_company(id: company.id) # this fails!!
Before my fix, the specs that I created were broken:
be m spec/unit/intercom/contact_spec.rb
Mocha deprecation warning at /github/intercom-ruby/spec/spec_helper.rb:5:in `require': Require 'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'.
Run options: -n "/^(test_0013_allows\\ setting\\ dates\\ to\\ nil\\ without\\ converting\\ them\\ to\\ 0|test_0015_will\\ allow\\ extra\\ attributes\\ in\\ response\\ from\\ api|test_0001_should\\ be\\ listable|test_0007_allows\\ easy\\ setting\\ of\\ custom\\ data|test_0008_rejects\\ nested\\ data\\ structures\\ in\\ custom_attributes|test_0009_saves\\ a\\ contact\\ \\(always\\ sends\\ custom_attributes\\)|test_0017_can\\ print\\ contacts\\ without\\ crashing|test_0005_is\\ throws\\ a\\ Intercom::AttributeNotSetError\\ on\\ trying\\ to\\ access\\ an\\ attribute\\ that\\ has\\ not\\ been\\ set|test_0003_to_hash'es\\ itself|test_0011_can\\ use\\ client\\.contacts\\.create\\ for\\ convenience|test_0006_presents\\ a\\ complete\\ contact\\ record\\ correctly|test_0020_deletes\\ a\\ contact|test_0002_should\\ throw\\ an\\ ArgumentError\\ when\\ there\\ are\\ no\\ parameters|test_0004_presents\\ created_at\\ and\\ last_impression_at\\ as\\ Date|test_0014_sets/gets\\ rw\\ keys|test_0019_can\\ update\\ a\\ contact\\ with\\ an\\ id|test_0016_returns\\ a\\ BaseCollectionProxy\\ for\\ all\\ without\\ making\\ any\\ requests|test_0012_updates\\ the\\ contact\\ with\\ attributes\\ as\\ set\\ by\\ the\\ server|test_0018_fetches\\ a\\ contact|test_0010_can\\ save\\ a\\ contact\\ with\\ a\\ nil\\ email|test_0001_increments\\ up\\ by\\ 1\\ with\\ no\\ args|test_0003_increments\\ down\\ by\\ given\\ value|test_0005_can\\ call\\ increment\\ on\\ the\\ same\\ key\\ twice\\ and\\ increment\\ by\\ 2|test_0002_increments\\ up\\ by\\ given\\ value|test_0004_can\\ increment\\ new\\ custom\\ data\\ fields|test_0001_decrements\\ down\\ by\\ 1\\ with\\ no\\ args|test_0002_decrements\\ down\\ by\\ given\\ value|test_0003_can\\ decrement\\ new\\ custom\\ data\\ fields|test_0004_can\\ call\\ decrement\\ on\\ the\\ same\\ key\\ twice\\ and\\ decrement\\ by\\ 2|test_0001_should\\ be\\ successful\\ with\\ a\\ lead\\ and\\ user|test_0001_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ notes|test_0004_adds\\ a\\ note\\ to\\ a\\ contact|test_0007_adds\\ a\\ contact\\ to\\ a\\ company|test_0002_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ tags|test_0003_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ companies|test_0005_adds\\ a\\ tag\\ to\\ a\\ contact|test_0006_removes\\ a\\ tag\\ from\\ a\\ contact|test_0008_removes\\ a\\ contact\\ from\\ a\\ company|test_0001_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ notes|test_0007_adds\\ a\\ contact\\ to\\ a\\ company|test_0006_removes\\ a\\ tag\\ from\\ a\\ contact|test_0002_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ tags|test_0003_returns\\ a\\ collection\\ proxy\\ for\\ listing\\ companies|test_0008_removes\\ a\\ contact\\ from\\ a\\ company|test_0004_adds\\ a\\ note\\ to\\ a\\ contact|test_0005_adds\\ a\\ tag\\ to\\ a\\ contact)$/" --seed 7184
# Running:
....E.E.EEE...................................
Finished in 0.014731s, 3122.6858 runs/s, 7399.4076 assertions/s.
1) Error:
Intercom::Contact::nested resources::just after creating the contact#test_0005_adds a tag to a contact:
NoMethodError: undefined method `post' for nil:NilClass
/github/intercom-ruby/lib/intercom/api_operations/nested_resource.rb:37:in `block (2 levels) in nested_resource_methods'
/github/intercom-ruby/spec/unit/intercom/contact_spec.rb:351:in `block (4 levels) in <top (required)>'
2) Error:
Intercom::Contact::nested resources::just after creating the contact#test_0006_removes a tag from a contact:
NoMethodError: undefined method `delete' for nil:NilClass
/github/intercom-ruby/lib/intercom/api_operations/nested_resource.rb:44:in `block (2 levels) in nested_resource_methods'
/github/intercom-ruby/spec/unit/intercom/contact_spec.rb:356:in `block (4 levels) in <top (required)>'
3) Error:
Intercom::Contact::nested resources::just after creating the contact#test_0004_adds a note to a contact:
NoMethodError: undefined method `post' for nil:NilClass
/github/intercom-ruby/lib/intercom/api_operations/nested_resource.rb:30:in `block (2 levels) in nested_resource_methods'
/github/intercom-ruby/spec/unit/intercom/contact_spec.rb:346:in `block (4 levels) in <top (required)>'
4) Error:
Intercom::Contact::nested resources::just after creating the contact#test_0007_adds a contact to a company:
NoMethodError: undefined method `post' for nil:NilClass
/github/intercom-ruby/lib/intercom/api_operations/nested_resource.rb:37:in `block (2 levels) in nested_resource_methods'
/github/intercom-ruby/spec/unit/intercom/contact_spec.rb:361:in `block (4 levels) in <top (required)>'
5) Error:
Intercom::Contact::nested resources::just after creating the contact#test_0008_removes a contact from a company:
NoMethodError: undefined method `delete' for nil:NilClass
/github/intercom-ruby/lib/intercom/api_operations/nested_resource.rb:44:in `block (2 levels) in nested_resource_methods'
/github/intercom-ruby/spec/unit/intercom/contact_spec.rb:366:in `block (4 levels) in <top (required)>'
46 runs, 109 assertions, 0 failures, 5 errors, 0 skips
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
goduchesne reacted with thumbs up emoji
Then you can not use the nested resources.
Example:
```ruby
contact = INTERCOM_CLIENT.contacts.new(email: "[email protected]")
INTERCOM_CLIENT.contacts.save(contact)
company = INTERCOM_CLIENT.contacts.new(company_id: "abc-company-example")
contact.add_company(id: company.id) # this fails!!
```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An oversight on our part, apologies 😞 Thanks a lot for this @WaKeMaTTa.
I'll try to get a new release out next week.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
WaKeMaTTa and goduchesne reacted with thumbs up emoji
Reviewers
murtron
murtron approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.