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

Validate dinkurs key with Dinkurs API #540

Merged

Conversation

patmbolger
Copy link
Collaborator

PT Story: https://www.pivotaltracker.com/story/show/158426458

Validation of the dinkurs_company_key attribute is complicated by these factors:
• We need to invoke the "fetch" API in order to determine if we have a valid key (that is, there is not a separate endpoint we could use to simply check key validity without fetching events)
• We want to avoid calling that API end point more than once, since it is called synchronously (which is the only reasonable way to do it)
• To fetch and store company events, we need a company ID
• Therefore, we need to fetch events after the company has been saved (for create)

Changes proposed in this pull request:

  1. Company create:
  • After other attributes are saved - if successful - try to fetch events (if key has been specified)
  • If fetch fails (due to invalid key), set key validation error and tell user that the company was successfully created but that there was a problem with the key
  1. Company update:
  • If all other changed attributes are valid, try to fetch events (if key is specified)
  • Show error(s) to user if any attributes are invalid or dinkurs key is invalid
  1. Miscellaneous small changes

Screenshots (Optional):

Company created successful, but dinkurs key is invalid

screen shot 2018-06-21 at 8 11 14 am


Company updated with invalid dinkurs key

screen shot 2018-06-21 at 8 12 10 am

Ready for review:
@AgileVentures/shf-project-team

result = company.validate_key_and_fetch_dinkurs_events

expect(result).to eq false
expect(company.errors.full_messages.first).to match /#{err}/

Choose a reason for hiding this comment

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

Lint/AmbiguousRegexpLiteral: Ambiguous regexp literal. Parenthesize the method arguments if it's surely a regexp literal, or add a whitespace to the right of the / if it should be a division.

@patmbolger patmbolger force-pushed the dinkurs_key_validation#158426458 branch from ef7564d to 13645d7 Compare June 21, 2018 13:34
@patmbolger patmbolger merged commit 78c7ddc into AgileVentures:develop Jun 24, 2018
@patmbolger patmbolger deleted the dinkurs_key_validation#158426458 branch June 24, 2018 20:02
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.

None yet

3 participants