-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automated] Merged master into target k8s
- Loading branch information
Showing
13 changed files
with
235 additions
and
3 deletions.
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 |