spree_auth_devise 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a85c3ec56e4d12970bf8abf6f8365a688cea123c9be66d5e7d9581ca51468bbc
4
- data.tar.gz: 6cd1ecf12edd93fc0ff505c9d21eadf139f218f1fd2be0870d64d68d833fa712
3
+ metadata.gz: be1bc8fb18988dfe1cc0e8f65220f824ce8553236a265add61e9530d11fe6c7c
4
+ data.tar.gz: 369edc99327bb03195a2c07007c9817c47036033db071b4c65da4567fa212505
5
5
  SHA512:
6
- metadata.gz: 3b55e45f4cd927c1d3a0509f9c4d04ff60d03f1453cb2878911ddd4137834d338cf506db686572ab17e5bc99534dffbc822b36201c92bc6f6a58b1480d8a0041
7
- data.tar.gz: 1edd8464cdef3be084845fb5eef65e33b9ac86c82e7fb19c35ab6acd29ad60e4a69114bf3a3917f14e150367b0df426c0a85b8340e5110e0443c3c41520f38d8
6
+ metadata.gz: e8a5ab6f8ccc9d79f8a7767d213f08ef5e60fdb7c6b77640f2ef2719432a695de5bd64e480e818f444a16ca480d1daf45d524dbe1521405e7eab67e97e948791
7
+ data.tar.gz: 0ed79a471adfb6ff76d1d12a5302a6355e14362dd9318278c0810e2b7ddfc3e102b31c17f22b0d227ada3c9affdc7b8dbac264a52a295e158b1f15594f862b68
data/.circleci/config.yml CHANGED
@@ -9,61 +9,23 @@ defaults: &defaults
9
9
  BUNDLE_PATH: ~/spree/vendor/bundle
10
10
  working_directory: ~/spree
11
11
  docker:
12
- - image: &ruby_image circleci/ruby:2.7-node-browsers
12
+ - image: &ruby_image circleci/ruby:3.0-node-browsers
13
13
  - image: &redis_image circleci/redis:6.2-alpine
14
14
 
15
- defaults_3_0: &defaults_3_0
16
- <<: *defaults
17
- docker:
18
- - image: &ruby_3_0_image circleci/ruby:3.0-node-browsers
19
- - image: *redis_image
20
-
21
15
  run_tests: &run_tests
22
16
  <<: *defaults
23
- steps:
24
- - checkout
25
- - restore_cache:
26
- keys:
27
- - spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
28
- - spree-auth-devise-bundle-v9-ruby-2-7
29
- - run:
30
- name: Install libvips
31
- command: sudo apt-get install libvips
32
- - run:
33
- name: Set bundle path
34
- command: bundle config --local path vendor/bundle
35
- - run:
36
- name: Ensure bundle Install
37
- command: |
38
- bundle check || bundle install
39
- - run:
40
- name: Create test app
41
- command: |
42
- bundle exec rake test_app
43
- - run:
44
- name: Run Rspec
45
- command: |
46
- TESTFILES=$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
47
- bundle exec rspec --format documentation \
48
- --format RspecJunitFormatter \
49
- -o ~/rspec/rspec.xml \
50
- -- ${TESTFILES}
51
- - store_test_results:
52
- path: ~/rspec
53
- - store_artifacts:
54
- path: tmp/capybara
55
-
56
- run_tests_3_0: &run_tests_3_0
57
- <<: *defaults_3_0
58
17
  steps:
59
18
  - checkout
60
19
  - restore_cache:
61
20
  keys:
62
21
  - spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
63
22
  - spree-auth-devise-bundle-v9-ruby-3-0
23
+ - run:
24
+ name: Add keyserver
25
+ command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
64
26
  - run:
65
27
  name: Install libvips
66
- command: sudo apt-get install libvips
28
+ command: sudo apt-get update && sudo apt-get install libvips
67
29
  - run:
68
30
  name: Set bundle path
69
31
  command: bundle config --local path vendor/bundle
