Skip to content

Commit

Permalink
added methods that return mst/pact status (#18470)
Browse files Browse the repository at this point in the history
* HunJerBAH/APPEALS-17509: Mocking BGS Contentions in Test Data (#18457)

* added mst and pact option to contention generator

* added mst and pact option to bgs_contention generator

* updated record maker to build epes with mst/pact contentions

* refactored to create both mst and pact contention cases for veterans

* added duplicate contention error handling in generator

* Ki/appeals 17508 v3 - Add Edit Issues Dropdown (#18453)

* APPEALs-17508 - feature branch update issues fix

* APPEALS-17508 - MST/PACT FeatureToggle

* added methods that return mst/pact status

* added safety operator to contention

* refactored changes onto request issue model

* refactored hash check with has_value?

* added rspec tests

* added generator for mst + pact status contention

* added brackets

* refactored spec tests

* updated contention generation methods for special issues

* updated status return methods to conform to test cases

* updated serialize attr from snake case to camel case

---------

Co-authored-by: HunJerBAH <99915461+HunJerBAH@users.noreply.github.com>
Co-authored-by: Ki Mau <ki.mau@va.gov>
  • Loading branch information
3 people authored Apr 26, 2023
1 parent 3d35d8b commit afb20fb
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 6 deletions.
12 changes: 11 additions & 1 deletion app/models/contestable_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def serialize
sourceReviewType: source_review_type,
timely: timely?,
latestIssuesInChain: serialize_latest_decision_issues,
isRating: is_rating
isRating: is_rating,
mstAvailable: mst_available?,
pactAvailable: pact_available?
}
end

Expand Down Expand Up @@ -112,6 +114,14 @@ def timely?
approx_decision_date && contesting_decision_review.timely_issue?(approx_decision_date)
end

def mst_available?
contested_by_request_issue&.mst_contention_status?
end

def pact_available?
contested_by_request_issue&.pact_contention_status?
end

private

def contested_by_request_issue
Expand Down
26 changes: 25 additions & 1 deletion app/models/request_issue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,30 @@ def status_active?
end_product_establishment.status_active?
end

def mst_contention_status?
return false if contention.nil?
status = false
contention&.special_issues&.each do |issue|
if issue[:code].upcase == "MST"
status = true
break
end
end
status
end

def pact_contention_status?
return false if contention.nil?
status = false
contention&.special_issues&.each do |issue|
if issue[:code].upcase == "PACT"
status = true
break
end
end
status
end

def rating?
!!associated_rating_issue? ||
!!previous_rating_issue? ||
Expand Down Expand Up @@ -609,7 +633,7 @@ def contention_missing?
end

def contention
end_product_establishment.contention_for_object(self)
end_product_establishment&.contention_for_object(self)
end

def bgs_contention
Expand Down
46 changes: 42 additions & 4 deletions lib/generators/contention.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def default_attrs_with_mst
text: "Generic contention with MST",
start_date: Time.zone.today,
submit_date: 5.days.ago,
special_issues: {
special_issues: [{
issue_id: generate_external_id,
narrative: "Military Sexual Trauma (MST)",
code: "MST"
}
}]
}
end

Expand All @@ -36,11 +36,30 @@ def default_attrs_with_pact
text: "Generic contention",
start_date: Time.zone.today,
submit_date: 5.days.ago,
special_issues: {
special_issues: [{
issue_id: generate_external_id,
narrative: "PACT",
code: "PACT"
}
}]
}
end

def default_attrs_with_mst_and_pact
{
id: generate_external_id,
claim_id: generate_external_id,
text: "Generic contention",
start_date: Time.zone.today,
submit_date: 5.days.ago,
special_issues: [{
issue_id: generate_external_id,
narrative: "Military Sexual Trauma (MST)",
code: "MST"
},{
issue_id: generate_external_id,
narrative: "PACT",
code: "PACT"
}]
}
end

Expand Down Expand Up @@ -100,5 +119,24 @@ def build_pact_contention(attrs = {})
end
end
end

def build_mst_and_pact_contention(attrs = {})
attrs = default_attrs_with_mst_and_pact.merge(attrs)
claim_id = attrs[:claim_id]
disposition = attrs.delete(:disposition)

OpenStruct.new(attrs).tap do |contention|
Fakes::BGSService.end_product_store.create_contention(contention)

if disposition
disposition_record = OpenStruct.new(
claim_id: claim_id,
contention_id: contention.id,
disposition: disposition
)
Fakes::BGSService.end_product_store.create_disposition(disposition_record)
end
end
end
end
end
114 changes: 114 additions & 0 deletions spec/models/request_issue_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,120 @@
end
end

context "#mst_contention_status?, #pact_contention_status?" do
context "when mst is available and pact is not available" do
let(:claim_id) {"600118959"}
let(:mst_contention) do
Generators::Contention.build_mst_contention(
claim_id: claim_id
)
end
let(:end_prod_establishment) do
create(:end_product_establishment,
reference_id: claim_id
)
end
let(:mst_request_issue) do
create(:request_issue,
contention_reference_id: mst_contention.id,
end_product_establishment: end_prod_establishment
)
end

it "mst_contention_status? is true" do
expect(mst_request_issue.mst_contention_status?).to be true
end

it "pact_contention_status? is false" do
expect(mst_request_issue.pact_contention_status?).to be false
end
end

context "when pact is available and mst is not available" do
let(:claim_id) {"600118959"}
let(:pact_contention) do
Generators::Contention.build_pact_contention(
claim_id: claim_id
)
end
let(:end_prod_establishment) do
create(:end_product_establishment,
reference_id: claim_id
)
end
let(:pact_request_issue) do
create(:request_issue,
contention_reference_id: pact_contention.id,
end_product_establishment: end_prod_establishment
)
end

it "mst_contention_status? is false" do
expect(pact_request_issue.mst_contention_status?).to be false
end

it "pact_contention_status? is true" do
expect(pact_request_issue.pact_contention_status?).to be true
end
end

context "when pact and mst are available" do
let(:claim_id) {"600118959"}
let(:mst_and_pact_contention) do
Generators::Contention.build_mst_and_pact_contention(
claim_id: claim_id
)
end
let(:end_prod_establishment) do
create(:end_product_establishment,
reference_id: claim_id
)
end
let(:mst_and_pact_request_issue) do
create(:request_issue,
contention_reference_id: mst_and_pact_contention.id,
end_product_establishment: end_prod_establishment
)
end

it "mst_contention_status? is true" do
expect(mst_and_pact_request_issue.mst_contention_status?).to be true
end

it "pact_contention_status? is true" do
expect(mst_and_pact_request_issue.pact_contention_status?).to be true
end
end

context "when pact and mst are not available" do
let(:claim_id) {"600118959"}
let(:contention) do
Generators::Contention.build(
claim_id: claim_id
)
end
let(:end_prod_establishment) do
create(:end_product_establishment,
reference_id: claim_id
)
end
let(:request_issue) do
create(:request_issue,
contention_reference_id: contention.id,
end_product_establishment: end_prod_establishment
)
end

it "mst_contention_status? is false" do
expect(request_issue.mst_contention_status?).to be false
end

it "pact_contention_status? is false" do
expect(request_issue.pact_contention_status?).to be false
end
end
end

context "#valid?" do
subject { request_issue.valid? }
let(:request_issue) do
Expand Down

0 comments on commit afb20fb

Please sign in to comment.