Skip to content

Commit

Permalink
80872: Add ivc_champva_form model, factory and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
balexandr committed Apr 17, 2024
1 parent 86b38e2 commit 588e05d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/models/ivc_champva_form.rb
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions spec/factories/ivc_champva_forms.rb
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions spec/models/ivc_champva_forms_spec.rb
Original file line number Diff line number Diff line change
@@ -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 = '[email protected]'
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

0 comments on commit 588e05d

Please sign in to comment.