Skip to content

Commit

Permalink
Merge branch 'feature/APPEALS-20492' into ricky/APPEALS-23450
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Manus authored Aug 17, 2023
2 parents 3261e34 + 4558835 commit 6be5200
Show file tree
Hide file tree
Showing 19 changed files with 285 additions and 50 deletions.
1 change: 1 addition & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ plugins:
exclude_patterns:
- 'db/schema.rb'
- 'db/seeds.rb'
- 'db/scripts/*'
- 'node_modules/**/*'
- 'app/mappers/zip_code_to_lat_lng_mapper.rb'
- 'tmp/**/*'
Expand Down
36 changes: 25 additions & 11 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ env:
rspec_active: true
FORCE_COLOR: "1" #Forces color within GHA - Note RSPEC still won't use color see line 199 --tty for rspec color

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
# This job runs the main deployment of caseflow
caseflow_rspec_job:
Expand Down Expand Up @@ -76,30 +80,38 @@ jobs:
steps:
- uses: actions/checkout@v3

# If we don't explicitly set this, the runner doesn't find the path when trying to save the cache
- name: Set yarn cache directory
id: set-yarn-cache-dir
run: mkdir -p ~/.cache/yarn && yarn config set cache-folder ~/.cache/yarn

- name: restore yarn cache
id: cache-yarn-cache
uses: actions/cache/restore@v3
with:
key: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
# hashFiles('client/yarn.lock') will use a unique cache based on dependencies so that we don't
# create a cache for each target branch
key: yarn-cache-${{ hashFiles('client/yarn.lock') }}
# We are including node_modules because most of the time is used to build the dependencies
path: |
node_modules
client/node_modules
~/.cache/yarn
public/assets
tmp/cache/assets/sprockets
restore-keys:
dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
restore-keys: yarn-cache-${{ hashFiles('client/yarn.lock') }}

# We run yarn install after loading the cache to update any dependencies if their version is different
- name: Install Node Dependencies
run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile"
run: ./ci-bin/capture-log "cd client && yarn install --frozen-lockfile --prefer-offline"