@@ -91,38 +53,18 @@ run_tests_3_0: &run_tests_3_0
91
53
  jobs:
92
54
  bundle:
93
55
  <<: *defaults
94
- steps:
95
- - checkout
96
- - restore_cache:
97
- keys:
98
- - spree-auth-devise-bundle-v9-ruby-2-7-{{ .Branch }}
99
- - spree-auth-devise-bundle-v9-ruby-2-7
100
- - run:
101
- name: Install libvips
102
- command: sudo apt-get install libvips
103
- - run:
104
- name: Set bundle path
105
- command: bundle config --local path vendor/bundle
106
- - run:
107
- name: Bundle Install
108
- command: |
109
- bundle check || bundle install
110
- - save_cache:
111
- paths:
112
- - vendor/bundle
113
- key: spree-auth-devise-bundle-v9-ruby-2-7-{{ checksum "Gemfile.lock" }}
114
-
115
- bundle_ruby_3_0:
116
- <<: *defaults_3_0
117
56
  steps:
118
57
  - checkout
119
58
  - restore_cache:
120
59
  keys:
121
60
  - spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
122
61
  - spree-auth-devise-bundle-v9-ruby-3-0
62
+ - run:
63
+ name: Add keyserver
64
+ command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
123
65
  - run:
124
66
  name: Install libvips
125
- command: sudo apt-get install libvips
67
+ command: sudo apt-get update && sudo apt-get install libvips
126
68
  - run:
127
69
  name: Set bundle path
128
70
  command: bundle config --local path vendor/bundle
@@ -149,15 +91,6 @@ jobs:
149
91
  environment:
150
92
  POSTGRES_USER: postgres
151
93
 
152
- tests_postgres_ruby_3_0: &tests_postgres_ruby_3_0
153
- <<: *run_tests_3_0
154
- environment:
155
- <<: *postgres_environment
156
- docker:
157
- - image: *ruby_3_0_image
158
- - image: *postgres_image
159
- - image: *redis_image
160
-
161
94
  tests_mysql: &tests_mysql
162
95
  <<: *run_tests
163
96
  environment: &mysql_environment
@@ -177,13 +110,9 @@ workflows:
177
110
  main:
178
111
  jobs:
179
112
  - bundle
180
- - bundle_ruby_3_0
181
113
  - tests_postgres:
182
114
  requires:
183
115
  - bundle
184
- - tests_postgres_ruby_3_0:
185
- requires:
186
- - bundle_ruby_3_0
187
116
  - tests_mysql:
188
117
  requires:
189
118
  - bundle
data/config/routes.rb CHANGED
@@ -1,52 +1,54 @@
1
1
  Spree::Core::Engine.add_routes do
2
- devise_for :spree_user,
3
- class_name: Spree.user_class.to_s,
4
- controllers: { sessions: 'spree/user_sessions',
5
- registrations: 'spree/user_registrations',
6
- passwords: 'spree/user_passwords',
7
- confirmations: 'spree/user_confirmations' },
8
- skip: [:unlocks, :omniauth_callbacks],
9
- path_names: { sign_out: 'logout' },
10
- path_prefix: :user
2
+ scope '(:locale)', locale: /#{Spree.available_locales.join('|')}/, defaults: { locale: nil } do
3
+ devise_for :spree_user,
4
+ class_name: Spree.user_class.to_s,
5
+ controllers: { sessions: 'spree/user_sessions',
6
+ registrations: 'spree/user_registrations',
7
+ passwords: 'spree/user_passwords',
8
+ confirmations: 'spree/user_confirmations' },
9
+ skip: [:unlocks, :omniauth_callbacks],
10
+ path_names: { sign_out: 'logout' },
11
+ path_prefix: :user
11
12
 
