GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@WaKeMaTTa WaKeMaTTa commented Mar 6, 2020 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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
All reactions
  • 👍 1 reaction
@WaKeMaTTa
[bugfix] Missing client in the response of the object created
33ecaad
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!!
```
murtron
murtron approved these changes Mar 6, 2020
View reviewed changes

@murtron murtron left a comment

Copy link
Copy Markdown
Contributor

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
All reactions
  • 👍 2 reactions
@murtron
murtron merged commit fb84544 into intercom:master Mar 10, 2020
@murtron murtron mentioned this pull request Mar 10, 2020
Bump intercom to 4.0.1 #518
Merged
@WaKeMaTTa
WaKeMaTTa deleted the bug-contact-add-comapny branch March 10, 2020 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@murtron murtron murtron approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@WaKeMaTTa @murtron
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.