- name: Save Yarn Cache
if: steps.cache-yarn-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
key: dot-cache-yarn-v2-{{ arch }}-{{ checksum "client/yarn.lock" }}
key: yarn-cache-${{ hashFiles('client/yarn.lock') }}
path: |
node_modules
client/node_modules
~/.cache/yarn
public/assets
tmp/cache/assets/sprockets
- name: setup testfiles directory
run: ./ci-bin/capture-log "mkdir -p tmp/testfiles"
Expand Down Expand Up @@ -178,9 +190,11 @@ jobs:
./ci-bin/capture-log "DB=etl bundle exec rake db:create db:schema:load db:migrate"
./ci-bin/capture-log "bundle exec rake db:create db:schema:load db:migrate"
- name: make seed-dbs
# We don't want to seed DBs here because DatabaseCleaner just truncates it anyway. The setup_vacols
# rake task needs to be run because it adds data to two tables that are ignored by DBCleaner
- name: Seed databases
run: |
./ci-bin/capture-log "make -f Makefile.example seed-dbs"
./ci-bin/capture-log "bundle exec rake spec:setup_vacols"
- name: Assets Precompile
run: |
Expand Down
92 changes: 92 additions & 0 deletions app/controllers/api/docs/pacman/idt-pacman-spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,27 @@ paths:
schema:
oneOf:
- $ref: '#/components/schemas/UploadDocumentRequestWithRecipientInformation'
- $ref: '#/components/schemas/UploadDocumentRequestWithRoColocatedRecipientInformation'
- $ref: '#/components/schemas/UploadDocumentRequest'
examples:
"With recipient information for Package Manager":
$ref: '#/components/schemas/UploadDocumentRequestWithRecipientInformation'
"With ro-colocated recipient information for Package Manager":
value:
veteran_identifier: '555555555'
document_type: 'BVA Decision'
document_subject: 'Test'
document_name: 'Test Doc'
file: 'VGhpcyBpcyBhIHRlc3QuIERvIG5vdCBiZSBhbGFybWVkLgo='
recipient_info:
- {
recipient_type: "ro-colocated",
name: "POA Name",
claimant_station_of_jurisdiction: "123",
poa_code: "02A",
destination_type: "derived",
copies: 1
}
"Without recipient information for Package Manager":
value:
veteran_identifier: '555555555'
Expand Down Expand Up @@ -389,10 +406,27 @@ paths:
schema:
oneOf:
- $ref: '#/components/schemas/UploadDocumentRequestWithRecipientInformation'
- $ref: '#/components/schemas/UploadDocumentRequestWithRoColocatedRecipientInformation'
- $ref: '#/components/schemas/UploadDocumentRequest'
examples:
"With recipient information for Package Manager":
$ref: '#/components/schemas/UploadDocumentRequestWithRecipientInformation'
"With ro-colocated recipient information for Package Manager":
value:
veteran_identifier: '555555555'
document_type: 'BVA Decision'
document_subject: 'Test'
document_name: 'Test Doc'
file: 'VGhpcyBpcyBhIHRlc3QuIERvIG5vdCBiZSBhbGFybWVkLgo='
recipient_info:
- {
recipient_type: "ro-colocated",
name: "POA Name",
claimant_station_of_jurisdiction: "123",
poa_code: "02A",
destination_type: "derived",
copies: 1
}
"Without recipient information for Package Manager":
value:
veteran_identifier: '555555555'
Expand Down Expand Up @@ -600,10 +634,26 @@ paths:
schema:
oneOf:
- $ref: '#/components/schemas/OutcodeRequestWithRecipientInformation'
- $ref: '#/components/schemas/OutcodeRequestWithRoColocatedRecipientInformation'
- $ref: '#/components/schemas/OutcodeRequest'
examples:
"With recipient information for Package Manager":
$ref: '#/components/schemas/OutcodeRequestWithRecipientInformation'
"With ro-colocated recipient information for Package Manager":
value:
citation_number: "A19062122"
decision_date: "December 21, 2022"
redacted_document_location: "\\path.va.gov\\archdata$\\some-file.pdf"
file: "VGVzdGluZyAxMjMK"
recipient_info:
- {
recipient_type: "ro-colocated",
name: "POA Name",
claimant_station_of_jurisdiction: "123",
poa_code: "02A",
destination_type: "derived",
copies: 1
}
"Without recipient information for Package Manager":
value:
citation_number: "A19062122"
Expand Down Expand Up @@ -960,6 +1010,16 @@ components:
items:
type: object
$ref: '#/components/schemas/RecipientRequestInformation'
UploadDocumentRequestWithRoColocatedRecipientInformation:
allOf:
- $ref: '#/components/schemas/UploadDocumentRequest'
- type: object
properties:
recipient_info:
type: array
items:
type: object
$ref: '#/components/schemas/RoColocatedRecipientRequestInformation'
UploadDocumentRequest:
type: object
properties:
Expand Down Expand Up @@ -992,6 +1052,38 @@ components:
items:
type: object
$ref: '#/components/schemas/RecipientRequestInformation'
OutcodeRequestWithRoColocatedRecipientInformation:
allOf:
- $ref: '#/components/schemas/OutcodeRequest'
- type: object
properties:
recipient_info:
type: array
items:
type: object
$ref: '#/components/schemas/RoColocatedRecipientRequestInformation'
RoColocatedRecipientRequestInformation:
type: object
properties:
recipient_type:
type: string
example: 'ro-colocated'
name:
description: 'Required if recipient_type is organization, system, or ro-colocated. Unused for people.'
type: string
example: "POA Name"
claimant_station_of_jurisdiction:
type: string
description: 'Required if recipient_type is ro-colocated.'
example: "123"
postal_code:
type: string
destination_type:
type: string
example: "derived"
copies:
type: integer
example: 1
RecipientRequestInformation:
type: object
properties:
Expand Down
34 changes: 34 additions & 0 deletions app/validators/mail_request_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ module DistributionDestination
validates :country_name, if: -> { destination_type == "internationalAddress" }
end

# If destination type is derived:
# - The recipient type of associated distribution must be ro-colocated
# - All physical address fields must be null/blank
with_options if: -> { destination_type == "derived" } do
validate :recipient_type_ro_colocated?
validates(*PHYSICAL_ADDRESS_FIELDS, absence: true)
end
# And vice versa: if recipient type is ro-colocated, destination type must be derived
validates :destination_type,
inclusion: { in: ["derived"], message: "must be derived if recipient type is ro-colocated" },
if: -> { ro_colocated? }

validates :treat_line_2_as_addressee,
inclusion: { in: [true], message: "cannot be false if line 3 is treated as addressee" },
if: -> { treat_line_3_as_addressee == true }
Expand All @@ -49,10 +61,32 @@ def physical_mail?
%w[domesticAddress internationalAddress militaryAddress].include?(destination_type)
end

PHYSICAL_ADDRESS_FIELDS = [
:address_line_1, :address_line_2, :address_line_3, :address_line_4, :address_line_5, :address_line_6,
:treat_line_2_as_addressee, :treat_line_3_as_addressee, :city, :state, :postal_code, :country_name,
:country_code
].freeze

