From 588e05da2df1a8eb7c081e3b77a860150a4fd970 Mon Sep 17 00:00:00 2001 From: Bryan Alexander Date: Wed, 17 Apr 2024 15:53:53 -0400 Subject: [PATCH] 80872: Add ivc_champva_form model, factory and tests --- .github/CODEOWNERS | 3 ++ app/models/ivc_champva_form.rb | 8 +++++ spec/factories/ivc_champva_forms.rb | 14 +++++++++ spec/models/ivc_champva_forms_spec.rb | 42 +++++++++++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 app/models/ivc_champva_form.rb create mode 100644 spec/factories/ivc_champva_forms.rb create mode 100644 spec/models/ivc_champva_forms_spec.rb diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e423dd2a2d3..8174b7c9d29 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -265,6 +265,7 @@ app/models/identifier_index.rb @department-of-veterans-affairs/vsa-debt-resoluti app/models/inherited_proofing @department-of-veterans-affairs/octo-identity app/models/inherited_proof_verified_user_account.rb @department-of-veterans-affairs/octo-identity app/models/in_progress_form.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group +app/models/ivc_champva_form.rb @department-of-veterans-affairs/champva-engineering @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/lighthouse_document.rb @department-of-veterans-affairs/backend-review-group app/models/maintenance_window.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group app/models/message_draft.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -1108,6 +1109,7 @@ spec/factories/iam_user_identities.rb @department-of-veterans-affairs/octo-ident spec/factories/iam_users.rb @department-of-veterans-affairs/octo-identity spec/factories/inherited_proofing @department-of-veterans-affairs/octo-identity spec/factories/in_progress_forms @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group +spec/factories/ivc_champva_forms.rb @department-of-veterans-affairs/champva-engineering @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/lighthouse @department-of-veterans-affairs/vfs-facilities-frontend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/maintenance_windows.rb @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/factories/message_drafts.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group @@ -1456,6 +1458,7 @@ spec/models/iam_user_identity_spec.rb @department-of-veterans-affairs/octo-ident spec/models/inherited_proofing @department-of-veterans-affairs/octo-identity spec/models/inherited_proof_verified_user_account_spec.rb @department-of-veterans-affairs/octo-identity spec/models/in_progress_form_spec.rb @department-of-veterans-affairs/vfs-authenticated-experience-backend @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group +spec/models/ivc_champva_forms_spec.rb @department-of-veterans-affairs/champva-engineering @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/message_spec.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/mhv_opt_in_flag_spec.rb @department-of-veterans-affairs/vfs-mhv-secure-messaging @department-of-veterans-affairs/va-api-engineers @department-of-veterans-affairs/backend-review-group spec/models/mpi_data_spec.rb @department-of-veterans-affairs/octo-identity diff --git a/app/models/ivc_champva_form.rb b/app/models/ivc_champva_form.rb new file mode 100644 index 00000000000..84ad88ea17c --- /dev/null +++ b/app/models/ivc_champva_form.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class IvcChampvaForm < ApplicationRecord + validates :email, presence: true + validates :email, uniqueness: true + + # Add more complex data modeling here outside of CRUD +end diff --git a/spec/factories/ivc_champva_forms.rb b/spec/factories/ivc_champva_forms.rb new file mode 100644 index 00000000000..e5eb1636932 --- /dev/null +++ b/spec/factories/ivc_champva_forms.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ivc_champva_form do + email { Faker::Internet.email } + first_name { Faker::Name.first_name } + last_name { Faker::Name.last_name } + form_number { '10-10D' } + file_name { Faker::File.file_name } + form_uuid { SecureRandom.uuid } + s3_status { 200 } + pega_status { %w[pending processing completed].sample } + end +end diff --git a/spec/models/ivc_champva_forms_spec.rb b/spec/models/ivc_champva_forms_spec.rb new file mode 100644 index 00000000000..7d8c35b60c5 --- /dev/null +++ b/spec/models/ivc_champva_forms_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe IvcChampvaForm, type: :model do + describe 'validations' do + it { is_expected.to validate_presence_of(:email) } + it { is_expected.to validate_uniqueness_of(:email) } + end + + describe 'factory' do + it 'is valid' do + expect(build(:ivc_champva_form)).to be_valid + end + end + + describe 'methods' do + describe '#create' do + it 'creates a new form' do + expect { create(:ivc_champva_form) }.to change(IvcChampvaForm, :count).by(1) + end + end + + describe '#update' do + let(:form) { create(:ivc_champva_form) } + + it 'updates an existing form' do + new_email = 'new_email@example.com' + form.update(email: new_email) + expect(form.reload.email).to eq(new_email) + end + end + + describe '#destroy' do + let!(:form) { create(:ivc_champva_form) } + + it 'deletes an existing form' do + expect { form.destroy }.to change(IvcChampvaForm, :count).by(-1) + end + end + end +end