-
Notifications
You must be signed in to change notification settings - Fork 19
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
Missing Ratings | Add current rating profile endpoint to Caseflow #15172
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0258827
Add current rating profile endpoint to BGSService
nanotone dd43bdf
Add initial implementation of CurrentRating
nanotone 93a1500
Always include issues with current rating profiles
nanotone 7286a8c
Add a fake implementation for current rating
nanotone 3ba7dee
Address some lint warnings
nanotone 74810b4
Add class description for CurrentRating
nanotone 59deabb
Add tests and fix intentional spelling mismatch
nanotone c9ed52e
Fix lint warnings
nanotone 497cc42
Use rating_at_issue_profile_data to format fakes
nanotone b8f9078
Merge branch 'master' into nanotone/14839-current-rating-profile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
# CurrentRating provides a Rating implementation based on data returned by the BGS endpoint | ||
# rating_profile.find_current_rating_profile_by_ptcpnt_id. Unlike its siblings RatingAtIssue | ||
# and PromulgatedRating, this fetches a single rating per call. Thus, fetch_in_range and | ||
# ratings_from_bgs_response are left unimplemented, and a few other methods aren't used. | ||
|
||
class CurrentRating < Rating | ||
class << self | ||
def fetch_by_participant_id(participant_id) | ||
from_bgs_hash(BGSService.new.find_current_rating_profile_by_ptcpnt_id(participant_id)) | ||
rescue BGS::ShareError | ||
nil | ||
end | ||
|
||
def from_bgs_hash(data) | ||
new( | ||
participant_id: data[:ptcpnt_vet_id], | ||
profile_date: data[:prfl_dt], | ||
promulgation_date: data[:prmlgn_dt], | ||
rating_profile: data | ||
) | ||
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,68 @@ | ||
# frozen_string_literal: true | ||
|
||
describe CurrentRating do | ||
describe "#fetch_by_participant_id" do | ||
let(:bgs) { double("BGSService") } | ||
let(:pid) { "12345" } | ||
before do | ||
allow(BGSService).to receive(:new) { bgs } | ||
end | ||
|
||
subject { CurrentRating.fetch_by_participant_id(pid) } | ||
|
||
context "when participant exists" do | ||
let(:bgs_hash) do | ||
{ ptcpnt_vet_id: pid } | ||
end | ||
before do | ||
allow(bgs).to receive(:find_current_rating_profile_by_ptcpnt_id).with(pid).and_return(bgs_hash) | ||
end | ||
|
||
it "returns a current rating object" do | ||
expect(subject.participant_id).to eq(pid) | ||
end | ||
end | ||
|
||
context "when participant doesn't exist" do | ||
let(:error) { BGS::ShareError.new_from_message("message", 500) } | ||
before do | ||
allow(bgs).to receive(:find_current_rating_profile_by_ptcpnt_id).with(pid).and_raise(error) | ||
end | ||
|
||
it { is_expected.to be_nil } | ||
end | ||
end | ||
|
||
describe "#from_bgs_hash" do | ||
let(:yesterday) { DateTime.yesterday } | ||
let(:bgs_hash) do | ||
{ | ||
ptcpnt_vet_id: "participant ID", | ||
prfl_dt: yesterday, | ||
prmlgn_dt: yesterday, | ||
rating_issues: [ | ||
{ | ||
rba_issue_id: "rating issue ID", | ||
decn_txt: "issue description text" | ||
} | ||
], | ||
disabilities: [ | ||
{ | ||
decn_tn: "Service Connected", | ||
dis_sn: "disability ID" | ||
} | ||
], | ||
associated_claims: { clm_id: "EP claim ID", bnft_clm_tc: "600PRI" } | ||
} | ||
end | ||
|
||
it "hydrates an object that behaves like a Rating" do | ||
rating = CurrentRating.from_bgs_hash(bgs_hash) | ||
expect(rating.participant_id).to eq("participant ID") | ||
expect(rating.profile_date).to eq(yesterday) | ||
expect(rating.promulgation_date).to eq(yesterday) | ||
expect(rating.issues[0].reference_id).to eq("rating issue ID") | ||
expect(rating.associated_end_products[0].claim_id).to eq("EP claim ID") | ||
end | ||
end | ||
end |
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.
Nice! You caught that.