def us_address?
%w[domesticAddress militaryAddress].include?(destination_type)
end

def ro_colocated?
case self
when MailRequest then recipient_type == "ro-colocated"
when VbmsDistributionDestination then vbms_distribution&.recipient_type == "ro-colocated"
else
false
end
end

def recipient_type_ro_colocated?
unless ro_colocated?
errors.add(:destination_type,
"cannot be derived unless recipient type of associated distribution is ro-colocated")
end
end

def valid_country_code?
unless iso_country_codes.include?(country_code)
errors.add(:country_code, "is not a valid ISO 3166-2 code")
Expand Down
2 changes: 1 addition & 1 deletion client/app/styles/_noncomp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
.cf-noncomp-search {
position: absolute;
right: 0;
z-index: 99999;
z-index: 1;
}

.cf-pagination-pages {
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20230731194341_make_address_line_1_nullable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class MakeAddressLine1Nullable < Caseflow::Migration
def change
change_column_null(:vbms_distribution_destinations, :address_line_1, true)
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_06_29_184615) do
ActiveRecord::Schema.define(version: 2023_07_31_194341) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -1809,7 +1809,7 @@
end

create_table "vbms_distribution_destinations", force: :cascade do |t|
t.string "address_line_1", null: false, comment: "PII. If destination_type is domestic, international, or military then Must not be null."
t.string "address_line_1", comment: "PII. If destination_type is domestic, international, or military then Must not be null."
t.string "address_line_2", comment: "PII. If treatLine2AsAddressee is [true] then must not be null"
t.string "address_line_3", comment: "PII. If treatLine3AsAddressee is [true] then must not be null"
t.string "address_line_4", comment: "PII."
Expand Down
18 changes: 13 additions & 5 deletions db/scripts/audit/remove_caseflow_audit_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,16 @@

require "pg"

conn = CaseflowRecord.connection
conn.execute(
"drop schema IF EXISTS caseflow_audit CASCADE;"
)
conn.close
begin
conn = CaseflowRecord.connection
conn.execute(
"drop schema IF EXISTS caseflow_audit CASCADE;"
)
conn.close
rescue ActiveRecord::NoDatabaseError => error
if error.message.include?('database "caseflow_certification_development" does not exist')
puts "Database caseflow_certification_development does not exist; skipping make audit-remove"
else
raise error
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
type_of_change CHAR(1) not null,
vbms_distribution_destinations_id bigint not null,
destination_type varchar NOT NULL,
address_line_1 varchar NOT NULL,
address_line_1 varchar NULL,
address_line_2 varchar NULL,
address_line_3 varchar NULL,
address_line_4 varchar NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ create table caseflow_audit.vbms_distribution_destinations_audit (
type_of_change CHAR(1) not null,
vbms_distribution_destinations_id bigint not null,
destination_type varchar NOT NULL,
address_line_1 varchar NOT NULL,
address_line_1 varchar NULL,
address_line_2 varchar NULL,
address_line_3 varchar NULL,
address_line_4 varchar NULL,
Expand Down
18 changes: 18 additions & 0 deletions spec/factories/mail_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@
recipient_type { nil }
end

trait :ro_colocated_recipient do
recipient_type { "ro-colocated" }
first_name { nil }
last_name { nil }
name { "WYOMING VETERANS COMMISSION" }
poa_code { "869" }
claimant_station_of_jurisdiction { "329" }
participant_id { nil }
destination_type { "derived" }
address_line_1 { nil }
city { nil }
country_code { nil }
postal_code { nil }
state { nil }
treat_line_2_as_addressee { nil }
treat_line_3_as_addressee { nil }
end

initialize_with { new(attributes) }
end
end
6 changes: 4 additions & 2 deletions spec/feature/hearings/add_hearing_day_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,14 @@
end

scenario "select a vlj from the dropdown works" do
click_dropdown(name: "vlj", text: judge.full_name, wait: 30)
expect(page).to have_content("VLJ")
click_dropdown(name: "vlj", text: judge.full_name)
expect(page).to have_content(judge.full_name)
end

scenario "select a coordinator from the dropdown works" do
click_dropdown(name: "coordinator", text: coordinator.full_name, wait: 30)
expect(page).to have_content("Hearing Coordinator")
click_dropdown(name: "coordinator", text: coordinator.full_name)
expect(page).to have_content(coordinator.full_name)
end
end
Expand Down
Loading

0 comments on commit 6be5200

Please sign in to comment.