Add External ID Field to Contact Model#155
Conversation
|
|
||
| $this->assertTrue($result instanceof Contact); | ||
| $this->assertNull($result->external_id); | ||
| } |
There was a problem hiding this comment.
[minor] I guess for the similar changes in the chartmogul-ruby repo, this kind of test makes sense: you have an input, the VCR cassette logs and asserts the actual HTTP payload (e.g. external_id is omitted in the input, it's also omitted in the request payload, logged in the cassette), mocks the response body and in the end the class property is asserted.
But in this case, we're not testing the request payload; the HTTP response is mocked, so in the end we're testing if the mocked response ContactTest::CONTACT_NULL_EXTERNAL_ID_JSON has external_id=null regardless of what is the input for Contact::create. You can test it out yoursef; pass in 'external_id' => '123' and $this->assertNull($result->external_id) would still pass.
There was actually an integration tests setup and I fixed it a few years back (PR). I would suggest to test it in a more integrated way using VCR cassettes similar to how we do things in charmogul-ruby. This type of unit test isn't exactly suitable for the logic you're introducing.
But it's minor; I see that a lot of tests have the exact same issue, so I don't want to block your PR and you can fix it in another PR. I just wanted to point this out
There was a problem hiding this comment.
Thanks a lot for the context, I've added some Contact model integration tests per your suggestion 👍
|
I received validation from Dijana that maintaining the |
This PR updates the Contact model to include the
external_idfield. Theexternal_idfield can be either a string or null. The Contact model tests have been updated to demonstrate how theexternal_idfield can be set in both CREATE and UPDATE requests.