Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Add validation for Display Id format #238

Merged
merged 1 commit into from
Nov 15, 2021
Merged

Conversation

Sgtpluck
Copy link
Collaborator

Description of change

Adds some validation around the TTA Display ID format because TTAHub 500s if the display id is not in the expected format.

Acceptance Criteria

When I input a TTA Activity Report Display ID that does not match the format /^R/d{2}-AR-/
I want an error that tells me it's a bad format
So I know what the problem is

How to test

  • Go to a complaint detail page.
  • Try to link a TTA AR ID that is not in the /^R/d{2}-AR-/ format
  • You should get an error that says "This doesn't look like a TTA Activity Report Display ID. Please double check the format."
  • Try to like a TTA AR ID that is in that format! You should get a different response depending on whether it's an ID you have access to or not.

Checklist

To be completed by the submitter:

  • Code is meaningfully tested
  • Meets accessibility standards (WCAG 2.1 Levels A, AA)

To the Reviewer

This project is using Conventional Comments to give structure
and context to PR comments. Please use these labels in your comments.

  • praise:
  • nitpick:
  • suggestion:
  • issue:
  • question:
  • thought:
  • chore:

@Sgtpluck Sgtpluck requested review from jduss4 and kbighorse November 10, 2021 19:06
@@ -38,6 +39,7 @@ def api_error_message
private

def api_call_succeeded
return unless errors.blank?
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this way, the API call won't happen if the display id is the wrong format

@@ -57,6 +59,12 @@ def api
ApiDelegator.use("tta", "activity_report", display_id: display_id, access_token: access_token)
end

def check_display_id_format
unless display_id.match?(/^R\d{2}-AR-/)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[comment, non-blocking] I can't find where I've seen the legacy display id format, but I think this regex will only work for the current format. I think it's good enough for our current purposes, though. Do you think it's worth adding a comment in case anybody is working from our code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure

@Sgtpluck Sgtpluck force-pushed the dmm/add-tta-link-validation branch from 7b55b59 to be38a62 Compare November 15, 2021 14:24
@Sgtpluck Sgtpluck force-pushed the dmm/add-tta-link-validation branch from be38a62 to b7e8795 Compare November 15, 2021 15:14
@Sgtpluck Sgtpluck merged commit bcc55d5 into main Nov 15, 2021
@Sgtpluck Sgtpluck deleted the dmm/add-tta-link-validation branch November 15, 2021 15:26
@Sgtpluck Sgtpluck mentioned this pull request Nov 15, 2021
6 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants