This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Make gem compatible with Rails 7 #321
Merged
kennyadsl
merged 10 commits into
solidusio:master
from
gsmendoza:gsmendoza/eng-355-fix-autoloading-issues-with
Jun 16, 2022
Merged
Make gem compatible with Rails 7 #321
kennyadsl
merged 10 commits into
solidusio:master
from
gsmendoza:gsmendoza/eng-355-fix-autoloading-issues-with
Jun 16, 2022
Conversation
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
Fixes `Webdrivers::BrowserNotFound: Failed to find Chrome binary` errors in CircleCI.
Output: ``` solidus_paypal_braintree 15:03:48 $ bundle exec rubocop --autocorrect Inspecting 76 files C..............................................CC..C........CCC.......C..... Offenses: Gemfile:23:6: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('DB') or ENV.fetch('DB', nil) instead of ENV['DB']. case ENV['DB'] ^^^^^^^^^ solidus_paypal_braintree.gemspec:22:3: C: [Corrected] Gemspec/DeprecatedAttributeAssignment: Do not set test_files in gemspec. s.test_files = Dir['spec/**/*'] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:57:14: C: [Correctable] RSpec/ExpectChange: Prefer change(SolidusPaypalBraintree::Source, :count). to change { SolidusPaypalBraintree::Source.count }. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:91:39: C: [Correctable] RSpec/ExpectChange: Prefer change(::Spree::Payment, :count). expect{ patch_update }.not_to(change{ ::Spree::Payment.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:95:39: C: [Correctable] RSpec/ExpectChange: Prefer change(SolidusPaypalBraintree::Source, :count). expect{ patch_update }.not_to(change{ SolidusPaypalBraintree::Source.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:103:37: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.to change { Spree::Address.count }.by(1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:116:37: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.to change { Spree::Address.count }.by(1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:126:41: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.not_to(change { Spree::Address.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/avs_result_spec.rb:9:25: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. instance_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/avs_result_spec.rb:30:25: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. instance_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:423:50: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. subject { gateway.try_void(instance_double('Spree::Payment', response_code: source.token)) } ^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:426:22: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. class_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:431:34: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. client = instance_double('Braintree::Gateway') ^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:438:27: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. instance_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:476:27: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. instance_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/gateway_spec.rb:488:27: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. instance_double('Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:7:7: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::ValidationError', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:15:7: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::ErrorResult', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:29:7: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:39:7: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::SuccessfulResult', ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:83:13: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:102:13: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:120:13: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:139:13: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:156:13: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:189:11: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/models/solidus_paypal_braintree/response_spec.rb:235:11: C: [Corrected] RSpec/VerifiedDoubleReference: Use a constant class reference for verified doubles. 'Braintree::Transaction', ^^^^^^^^^^^^^^^^^^^^^^^^ spec/support/capybara.rb:7:30: C: [Corrected] Style/RedundantParentheses: Don't use parentheses around a method call. Capybara.javascript_driver = (ENV.fetch('CAPYBARA_DRIVER', :selenium_chrome)).to_sym ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/support/capybara.rb:7:31: C: [Corrected] Style/FetchEnvVar: Use ENV.fetch('CAPYBARA_DRIVER', :selenium_chrome) instead of ENV['CAPYBARA_DRIVER'] || :selenium_chrome. Capybara.javascript_driver = (ENV['CAPYBARA_DRIVER'] || :selenium_chrome).to_sym ^^^^^^^^^^^^^^^^^^^^^^ 76 files inspected, 29 offenses detected, 23 offenses corrected, 6 more offenses can be corrected with `rubocop -A` ```
For some reason, RuboCop is unable to autocorrect these. RuboCop output: ``` solidus_paypal_braintree 15:12:20 $ bundle exec rubocop --autocorrect Inspecting 76 files ................................................C..C........................ Offenses: spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:56:36: C: [Correctable] RSpec/ExpectChange: Prefer change(SolidusPaypalBraintree::Source, :count). expect { patch_update }.to change { SolidusPaypalBraintree::Source.count }.from(0).to(1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:88:39: C: [Correctable] RSpec/ExpectChange: Prefer change(::Spree::Payment, :count). expect{ patch_update }.not_to(change{ ::Spree::Payment.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/checkouts_controller_spec.rb:92:39: C: [Correctable] RSpec/ExpectChange: Prefer change(SolidusPaypalBraintree::Source, :count). expect{ patch_update }.not_to(change{ SolidusPaypalBraintree::Source.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:103:37: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.to change { Spree::Address.count }.by(1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:116:37: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.to change { Spree::Address.count }.by(1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ spec/controllers/solidus_paypal_braintree/transactions_controller_spec.rb:126:41: C: [Correctable] RSpec/ExpectChange: Prefer change(Spree::Address, :count). expect { post_create }.not_to(change { Spree::Address.count }) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 76 files inspected, 6 offenses detected, 6 more offenses can be corrected with `rubocop -A` ```
Remove Bundler workaround. No longer needed.
Will be reenabled once Venmo is enabled on the Braintree sandbox.
Fixes `NameError: uninitialized constant SolidusPaypalBraintree::Gateway` when running `bundle exec rake`
Fixes `NameError: uninitialized constant SolidusPaypalBraintree::Spree::PermittedAttributes` when running `bundle exec rake`.
…idempotent For historical reasons, the `to_prepare` callback may run twice. The code it executes must be idempotent. See https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#autoload-on-boot-and-on-each-reload.
gsmendoza
commented
Jun 16, 2022
SolidusPaypalBraintree::Gateway.allowed_admin_form_preference_types << :preference_select | ||
Spree::PermittedAttributes.source_attributes.concat [:nonce, :payment_type, :paypal_funding_source] | ||
config.to_prepare do | ||
app.config.spree.payment_methods << SolidusPaypalBraintree::Gateway |
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.
This append
call is already idempotent since app.config.spree.payment_methods
is a Set object
kennyadsl
approved these changes
Jun 16, 2022
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.
Thanks George!
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Main changes
register_solidus_paypal_braintree_gateway
initializer for Rails 7. See https://guides.rubyonrails.org/autoloading_and_reloading_constants.html.