Skip to content

Extract Idv::ProoferValidator#result#1515

Merged
zachmargolis merged 1 commit intomasterfrom
margolis-extract-vendor-result
Jun 29, 2017
Merged

Extract Idv::ProoferValidator#result#1515
zachmargolis merged 1 commit intomasterfrom
margolis-extract-vendor-result

Conversation

@zachmargolis
Copy link
Contributor

Why:
Extracting this into a serializable object will make it
easier to refactor these classes into background jobs.


Follow-up to #1513

@zachmargolis zachmargolis force-pushed the margolis-extract-vendor-result branch from c7f5caa to 9ea5c4f Compare June 29, 2017 14:28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we change the behavior of #to_json somewhere, or is this just verifying that it serializes normalized_applicant correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not changing the behavior anywhere, do you think we should remove the spec?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe it the purpose is to check that it correctly serializes things that don't translate to JSON primitives, it could be something like:

it 'serializes normalized_applicant correctly'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Will update

Copy link
Contributor

@jmhooper jmhooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question for my understanding.

Looks good 🥇

@zachmargolis zachmargolis force-pushed the margolis-extract-vendor-result branch 2 times, most recently from 203b6cc to 0ff17d2 Compare June 29, 2017 15:32
**Why**:
Extracting this into a serializable object will make it
easier to refactor these classes into background jobs.
@zachmargolis zachmargolis self-assigned this Jun 29, 2017
@zachmargolis zachmargolis merged commit 49d09a8 into master Jun 29, 2017
@zachmargolis zachmargolis deleted the margolis-extract-vendor-result branch June 29, 2017 15:59
success
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Reek's TooManyInstanceVariables offense. How about making this class only accept the result as an argument, and then the class can define public method for success, errors, reasons, session_id, and normalized_applicant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to state my goals clearly, the end result that I want is an object that can be can easily be serialized and passed around (from the background process) so we can continue working on the results of the proofing process outside of a background job. In this case I settled on creating Idv::VendorResult.

If we chose to make this class accept result as you suggest, then @result would be its only instance variable, and it would not serialize cleanly. The result (which is an Proofer::Resolution) has result.vendor_resp which is kind of a free-form field and so we have no way of easily deserializing it (it has different classes and values depending on which method we call on the client).

I am satisfied with the choice here to ignore reek's warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it now. Sorry for jumping the gun. It wasn't clear at the beginning what this was doing since new_from_json is not being used yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, thanks for checking! 👍

describe '#success?' do
it 'returns Proofer::Confirmation#success?' do
describe '#result' do
it 'has success' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is successful? instead of has success?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe it 'responds to success?', and it 'responds to errors'

describe '#success?' do
it 'returns Proofer::Confirmation#success?' do
describe '#result' do
it 'has success' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above about the test description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants