-
Notifications
You must be signed in to change notification settings - Fork 66
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
Begin adding notification_first_name to Simple Forms models #20376
Merged
stevenjcumming
merged 10 commits into
master
from
add-notification-first-name-to-simple-forms-models
Jan 28, 2025
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a372d8f
Begin adding notification_first_name to Simple Forms models
Thrillberg d6df6da
Finish the rest of the forms
Thrillberg ed827bb
lint/test
Thrillberg bf8c50d
spec
Thrillberg 2304443
feedback
Thrillberg a27ba31
correct possible typo
Thrillberg c7c44c4
Merge branch 'master' into add-notification-first-name-to-simple-form…
Thrillberg cd376ac
rename class
Thrillberg 427a1b3
tests
Thrillberg b40f091
switch ivars to attributes
Thrillberg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
require 'json' | ||
|
||
module SimpleFormsApi | ||
# rubocop:disable Metrics/ClassLength | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Thrillberg, can you look into getting this file under 400 lines? May I suggest moving the contents of module SimpleFormsApi
module VBA4010007
class Attachment
attr_reader :file_path, :data
def initialize(file_path:, data:)
@file_path = file_path
@data = @data
end
def create
veteran_sex = get_gender(@data.dig('application', 'veteran', 'gender'))
# etc etc then you can do this in the form model def create_attachment_page(file_path)
SimpleFormsApi::VBA4010007::Attachment.new(file_path:, data: @data).create
end |
||
class VBA4010007 < BaseForm | ||
STATS_KEY = 'api.simple_forms_api.40_10007' | ||
|
||
|
@@ -39,6 +40,16 @@ def metadata | |
} | ||
end | ||
|
||
def notification_first_name | ||
applicant_relationship = @data.dig('application', 'applicant', 'applicant_relationship_to_claimant') | ||
|
||
if applicant_relationship == 'Self' | ||
@data.dig('application', 'claimant', 'name', 'first') | ||
else | ||
@data.dig('application', 'applicant', 'name', 'first') | ||
end | ||
end | ||
|
||
def zip_code_is_us_based | ||
# TODO: Implement this | ||
true | ||
|
@@ -475,4 +486,5 @@ def get_attachments | |
attachments | ||
end | ||
end | ||
# rubocop:enable Metrics/ClassLength | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe SimpleFormsApi::BaseForm do | ||
describe '#notification_first_name' do | ||
it 'returns the first name to be used in notifications' do | ||
data = { | ||
'veteran_full_name' => { | ||
'first' => 'Veteran', | ||
'last' => 'Eteranvay' | ||
} | ||
} | ||
|
||
expect(described_class.new(data).notification_first_name).to eq 'Veteran' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require_relative '../support/shared_examples_for_base_form' | ||
|
||
RSpec.describe SimpleFormsApi::VBA2010206 do | ||
it_behaves_like 'zip_code_is_us_based', %w[address] | ||
|
||
describe '#notification_first_name' do | ||
let(:data) do | ||
{ | ||
'full_name' => { | ||
'first' => 'Veteran', | ||
'last' => 'Eteranvay' | ||
} | ||
} | ||
end | ||
|
||
it 'returns the first name to be used in notifications' do | ||
expect(described_class.new(data).notification_first_name).to eq 'Veteran' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require_relative '../support/shared_examples_for_base_form' | ||
|
||
RSpec.describe SimpleFormsApi::VBA210972 do | ||
it_behaves_like 'zip_code_is_us_based', %w[preparer_address] | ||
|
||
describe '#notification_first_name' do | ||
let(:data) do | ||
{ | ||
'preparer_full_name' => { | ||
'first' => 'Veteran', | ||
'last' => 'Eteranvay' | ||
} | ||
} | ||
end | ||
|
||
it 'returns the first name to be used in notifications' do | ||
expect(described_class.new(data).notification_first_name).to eq 'Veteran' | ||
end | ||
end | ||
end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Do you want to use the instance variable
@data
just to be consistent with the othernotification_first_name method
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather change the others to be
data
(lose the@
) since it's an attribute anyway. I'll update.