-
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
dbex/77177: EVSS Migration - /generatePDF migration: Abstract references to EVSS /getpdf #16080
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
350cc0f
dbex/77177: add GeneratePdfProvider
aurora-a-k-a-lightning cb22231
dbex/77177: add GeneratePdfProvider
aurora-a-k-a-lightning a7c4e3b
dbex/77177: add GeneratePdfProvider
aurora-a-k-a-lightning d5327d2
dbex/77177: add GeneratePdfProvider
aurora-a-k-a-lightning 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
22 changes: 22 additions & 0 deletions
22
lib/disability_compensation/providers/generate_pdf/evss_generate_pdf_provider.rb
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'disability_compensation/providers/generate_pdf/generate_pdf_provider' | ||
require 'evss/disability_compensation_form/service' | ||
require 'evss/disability_compensation_form/non_breakered_service' | ||
|
||
class EvssGeneratePdfProvider | ||
include GeneratePdfProvider | ||
|
||
def initialize(auth_headers, breakered: true) | ||
# both of these services implement `get_form526` | ||
@service = if breakered | ||
EVSS::DisabilityCompensationForm::Service.new(auth_headers) | ||
else | ||
EVSS::DisabilityCompensationForm::NonBreakeredService.new(auth_headers) | ||
end | ||
end | ||
|
||
def generate_526_pdf(form_content) | ||
@service.get_form526(form_content) | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
lib/disability_compensation/providers/generate_pdf/generate_pdf_provider.rb
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,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module GeneratePdfProvider | ||
def self.generate_526_pdf(_form_content) | ||
raise NotImplementedError, 'Do not use base module methods. Override this method in implementation class.' | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
lib/disability_compensation/providers/generate_pdf/lighthouse_generate_pdf_provider.rb
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'disability_compensation/providers/generate_pdf/generate_pdf_provider' | ||
|
||
class LighthouseGeneratePdfProvider | ||
include GeneratePdfProvider | ||
|
||
def initialize(_auth_headers) | ||
# TODO: Implement in Ticket# | ||
end | ||
|
||
def generate_526_pdf(_form_content) | ||
# TODO: Implement in Ticket# | ||
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
48 changes: 48 additions & 0 deletions
48
spec/lib/disability_compensation/providers/generate_pdf/evss_generate_pdf_provider_spec.rb
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,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'disability_compensation/factories/api_provider_factory' | ||
require 'disability_compensation/providers/generate_pdf/evss_generate_pdf_provider' | ||
require 'support/disability_compensation_form/shared_examples/generate_pdf_service_provider' | ||
|
||
RSpec.describe EvssGeneratePdfProvider do | ||
let(:current_user) do | ||
create(:user) | ||
end | ||
|
||
let(:auth_headers) do | ||
EVSS::AuthHeaders.new(current_user).to_h | ||
end | ||
|
||
before do | ||
Flipper.disable(ApiProviderFactory::FEATURE_TOGGLE_GENERATE_PDF) | ||
end | ||
|
||
after do | ||
Flipper.disable(ApiProviderFactory::FEATURE_TOGGLE_GENERATE_PDF) | ||
end | ||
|
||
it_behaves_like 'generate pdf service provider' | ||
|
||
it 'creates a breakered evss service' do | ||
provider = EvssGeneratePdfProvider.new(auth_headers) | ||
expect(provider.instance_variable_get(:@service).class).to equal(EVSS::DisabilityCompensationForm::Service) | ||
|
||
provider = EvssGeneratePdfProvider.new(auth_headers, breakered: true) | ||
expect(provider.instance_variable_get(:@service).class).to equal(EVSS::DisabilityCompensationForm::Service) | ||
end | ||
|
||
it 'creates a non-breakered evss service' do | ||
provider = EvssGeneratePdfProvider.new(auth_headers, breakered: false) | ||
expect(provider.instance_variable_get(:@service).class) | ||
.to equal(EVSS::DisabilityCompensationForm::NonBreakeredService) | ||
end | ||
|
||
it 'retrieves a generated 526 pdf from the EVSS API' do | ||
VCR.use_cassette('form526_backup/200_evss_get_pdf', match_requests_on: %i[uri method]) do | ||
provider = EvssGeneratePdfProvider.new(auth_headers) | ||
response = provider.generate_526_pdf({}.to_json) | ||
expect(response.body['pdf']).to eq('<big long pdf string, but not required here>') | ||
end | ||
end | ||
end |
12 changes: 12 additions & 0 deletions
12
spec/lib/disability_compensation/providers/generate_pdf/generate_pdf_provider_spec.rb
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'disability_compensation/providers/generate_pdf/generate_pdf_provider' | ||
|
||
RSpec.describe GeneratePdfProvider do | ||
it 'always raises an error on the BRDProvider base module' do | ||
expect do | ||
subject.generate_526_pdf({}) | ||
end.to raise_error NotImplementedError | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
...b/disability_compensation/providers/generate_pdf/lighthouse_generate_pdf_provider_spec.rb
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
require 'disability_compensation/factories/api_provider_factory' | ||
require 'disability_compensation/providers/generate_pdf/lighthouse_generate_pdf_provider' | ||
require 'support/disability_compensation_form/shared_examples/generate_pdf_service_provider' | ||
require 'lighthouse/service_exception' | ||
|
||
RSpec.describe LighthouseGeneratePdfProvider do | ||
let(:auth_headers) { {} } | ||
|
||
before do | ||
@provider = LighthouseGeneratePdfProvider.new(auth_headers) | ||
Flipper.enable(ApiProviderFactory::FEATURE_TOGGLE_GENERATE_PDF) | ||
end | ||
|
||
after do | ||
Flipper.disable(ApiProviderFactory::FEATURE_TOGGLE_GENERATE_PDF) | ||
end | ||
|
||
it_behaves_like 'generate pdf service provider' | ||
|
||
# TODO: Implement in Ticket# | ||
# it 'retrieves a generated 526 pdf from the Lighthouse API' do | ||
# VCR.use_cassette('lighthouse/benefits_claims/generate_pdf/200_response') do | ||
# | ||
# response = @provider.generate_526_pdf | ||
# expect(response).to eq(nil) | ||
# 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
10 changes: 10 additions & 0 deletions
10
spec/support/disability_compensation_form/shared_examples/generate_pdf_service_provider.rb
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,10 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
shared_examples 'generate pdf service provider' do | ||
# this is used to instantiate any Claim Service with a current_user | ||
subject { described_class.new(auth_headers) } | ||
|
||
it { is_expected.to respond_to(:generate_526_pdf) } | ||
end |
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.
I think if @options[:auth_headers].blank? will cover both nil and empty scenarios here