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

Correspondence - Add validation to foreign keys #20474

Merged
merged 29 commits into from
Jan 12, 2024

Conversation

Rnmarshall93
Copy link
Contributor

@Rnmarshall93 Rnmarshall93 commented Jan 10, 2024

Resolves Add validation to foreign keys

Description

These changes modify the Correspondence Model to have validation for the following foreign keys, and will reject the data if saved without having them present.

  • correspondence_type_id
  • package_document_type_id
  • assigned_by_id
  • updated_by_id
  • veteran_id

Acceptance Criteria

  • Code compiles correctly

Testing Plan

  1. Open a rails console within the caseflow directory
  2. Attempt to create a new correspondence with Correspondence.create!
  3. The creation will fail. Instead, pass it data for each of the required foreign keys like so:
    Correspondence.create!( updated_by_id: 1, correspondence_type_id: 1, assigned_by_id: 1, veteran_id: 1, package_document_type_id: 1 )
  4. This will pass because the validations are met.

Tests

Test Coverage

Did you include any test coverage for your code? Check below:

  • RSpec
  • Jest
  • Other

Code Climate

Your code does not add any new code climate offenses? If so why?

  • No new code climate issues added

@Rnmarshall93 Rnmarshall93 changed the title 37706 draft Correspondence - Add validation to foreign keys Jan 10, 2024
Copy link
Contributor

@HunJerBAH HunJerBAH left a comment

Choose a reason for hiding this comment

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

Fantastic work on this! Tests are looking good and seed data is all looking good as well. My only request is if you could add the updated_by_id to the correspondence.rake task in the create_correspondences_with_documents, create_correspondence, and create_multi_correspondences methods in that rake task. With these changes, we are going to need to blow up our current UAT data and re-run that rake tasks with the correct relationships.

Copy link
Contributor

@jimfoley25 jimfoley25 left a comment

Choose a reason for hiding this comment

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

Factory refinements by Alex are truly awesome, way to go team.

Copy link
Contributor

@HunJerBAH HunJerBAH left a comment

Choose a reason for hiding this comment

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

Fantastic work!

@HunJerBAH HunJerBAH merged commit 3fc169f into feature/APPEALS-27311 Jan 12, 2024
17 checks passed
@HunJerBAH HunJerBAH deleted the ryan/APPEALS-37706 branch January 12, 2024 15:35
craigrva pushed a commit that referenced this pull request Jan 24, 2024
* presence validation added.

* fixed failing tests due to validations

* changed data to be less confusing

* fixed failing test

* added foreign key validation at the db level

* Fixed failing tests.

* Added additional let! statements to stub data

* fixed linting

* Fixed failing specs (all of them) by stubbing more correspondence data

* Updated correspondence factors to supply all required foreign key objects.

* modified correspondence helpers to use only factory.

* Fixed failing specs

* removed redundant info

* updated spec to fix failing validations

* Changed seed order to support Correspondence validations

* fixed linting issues

* Added correspondence_type factory

* Modified correspondence factory so that it uses user, veteran, correspondence_type factories.

* Added package_document_type factory, changed correspondence factory to use it.

* Added association for assigned_by

* Updated to use factories for user, removed useless assignments

* Removed redundant code

* fixed failing spec.

* fixed failing spec

* added updated_to_id to all correspondences

---------

Co-authored-by: Jim Foley <james.foley4@va.gov>
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