-
Notifications
You must be signed in to change notification settings - Fork 8
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
AlecK/APPEALS-44509 - (6.1 Base) #1671
Open
AKeyframe
wants to merge
14
commits into
AlecK/APPEALS-46558
Choose a base branch
from
AlecK/APPEALS-44509-6.1Base
base: AlecK/APPEALS-46558
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
cafdb8e
Added Zeitwerk inflector file
AKeyframe 10edae5
Added Zeitwerk Rspec test
AKeyframe 043d253
Remove classic loading, added eager_load_paths
AKeyframe de7dab4
Added 'to_prepare' wrapper for deprecation warning
AKeyframe ca2ffa8
Added modules for Zeitwerk compliance
AKeyframe 6004e46
CurrentUserLoadTests name changed to singular for ZW compliance
AKeyframe ea90e71
Caseflow gem updated for ZW compliance
AKeyframe 94cb112
Removed uneeded require statements
AKeyframe 5c35d28
Parity changes
AKeyframe 25398a8
fixed ignored files during load
AKeyframe e0056eb
remove log statement
AKeyframe 783be5f
Updated eFolder only BGS:: calls to match new name BGSErrors
AKeyframe 5fb9122
Added `to_prepare` - constant called within before zeitwerk autoloading
AKeyframe 72f60ee
Refactored BGSErrors to preserve current execution
AKeyframe 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require "vva" | ||
|
||
|
||
# Thin interface to talk to Virtual VA | ||
class ExternalApi::VVAService | ||
|
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 |
---|---|---|
@@ -1 +1,3 @@ | ||
BGSService = (!BaseController.dependencies_faked? ? ExternalApi::BGSService : Fakes::BGSService) | ||
Rails.application.reloader.to_prepare do | ||
BGSService = (!BaseController.dependencies_faked? ? ExternalApi::BGSService : Fakes::BGSService) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
VeteranFileFetcher = ExternalApi::VeteranFileFetcher | ||
.new(use_canned_api_responses: BaseController.dependencies_faked_for_CEAPI?, logger: Rails.logger) | ||
Rails.application.reloader.to_prepare do | ||
VeteranFileFetcher = ExternalApi::VeteranFileFetcher | ||
.new(use_canned_api_responses: BaseController.dependencies_faked_for_CEAPI?, logger: Rails.logger) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
S3Service = (Rails.application.config.s3_enabled ? Caseflow::S3Service : Caseflow::Fakes::S3Service) | ||
Rails.application.reloader.to_prepare do | ||
S3Service = (Rails.application.config.s3_enabled ? Caseflow::S3Service : Caseflow::Fakes::S3Service) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
VBMSService = (!BaseController.dependencies_faked? ? ExternalApi::VBMSService : Fakes::VBMSService) | ||
Rails.application.reloader.to_prepare do | ||
VBMSService = (!BaseController.dependencies_faked? ? ExternalApi::VBMSService : Fakes::VBMSService) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
VVAService = (!BaseController.dependencies_faked? ? ExternalApi::VVAService : Fakes::VVAService) | ||
Rails.application.reloader.to_prepare do | ||
VVAService = (!BaseController.dependencies_faked? ? ExternalApi::VVAService : Fakes::VVAService) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
# Zeitwerk has specific requirements for auto/eager loading. See below links for more details | ||
# https://guides.rubyonrails.org/classic_to_zeitwerk_howto.html | ||
# https://github.com/fxn/zeitwerk | ||
|
||
# To sumarize Zeitwerk requires several conditions be met when attempting to auto/eager load | ||
# - The top level namespace must reflect the auto/eager-loadpath / filename. The auto/eager-load | ||
# path will be different from the relative path. See https://github.com/fxn/zeitwerk#file-structure | ||
# - Zeitwerk expects 1 constant per file, anything not under that constant won't be loaded | ||
# - Acronyms aren't implicit. You can use them but you'll need to tell zeitwerk. (More details below) | ||
# - The constant name and file name MUST match, or zeitwerk needs to be told otherwise. | ||
# So file_name.rb should be `module or class FileName` not `FileNames``. | ||
# - Namespaces need to be unique. Depending on the auto/eager-load path, files with the same | ||
# name but located in different directories can cause issues. To avoid this try and name files uniquely as well. | ||
|
||
# Use the command and test below to ensure zeitwerk compliance. | ||
# bin/rails zeitwerk:check | ||
# Alternatively an rspec test has been added, check CI output for details | ||
|
||
Rails.autoloaders.each do |autoloader| | ||
# "file_name" => Expected Module or Class name. | ||
autoloader.inflector.inflect( | ||
"bgs_errors" => "BGSErrors", | ||
"bgs_service" => "BGSService", | ||
"poa_mapper" => "POAMapper", | ||
"vbms_service" => "VBMSService", | ||
"vva_service" => "VVAService" | ||
) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require 'bgs_errors' | ||
|
||
|
||
class Fakes::BGSService | ||
include ActiveModel::Model | ||
|
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 |
---|---|---|
@@ -1,43 +1,48 @@ | ||
require "omniauth/strategies/developer" | ||
require "omniauth/form" | ||
|
||
class EfolderAuthForm < OmniAuth::Form | ||
def hidden_field(name, value) | ||
@html << "\n<input type='hidden' name='#{name}' value='#{value}' />" | ||
self | ||
end | ||
|
||
def header(title, header_info) | ||
@html << <<-HTML | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<title>#{title}</title> | ||
#{css} | ||
#{header_info} | ||
</head> | ||
<body> | ||
<h1>#{title}</h1> | ||
<form method='post' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'> | ||
HTML | ||
self | ||
end | ||
end | ||
module Fakes | ||
module TestAuthStrategy | ||
class EfolderAuthForm < OmniAuth::Form | ||
def hidden_field(name, value) | ||
@html << "\n<input type='hidden' name='#{name}' value='#{value}' />" | ||
self | ||
end | ||
|
||
class OmniAuth::Strategies::TestAuthStrategy < OmniAuth::Strategies::Developer | ||
# custom form rendering | ||
def request_phase | ||
form = EfolderAuthForm.new(title: "Test VA Saml", url: callback_path) | ||
form.hidden_field :username, session["login"]["username"] | ||
form.hidden_field :station_id, session["login"]["station_id"] | ||
form.button "Fake PIV Login" | ||
form.to_response | ||
end | ||
def header(title, header_info) | ||
@html << <<-HTML | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
<title>#{title}</title> | ||
#{css} | ||
#{header_info} | ||
</head> | ||
<body> | ||
<h1>#{title}</h1> | ||
<form method='post' #{"action='#{options[:url]}' " if options[:url]}noValidate='noValidate'> | ||
HTML | ||
self | ||
end | ||
end | ||
|
||
class OmniAuth::Strategies::TestAuthStrategy < OmniAuth::Strategies::Developer | ||
# custom form rendering | ||
def request_phase | ||
form = EfolderAuthForm.new(title: "Test VA Saml", url: callback_path) | ||
form.hidden_field :username, session["login"]["username"] | ||
form.hidden_field :station_id, session["login"]["station_id"] | ||
form.button "Fake PIV Login" | ||
form.to_response | ||
end | ||
|
||
def auth_hash | ||
hash = super | ||
hash.uid = hash["info"]["css_id"] | ||
hash | ||
def auth_hash | ||
hash = super | ||
hash.uid = hash["info"]["css_id"] | ||
hash | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
require "rails_helper" | ||
|
||
# See config/initializers/zeitwerk.rb if this fails | ||
RSpec.describe "Zeitwerk Compliance Check" do | ||
it "Eager loads all files without errors" do | ||
expect { Rails.application.eager_load! }.not_to raise_error | ||
end | ||
end | ||
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For conformity w/ Caseflow, let's move this file to |
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.
Let's move the Zeitwerk inflector settings here (before
config.autoload_paths
) and delete the initializer, as was done for Caseflow in this commit.This is a precautionary move, to circumvent potential sequencing issues when autoloading inflected constants in the
autoload_once_paths
(via theonce
autoloader).We are not currently autloading anything with the
once
autoloader, but if down the road we need to, this will be one less gotcha we'll have to deal with.For more details on this issue, see rails/rails#45568