12
- devise_scope :spree_user do
13
- get '/login' => 'user_sessions#new', :as => :login
14
- post '/login' => 'user_sessions#create', :as => :create_new_session
15
- get '/logout' => 'user_sessions#destroy', :as => :logout
16
- get '/signup' => 'user_registrations#new', :as => :signup
17
- post '/signup' => 'user_registrations#create', :as => :registration
18
- get '/password/recover' => 'user_passwords#new', :as => :recover_password
19
- post '/password/recover' => 'user_passwords#create', :as => :reset_password
20
- get '/password/change' => 'user_passwords#edit', :as => :edit_password
21
- put '/password/change' => 'user_passwords#update', :as => :update_password
22
- get '/confirm' => 'user_confirmations#show', :as => :confirmation
23
- end
13
+ devise_scope :spree_user do
14
+ get '/login' => 'user_sessions#new', :as => :login
15
+ post '/login' => 'user_sessions#create', :as => :create_new_session
16
+ get '/logout' => 'user_sessions#destroy', :as => :logout
17
+ get '/signup' => 'user_registrations#new', :as => :signup
18
+ post '/signup' => 'user_registrations#create', :as => :registration
19
+ get '/password/recover' => 'user_passwords#new', :as => :recover_password
20
+ post '/password/recover' => 'user_passwords#create', :as => :reset_password
21
+ get '/password/change' => 'user_passwords#edit', :as => :edit_password
22
+ put '/password/change' => 'user_passwords#update', :as => :update_password
23
+ get '/confirm' => 'user_confirmations#show', :as => :confirmation
24
+ end
24
25
 
25
- if Spree::Core::Engine.frontend_available?
26
- resources :users, only: [:edit, :update]
27
- get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
28
- put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
29
- resource :account, controller: 'users'
30
- end
26
+ if Spree::Core::Engine.frontend_available?
27
+ resources :users, only: [:edit, :update]
28
+ get '/checkout/registration' => 'checkout#registration', :as => :checkout_registration
29
+ put '/checkout/registration' => 'checkout#update_registration', :as => :update_checkout_registration
30
+ resource :account, controller: 'users'
31
+ end
31
32
 
32
- if Spree.respond_to?(:admin_path) && Spree::Core::Engine.backend_available?
33
- namespace :admin, path: Spree.admin_path do
34
- devise_for :spree_user,
35
- class_name: Spree.user_class.to_s,
36
- controllers: { sessions: 'spree/admin/user_sessions',
37
- passwords: 'spree/admin/user_passwords' },
38
- skip: [:unlocks, :omniauth_callbacks, :registrations],
39
- path_names: { sign_out: 'logout' },
40
- path_prefix: :user
41
- devise_scope :spree_user do
42
- get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
43
- get '/login' => 'user_sessions#new', :as => :login
44
- post '/login' => 'user_sessions#create', :as => :create_new_session
45
- get '/logout' => 'user_sessions#destroy', :as => :logout
46
- get '/password/recover' => 'user_passwords#new', :as => :recover_password
47
- post '/password/recover' => 'user_passwords#create', :as => :reset_password
48
- get '/password/change' => 'user_passwords#edit', :as => :edit_password
49
- put '/password/change' => 'user_passwords#update', :as => :update_password
33
+ if Spree.respond_to?(:admin_path) && Spree::Core::Engine.backend_available?
34
+ namespace :admin, path: Spree.admin_path do
35
+ devise_for :spree_user,
36
+ class_name: Spree.user_class.to_s,
37
+ controllers: { sessions: 'spree/admin/user_sessions',
38
+ passwords: 'spree/admin/user_passwords' },
39
+ skip: [:unlocks, :omniauth_callbacks, :registrations],
40
+ path_names: { sign_out: 'logout' },
41
+ path_prefix: :user
42
+ devise_scope :spree_user do
43
+ get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized
44
+ get '/login' => 'user_sessions#new', :as => :login
45
+ post '/login' => 'user_sessions#create', :as => :create_new_session
46
+ get '/logout' => 'user_sessions#destroy', :as => :logout
47
+ get '/password/recover' => 'user_passwords#new', :as => :recover_password
48
+ post '/password/recover' => 'user_passwords#create', :as => :reset_password
49
+ get '/password/change' => 'user_passwords#edit', :as => :edit_password
50
+ put '/password/change' => 'user_passwords#update', :as => :update_password
51
+ end
50
52
  end
