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

Pamatya/appeals 26561 #19282

Merged
merged 6 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def seed
call_and_log_seed_step Seeds::Annotations
call_and_log_seed_step Seeds::Tags
# These must be ran before others
call_and_log_seed_step Seeds::BusinessLineOrg
call_and_log_seed_step Seeds::Users
call_and_log_seed_step Seeds::NotificationEvents
# End of required to exist dependencies
Expand Down
17 changes: 17 additions & 0 deletions db/seeds/businesss_line_org.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# Veterans Health Administration related seeds
# require "/sanitized_json_seeds.rb"

module Seeds
class BusinessLineOrg < Base
def seed!
create_business_lines
end

private
def create_business_lines
Seeds::SanitizedJsonSeeds.new.business_line_seeds
end
end
end
139 changes: 139 additions & 0 deletions db/seeds/sanitized_business_line_json/business_line.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"organizations": [
{
"id": 219,
"type": "BusinessLine",
"name": "Education",
"role": null,
"url": "education",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 220,
"type": "BusinessLine",
"name": "Veterans Readiness and Employment",
"role": null,
"url": "voc_rehab",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 221,
"type": "BusinessLine",
"name": "Loan Guaranty",
"role": null,
"url": "loan_guaranty",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 222,
"type": "BusinessLine",
"name": "Veterans Health Administration",
"role": null,
"url": "vha",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 590,
"type": "BusinessLine",
"name": "Pension & Survivor's Benefits",
"role": null,
"url": "pension",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 591,
"type": "BusinessLine",
"name": "Fiduciary",
"role": null,
"url": "fiduciary",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 592,
"type": "BusinessLine",
"name": "Compensation",
"role": null,
"url": "compensation",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 593,
"type": "BusinessLine",
"name": "Insurance",
"role": null,
"url": "insurance",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
},
{
"id": 11,
"type": "BusinessLine",
"name": "National Cemetery Administration",
"role": null,
"url": "nca",
"participant_id": null,
"created_at": null,
"updated_at": null,
"status": "active",
"status_updated_at": null,
"accepts_priority_pushed_cases": null,
"ama_only_push": false,
"ama_only_request": false
}
]
}
9 changes: 8 additions & 1 deletion db/seeds/sanitized_json_seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,20 @@ def seed!
import_json_seed_data
end

def business_line_seeds
import_json("db/seeds/sanitized_business_line_json/business_line.json")
end

private

def import_json_seed_data
# appeal_ready_for_substitution_3.json requires this to exist
FactoryBot.create(:higher_level_review, id: 2_000_050_893)
import_json("db/seeds/sanitized_json/*.json")
end

Dir.glob("db/seeds/sanitized_json/*.json").each do |json_seed|
def import_json(file_path)
Dir.glob(file_path).each do |json_seed|
sji = SanitizedJsonImporter.from_file(json_seed, verbosity: 0)
sji.import
end
Expand Down
3 changes: 1 addition & 2 deletions db/seeds/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def create_users
BvaIntake.singleton.add_user(bva_intake_user)

Functions.grant!("System Admin", users: User.all.pluck(:css_id))

create_team_admin
create_colocated_users
create_transcription_team
Expand Down Expand Up @@ -282,7 +281,7 @@ def create_field_vso_and_users
end

def create_org_queue_users
nca = BusinessLine.create!(name: "National Cemetery Administration", url: "nca")
nca = BusinessLine.find_or_create_by!(name: "National Cemetery Administration", url: "nca")
%w[Parveen Chandra Sydney Tai Kennedy].each do |name|
u = User.create!(station_id: 101, css_id: "NCA_QUEUE_USER_#{name}", full_name: "#{name} NCAUser Carter")
nca.add_user(u)
Expand Down
28 changes: 28 additions & 0 deletions spec/seeds/business_line_org_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

describe Seeds::BusinessLineOrg do
describe "#seeds!" do
subject { described_class.new.seed! }
let(:sji1) { instance_double(SanitizedJsonImporter) }

it "reads json file from specific directory" do
expect(subject).to eq ["db/seeds/sanitized_business_line_json/business_line.json"]
end

it "creates business line organizations" do
expect { subject }.to_not raise_error
expect(BusinessLine.count).to eq 9
end

it "invokes SanitizedJsonImporter for each matching file" do
expect(Dir).to receive(:glob).with("db/seeds/sanitized_business_line_json/business_line.json")
.and_return(%w[business_line.json])

expect(SanitizedJsonImporter).to receive(:from_file)
.with("business_line.json", verbosity: 0).and_return(sji1)
expect(sji1).to receive(:import)

subject
end
end
end
Loading