Skip to content

Commit 9aecff3

Browse files
committed
Use bare config accessors
Replace Spree::Config and Spree::Auth::Config[:foo] with the bare accessors. Both dispatch to the same preferred_foo body; the bare form skips has_preference!'s array scan and matches the form used by Solidus core and most of this codebase. A store that overrides preferred_foo on a configuration class no longer affects these reads. Nothing in this workspace does that.
1 parent 8763062 commit 9aecff3

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To enable Devise's Confirmable module, which will send the user an email with a
3636
* Add this line to an initializer in your Rails project (typically `config/initializers/spree.rb`):
3737

3838
```ruby
39-
Spree::Auth::Config[:confirmable] = true
39+
Spree::Auth::Config.confirmable = true
4040
```
4141

4242
* Add a Devise initializer to your Rails project (typically `config/initializers/devise.rb`):

‎app/models/spree/user.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class User < Spree::Base
77

88
devise :database_authenticatable, :registerable, :recoverable,
99
:rememberable, :trackable, :validatable, :encryptable
10-
devise :confirmable if Spree::Auth::Config[:confirmable]
10+
devise :confirmable if Spree::Auth::Config.confirmable
1111

1212
after_destroy :scramble_email_and_password
1313
after_discard :scramble_email_and_password

‎config/routes.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
post "/password/recover", to: "user_passwords#create", as: :reset_password
2929
get "/password/change", to: "user_passwords#edit", as: :edit_password
3030
put "/password/change", to: "user_passwords#update", as: :update_password
31-
get "/confirm", to: "user_confirmations#show", as: :confirmation if Spree::Auth::Config[:confirmable]
31+
get "/confirm", to: "user_confirmations#show", as: :confirmation if Spree::Auth::Config.confirmable
3232
end
3333

3434
get "/checkout/registration", to: "checkout#registration", as: :checkout_registration

‎lib/controllers/frontend/spree/users_controller.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def update
3838

3939
if params[:user][:password].present?
4040
# this logic needed b/c devise wants to log us out after password changes
41-
if Spree::Auth::Config[:signout_after_password_change]
41+
if Spree::Auth::Config.signout_after_password_change
4242
redirect_url = spree.login_url
4343
else
4444
bypass_sign_in(@user)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# frozen_string_literal: true
22

33
Devise.secret_key = '<%= SecureRandom.hex(64) %>'
4-
Devise.email_regexp = Spree::Config[:default_email_regexp]
4+
Devise.email_regexp = Spree::Config.default_email_regexp

‎lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def check_registration
5050
end
5151

5252
def registration_required?
53-
Spree::Auth::Config[:registration_step] &&
53+
Spree::Auth::Config.registration_step &&
5454
!already_registered?
5555
end
5656

@@ -60,7 +60,7 @@ def already_registered?
6060

6161
def guest_authenticated?
6262
current_order&.email.present? &&
63-
Spree::Config[:allow_guest_checkout]
63+
Spree::Config.allow_guest_checkout
6464
end
6565

6666
# Overrides the equivalent method defined in Spree::Core. This variation of the method will ensure that users

‎lib/views/frontend/spree/checkout/registration.html.erb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div id="account" class="columns alpha eight">
55
<%= render template: 'spree/user_sessions/new' %>
66
</div>
7-
<% if Spree::Config[:allow_guest_checkout] %>
7+
<% if Spree::Config.allow_guest_checkout %>
88
<div id="guest_checkout" data-hook class="columns omega eight">
99
<h6><%= t('spree.guest_user_account') %></h6>
1010
<% if flash[:registration_error] %>

0 commit comments

Comments
 (0)