51
53
  end
52
54
  end
@@ -94,7 +94,7 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
94
94
  scope = Devise::Mapping.find_scope!(resource)
95
95
  router_name = Devise.mappings[scope].router_name
96
96
  context = router_name ? send(router_name) : self
97
- context.respond_to?(:login_path) ? context.login_path : "/login"
97
+ context.respond_to?(:login_path) ? context.login_path(locale_param) : spree.root_path
98
98
  end
99
99
 
100
100
  private
@@ -104,7 +104,9 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
104
104
  end
105
105
 
106
106
  def spree_user_params
107
- params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
107
+ user_params = params.require(:spree_user).permit(Spree::PermittedAttributes.user_attributes)
108
+ user_params[:selected_locale] = current_locale
109
+ user_params
108
110
  end
109
111
 
110
112
  def after_sign_in_redirect(resource_or_scope)
@@ -81,6 +81,6 @@ class Spree::UserSessionsController < Devise::SessionsController
81
81
  scope = Devise::Mapping.find_scope!(resource_or_scope)
82
82
  router_name = Devise.mappings[scope].router_name
83
83
  context = router_name ? send(router_name) : self
84
- context.respond_to?(:login_path) ? context.login_path : spree.root_path
84
+ context.respond_to?(:login_path) ? context.login_path(locale_param) : spree.root_path
85
85
  end
86
86
  end
@@ -23,7 +23,7 @@ class Spree::UsersController < Spree::StoreController
23
23
 
24
24
  redirect_back_or_default(root_url)
25
25
  else
26
- render :new
26
+ render :new, status: :unprocessable_entity
27
27
  end
28
28
  end
29
29
 
@@ -41,7 +41,7 @@ class Spree::UsersController < Spree::StoreController
41
41
  end
42
42
  redirect_to spree.account_path, notice: Spree.t(:account_updated)
43
43
  else
44
- render :edit
44
+ render :edit, status: :unprocessable_entity
45
45
  end
46
46
  end
47
47
 
@@ -1,10 +1,33 @@
1
1
  module Spree
2
2
  module Auth
3
- class Configuration < Preferences::Configuration
4
- preference :registration_step, :boolean, default: true
5
- preference :signout_after_password_change, :boolean, default: true
6
- preference :confirmable, :boolean, default: false
7
- preference :validatable, :boolean, default: true
3
+ class Configuration
4
+ attr_accessor :registration_step,
5
+ :signout_after_password_change,
6
+ :confirmable,
7
+ :validatable
8
+
9
+ def initialize
10
+ self.registration_step = true
11
+ self.signout_after_password_change = true
12
+ self.confirmable = false
13
+ self.validatable = true
14
+ end
15
+
16
+ def configure
17
+ yield(self) if block_given?
18
+ end
19
+
20
+ def get(preference)
21
+ send(preference)
22
+ end
23
+
24
+ alias [] get
25
+
26
+ def set(preference, value)
27
+ send("#{preference}=", value)
28
+ end
29
+
30
+ alias []= set
8
31
  end
9
32
  end
10
33
  end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  module Auth
3
- VERSION = '4.5.0'.freeze
3
+ VERSION = '4.6.0'.freeze
4
4
 
5
5
  def gem_version
6
6
  Gem::Version.new(VERSION)
@@ -6,13 +6,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
6
6
  before do
7
7
  allow(controller).to receive(:current_order) { order }
8
8
  allow(order).to receive(:confirmation_required?) { true }
9
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr') if Spree.version.to_f >= 4.2
9
10
  end
10
11
 
11
12
  context '#edit' do
12
13
  context 'when registration step enabled' do
13
14
  before do
14
15
  allow(controller).to receive(:check_authorization)
15
- Spree::Auth::Config.set(registration_step: true)
16
+ Spree::Auth::Config.set(:registration_step, true)
16
17
  end
17
18
 
18
19
  context 'when authenticated as registered user' do
@@ -29,12 +30,19 @@ RSpec.describe Spree::CheckoutController, type: :controller do
29
30
  get :edit, params: { state: 'address' }
30
31
  expect(response).to redirect_to spree.checkout_registration_path
31
32
  end
33
+
34
+ context 'non default locale' do
35
+ it 'redirects to registration step with non default locale' do
36
+ get :edit, params: { state: 'address', locale: 'fr' }
37
+ expect(response).to redirect_to spree.checkout_registration_path(locale: 'fr')
38
+ end
39
+ end
32
40
  end
33
41
  end
34
42
 
35
43
  context 'when registration step disabled' do
36
44
  before do
37
- Spree::Auth::Config.set(registration_step: false)
45
+ Spree::Auth::Config.set(:registration_step, false)
38
46
  allow(controller).to receive(:check_authorization)
39
47
  end
40
48
 
@@ -84,6 +92,15 @@ RSpec.describe Spree::CheckoutController, type: :controller do
84
92
  post :update, params: { state: 'confirm' }
85
93
  expect(response).to redirect_to spree.order_path(order)
86
94
  end
95
+
96
+ context 'non default locale' do
97
+ it 'redirects to the tokenized order view with a non default locale' do
98
+ # spree version higher than 3.6 required for test to work correctly
99
+ request.cookie_jar.signed[:token] = 'ABC'
100
+ post :update, params: { state: 'confirm', locale: 'fr' }
101
+ expect(response).to redirect_to spree.order_path(order, locale: 'fr')
102
+ end
103
+ end
87
104
  end
88
105
 
89
106
  context 'with a registered user' do
@@ -101,6 +118,13 @@ RSpec.describe Spree::CheckoutController, type: :controller do
101
118
  post :update, params: { state: 'confirm' }
102
119
  expect(response).to redirect_to spree.order_path(order)
103
120
  end
121
+
122
+ context 'non default locale' do
123
+ it 'redirects to the standard order view with a non default locale' do
124
+ post :update, params: { state: 'confirm', locale: 'fr' }
125
+ expect(response).to redirect_to spree.order_path(order, locale: 'fr')
126
+ end
127
+ end
104
128
  end
105
129
  end
106
130
  end
@@ -147,6 +171,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
147
171
  expect(response).to redirect_to spree.checkout_state_path(:address)
148
172
  end
149
173
 
174
+ context 'non default locale' do
175
+ it 'redirects to the checkout_path after saving with non default locale' do
176
+ allow(controller).to receive(:check_authorization)
177
+ put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' }, locale: 'fr' }
178
+ expect(response).to redirect_to spree.checkout_state_path(:address, locale: 'fr')
179
+ end
180
+ end
181
+
150
182
  it 'checks if the user is authorized for :edit' do
151
183
  if Spree.version.to_f > 3.6
152
184
  request.cookie_jar.signed[:token] = token
@@ -9,6 +9,25 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
9
9
  expect(response).to redirect_to spree.account_path
10
10
  end
11
11
 
12
+ context 'with non default locale' do
13
+ before do
14
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
15
+ end
16
+
17
+ after { I18n.locale = :en }
18
+
19
+ it 'redirects to account_path with locale' do
20
+ post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }, locale: 'fr'}
21
+ expect(response).to redirect_to spree.account_path(locale: 'fr')
22
+ end
23
+
24
+ it 'saves locale in user' do
25
+ post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }, locale: 'fr'}
26
+ user = Spree.user_class.find_by_email('foobar@example.com')
27
+ expect(user.selected_locale).to eq('fr')
28
+ end
29
+ end
30
+
12
31
  context 'with a guest token present' do
13
32
  before do
14
33
  if Spree.version.to_f > 3.6
@@ -55,4 +74,29 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
55
74
  end
56
75
  end
57
76
  end
77
+
78
+ context 'when user session times out' do
79
+ let(:user) { build_stubbed(:user) }
80
+
81
+ before do
82
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
83
+ allow(Devise::Mapping).to receive(:find_scope!).and_return(:spree_user)
84
+ end
85
+
86
+ after { I18n.locale = :en }
87
+
88
+ it 'redirects to sign in after timeout' do
89
+ expect(controller.send(:after_inactive_sign_up_path_for, :user)).to eq(spree.login_path)
90
+ end
91
+
92
+ context 'with locale changed to fr' do
93
+ before do
94
+ allow(controller).to receive(:locale_param).and_return('fr')
95
+ end
96
+
97
+ it 'redirect to sign in after timeout with changed locale' do
98
+ expect(controller.send(:after_inactive_sign_up_path_for, :user)).to eq(spree.login_path('fr'))
99
+ end
100
+ end
101
+ end
58
102
  end
@@ -200,4 +200,22 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
200
200
  end
201
201
  end
202
202
  end
203
+
204
+ context "#destroy" do
205
+ before do
206
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
207
+ end
208
+
209
+ it "redirects to login page after signing out with default locale" do
210
+ post :create, params: { spree_user: { email: user.email, password: 'secret' }}
211
+ delete :destroy
212
+ expect(response).to redirect_to(spree.login_path)
213
+ end
214
+
215
+ it "persists fr locale when redirecting to login page after signing out" do
216
+ post :create, params: { spree_user: { email: user.email, password: 'secret' }, locale: 'fr' }
217
+ delete :destroy, params: { locale: 'fr' }
218
+ expect(response).to redirect_to spree.login_path(locale: 'fr')
219
+ end
220
+ end
203
221
  end
@@ -3,7 +3,10 @@ RSpec.describe Spree::UsersController, type: :controller do
3
3
  let(:user) { create(:user) }
4
4
  let(:role) { create(:role) }
5
5
 
6
- before { allow(controller).to receive(:spree_current_user) { user } }
6
+ before do
7
+ allow(controller).to receive(:spree_current_user) { user }
8
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
9
+ end
7
10
 
8
11
  context '#load_object' do
9
12
  it 'redirects to signup path if user is not found' do
@@ -11,6 +14,14 @@ RSpec.describe Spree::UsersController, type: :controller do
11
14
  put :update, params: { user: { email: 'foobar@example.com' } }
12
15
  expect(response).to redirect_to spree.login_path
13
16
  end
17
+
18
+ context "non default locale" do
19
+ it 'redirects to signup path with non default locale if user is not found' do
20
+ allow(controller).to receive(:spree_current_user) { nil }
21
+ put :update, params: { user: { email: 'foobar@example.com' }, locale: 'fr' }
22
+ expect(response).to redirect_to spree.login_path(locale: 'fr')
23
+ end
24
+ end
14
25
  end
15
26
 
16
27
  context '#create' do
@@ -22,10 +33,33 @@ RSpec.describe Spree::UsersController, type: :controller do
22
33
 
23
34
  context '#update' do
24
35
  context 'when updating own account' do
25
- it 'performs update' do
26
- put :update, params: { user: { email: 'mynew@email-address.com' } }
27
- expect(assigns[:user].email).to eq 'mynew@email-address.com'
28
- expect(response).to redirect_to spree.account_path
36
+ context 'deafult locale' do
37
+ before { put :update, params: { user: { email: 'mynew@email-address.com' } } }
38
+
39
+ it 'performs update of email' do
40
+ expect(assigns[:user].email).to eq 'mynew@email-address.com'
41
+ end
42
+
43
+ it 'redirects to correct path' do
44
+ expect(response).to redirect_to spree.account_path
45
+ end
46
+ end
47
+
48
+ context 'non default locale' do
49
+ before { put :update, params: { user: { email: 'mynew@email-address.com' }, locale: 'fr' } }
50
+
51
+ it 'performs update of email' do
52
+ expect(assigns[:user].email).to eq 'mynew@email-address.com'
53
+ end
54
+
55
+ it 'persists locale when redirecting to account' do
56
+ expect(response).to redirect_to spree.account_path(locale: 'fr')
57
+ end
58
+ end
59
+
60
+ it 'performs update of selected_locale' do
61
+ put :update, params: { user: { selected_locale: 'pl' } }
62
+ expect(assigns[:user].selected_locale).to eq 'pl'
29
63
  end
30
64
  end
31
65
 
@@ -18,6 +18,25 @@ RSpec.feature 'Admin - Sign In', type: :feature do
18
18
  expect(current_path).to eq '/account'
19
19
  end
20
20
 
21
+ context 'with non default locale' do
22
+ before do
23
+ add_french_locales
24
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
25
+ I18n.locale = :fr
26
+ end
27
+
28
+ after { I18n.locale = :en }
29
+
30
+ scenario 'lets a user sign in successfully', js: true do
31
+ log_in(email: @user.email, password: 'secret', locale: 'fr')
32
+ show_user_menu
33
+
34
+ expect(page).not_to have_text login_button.upcase
35
+ expect(page).to have_text logout_button.upcase
36
+ expect(current_path).to eq '/fr/account'
37
+ end
38
+ end
39
+
21
40
  scenario 'shows validation errors' do
22
41
  fill_in 'Email', with: @user.email
23
42
  fill_in 'Password', with: 'wrong_password'
@@ -30,7 +30,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
30
30
  end
31
31
 
32
32
  scenario 'allow a visitor to checkout as guest, without registration' do
33
- Spree::Auth::Config.set(registration_step: true)
33
+ Spree::Auth::Config.set(:registration_step, true)
34
34
  add_to_cart(mug)
35
35
  click_link 'checkout'
36
36
 
@@ -74,7 +74,7 @@ RSpec.feature 'Sign In', type: :feature do
74
74
 
75
75
  expect(page).not_to have_text Spree.t(:login).upcase
76
76
  expect(page).to have_text Spree.t(:logout).upcase
77
- expect(current_url).to match(/\/account\?locale\=fr$/)
77
+ expect(current_url).to match(/\/fr\/account/)
78
78
  end
79
79
  end
80
80
  end
@@ -1,6 +1,6 @@
1
1
  module ConfigurationHelpers
2
2
  def allow_bypass_sign_in
3
- Spree::Auth::Config.set(signout_after_password_change: false)
3
+ Spree::Auth::Config.set(:signout_after_password_change, false)
4
4
  end
5
5
  end
6
6
 
@@ -1,12 +1,14 @@
1
1
  RSpec.configure do |config|
2
2
  config.around do |example|
3
3
  if example.metadata.key?(:confirmable)
4
+ old_setting = Spree::Auth::Config.confirmable
4
5
  old_user = Spree::User
5
6
 
6
7
  begin
7
8
  example.run
8
9
  ensure
9
10
  Spree.const_set('User', old_user)
11
+ Spree::Auth::Config.confirmable = old_setting
10
12
  end
11
13
  else
12
14
  example.run
@@ -16,7 +18,7 @@ RSpec.configure do |config|
16
18
  config.before do |example|
17
19
  if example.metadata.key?(:confirmable)
18
20
  Rails.cache.clear
19
- Spree::Auth::Config[:confirmable] = example.metadata[:confirmable]
21
+ Spree::Auth::Config.confirmable = example.metadata[:confirmable]
20
22
 
21
23
  Spree.send(:remove_const, :User)
22
24
  load File.expand_path('../../../app/models/spree/user.rb', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-12-01 00:00:00.000000000 Z
12
+ date: 2023-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -213,9 +213,9 @@ licenses:
213
213
  - BSD-3-Clause
214
214
  metadata:
215
215
  bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
216
- changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.5.0
216
+ changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.6.0
217
217
  documentation_uri: https://guides.spreecommerce.org/
218
- source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.5.0
218
+ source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.6.0
219
219
  post_install_message:
220
220
  rdoc_options: []
221
221
  require_paths:
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements:
234
234
  - none
235
- rubygems_version: 3.0.9
235
+ rubygems_version: 3.4.1
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: Provides authentication and authorization services for use with Spree by