spree_auth_devise 4.5.0 → 4.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +14 -88
- data/Gemfile +2 -4
- data/README.md +23 -3
- data/config/routes.rb +47 -45
- data/db/default/users.rb +0 -2
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +4 -2
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +1 -1
- data/lib/controllers/frontend/spree/users_controller.rb +2 -2
- data/lib/spree/auth/configuration.rb +28 -5
- data/lib/spree/auth/version.rb +1 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +34 -2
- data/spec/controllers/spree/user_registrations_controller_spec.rb +44 -0
- data/spec/controllers/spree/user_sessions_controller_spec.rb +18 -0
- data/spec/controllers/spree/users_controller_spec.rb +39 -5
- data/spec/features/admin/sign_in_spec.rb +19 -0
- data/spec/features/checkout_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +1 -1
- data/spec/models/user_spec.rb +2 -2
- data/spec/support/configuration_helpers.rb +1 -1
- data/spec/support/confirm_helpers.rb +3 -1
- metadata +5 -6
- data/.travis.yml +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a01a57a067f83b53429e57919cb6264127b28a10dfa7005536c2531479b5f314
|
4
|
+
data.tar.gz: b969026ace1d170c5ad4c23f00b78ae178a352abfd244ae3e9afdee5a8940e81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09f792afd1cc2b5f2e3c39c075ad628c23e0bb4ef9b9a6ff049ec1f390bc02cb2037568517e854ed815020aa651d4842320d8fff4772d973f095cdca1afe638f'
|
7
|
+
data.tar.gz: b3d8113dd54a4eff67acc34c323b0a09805224a4da0414d703a28213807b341311e5d9da8d4784a33c15bbc1fe6e90b8161e8c877d43a1424f1300cfa87357e4
|
data/.circleci/config.yml
CHANGED
@@ -9,14 +9,7 @@ defaults: &defaults
|
|
9
9
|
BUNDLE_PATH: ~/spree/vendor/bundle
|
10
10
|
working_directory: ~/spree
|
11
11
|
docker:
|
12
|
-
- image: &ruby_image
|
13
|
-
- image: &redis_image circleci/redis:6.2-alpine
|
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
|
12
|
+
- image: &ruby_image cimg/ruby:3.3.0-browsers
|
20
13
|
|
21
14
|
run_tests: &run_tests
|
22
15
|
<<: *defaults
|
@@ -24,46 +17,14 @@ run_tests: &run_tests
|
|
24
17
|
- checkout
|
25
18
|
- restore_cache:
|
26
19
|
keys:
|
27
|
-
- spree-auth-devise-bundle-
|
28
|
-
- spree-auth-devise-bundle-
|
20
|
+
- spree-auth-devise-bundle-v10-ruby-3-3-{{ .Branch }}
|
21
|
+
- spree-auth-devise-bundle-v10-ruby-3-3
|
29
22
|
- run:
|
30
|
-
name:
|
31
|
-
command: sudo apt-
|
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
|
-
steps:
|
59
|
-
- checkout
|
60
|
-
- restore_cache:
|
61
|
-
keys:
|
62
|
-
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
63
|
-
- spree-auth-devise-bundle-v9-ruby-3-0
|
23
|
+
name: Add keyserver
|
24
|
+
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
|
64
25
|
- run:
|
65
26
|
name: Install libvips
|
66
|
-
command: sudo apt-get install libvips
|
27
|
+
command: sudo apt-get update && sudo apt-get install libvips
|
67
28
|
- run:
|
68
29
|
name: Set bundle path
|
69
30
|
command: bundle config --local path vendor/bundle
|
@@ -95,34 +56,14 @@ jobs:
|
|
95
56
|
- checkout
|
96
57
|
- restore_cache:
|
97
58
|
keys:
|
98
|
-
- spree-auth-devise-bundle-
|
99
|
-
- spree-auth-devise-bundle-
|
59
|
+
- spree-auth-devise-bundle-v10-ruby-3-3-{{ .Branch }}
|
60
|
+
- spree-auth-devise-bundle-v10-ruby-3-3
|
100
61
|
- run:
|
101
|
-
name:
|
102
|
-
command: sudo apt-
|
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
|
-
steps:
|
118
|
-
- checkout
|
119
|
-
- restore_cache:
|
120
|
-
keys:
|
121
|
-
- spree-auth-devise-bundle-v9-ruby-3-0-{{ .Branch }}
|
122
|
-
- spree-auth-devise-bundle-v9-ruby-3-0
|
62
|
+
name: Add keyserver
|
63
|
+
command: sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
|
123
64
|
- run:
|
124
65
|
name: Install libvips
|
125
|
-
command: sudo apt-get install libvips
|
66
|
+
command: sudo apt-get update && sudo apt-get install libvips
|
126
67
|
- run:
|
127
68
|
name: Set bundle path
|
128
69
|
command: bundle config --local path vendor/bundle
|
@@ -133,7 +74,7 @@ jobs:
|
|
133
74
|
- save_cache:
|
134
75
|
paths:
|
135
76
|
- vendor/bundle
|
136
|
-
key: spree-auth-devise-bundle-
|
77
|
+
key: spree-auth-devise-bundle-v10-ruby-3-3-{{ checksum "Gemfile.lock" }}
|
137
78
|
|
138
79
|
tests_postgres: &tests_postgres
|
139
80
|
<<: *run_tests
|
@@ -144,20 +85,10 @@ jobs:
|
|
144
85
|
DB_USERNAME: postgres
|
145
86
|
docker:
|
146
87
|
- image: *ruby_image
|
147
|
-
- image:
|
148
|
-
- image: &postgres_image circleci/postgres:12-alpine
|
88
|
+
- image: &postgres_image cimg/postgres:16.2
|
149
89
|
environment:
|
150
90
|
POSTGRES_USER: postgres
|
151
91
|
|
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
92
|
tests_mysql: &tests_mysql
|
162
93
|
<<: *run_tests
|
163
94
|
environment: &mysql_environment
|
@@ -169,21 +100,16 @@ jobs:
|
|
169
100
|
COVERAGE_DIR: /tmp/workspace/simplecov
|
170
101
|
docker:
|
171
102
|
- image: *ruby_image
|
172
|
-
- image:
|
173
|
-
- image: &mysql_image circleci/mysql:8-ram
|
103
|
+
- image: &mysql_image cimg/mysql:8.0
|
174
104
|
|
175
105
|
workflows:
|
176
106
|
version: 2
|
177
107
|
main:
|
178
108
|
jobs:
|
179
109
|
- bundle
|
180
|
-
- bundle_ruby_3_0
|
181
110
|
- tests_postgres:
|
182
111
|
requires:
|
183
112
|
- bundle
|
184
|
-
- tests_postgres_ruby_3_0:
|
185
|
-
requires:
|
186
|
-
- bundle_ruby_3_0
|
187
113
|
- tests_mysql:
|
188
114
|
requires:
|
189
115
|
- bundle
|
data/Gemfile
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rails-controller-testing'
|
4
|
-
gem 'devise', github: 'heartcombo/devise', branch: 'main'
|
5
4
|
gem 'spree', github: 'spree/spree', branch: 'main'
|
6
5
|
gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
|
7
6
|
gem 'spree_emails', github: 'spree/spree', branch: 'main'
|
8
7
|
gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
|
9
|
-
gem 'rspec_junit_formatter', '~> 0.4.1'
|
10
8
|
|
11
9
|
if ENV['DB'] == 'mysql'
|
12
10
|
gem 'mysql2'
|
13
11
|
else
|
14
|
-
gem 'pg'
|
12
|
+
gem 'pg'
|
15
13
|
end
|
16
14
|
|
17
|
-
gem 'pry'
|
15
|
+
gem 'pry'
|
18
16
|
gemspec
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Spree Auth
|
1
|
+
# Spree Auth Devise
|
2
2
|
|
3
3
|
[![CircleCI](https://circleci.com/gh/spree/spree_auth_devise/tree/main.svg?style=svg)](https://circleci.com/gh/spree/spree_auth_devise/tree/main)
|
4
4
|
|
@@ -6,9 +6,9 @@ Provides authentication services for [Spree](https://spreecommerce.org), using t
|
|
6
6
|
|
7
7
|
## Developed by
|
8
8
|
|
9
|
-
|
9
|
+
<a href="https://getvendo.com?utm_source=spree_auth_github"><img src="https://cdn.getvendo.com/assets/vendo-logo-4bda02af8c99bc2ecc5a400120f0ebe4eafcd385e02e25f198a8c355ab75d1ff.png" height=50 alt="Vendo - Start your own multi-brand marketplace" /></a>
|
10
10
|
|
11
|
-
|
11
|
+
<a href="http://sparksolutions.co?utm_source=github"><img src="https://sparksolutions.co/wp-content/themes/sparksolutions/images/logo.svg" height=50 alt="Spark Solutions - Ruby on Rails and Spree Commerce developers"></a>
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -135,3 +135,23 @@ You need to do a quick one-time creation of a test application and then you can
|
|
135
135
|
Then run the rspec tests.
|
136
136
|
|
137
137
|
bundle exec rspec
|
138
|
+
|
139
|
+
|
140
|
+
## License
|
141
|
+
|
142
|
+
Spree Starter (formerly Spark Starter Kit) is copyright © 2015-2021
|
143
|
+
[Spark Solutions Sp. z o.o.][spark]. It is free software,
|
144
|
+
and may be redistributed under the terms specified in the
|
145
|
+
[LICENSE](LICENSE.md) file.
|
146
|
+
|
147
|
+
## About Spark Solutions
|
148
|
+
|
149
|
+
[![Spark Solutions](http://sparksolutions.co/wp-content/uploads/2015/01/logo-ss-tr-221x100.png)][spark]
|
150
|
+
|
151
|
+
Spree Auth Devise is maintained and funded by [Spark Solutions Sp. z o.o.](http://sparksolutions.co?utm_source=github)
|
152
|
+
The names and logos are trademarks of Spark Solutions Sp. z o.o.
|
153
|
+
|
154
|
+
We are passionate about open source software.
|
155
|
+
We are [available for hire][spark].
|
156
|
+
|
157
|
+
[spark]:http://sparksolutions.co?utm_source=github
|
data/config/routes.rb
CHANGED
@@ -1,52 +1,54 @@
|
|
1
1
|
Spree::Core::Engine.add_routes do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
data/db/default/users.rb
CHANGED
@@ -50,8 +50,6 @@ def create_admin_user
|
|
50
50
|
login: email
|
51
51
|
}
|
52
52
|
|
53
|
-
load 'spree/user.rb'
|
54
|
-
|
55
53
|
if Spree::User.find_by_email(email)
|
56
54
|
say "\nWARNING: There is already a user with the email: #{email}, so no account changes were made. If you wish to create an additional admin user, please run rake spree_auth:admin:create again with a different email.\n\n"
|
57
55
|
else
|
@@ -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 :
|
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
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|
data/lib/spree/auth/version.rb
CHANGED
@@ -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
|
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
|
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
|
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
|
-
|
26
|
-
put :update, params: { user: { email: 'mynew@email-address.com' } }
|
27
|
-
|
28
|
-
|
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
|
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
|
77
|
+
expect(current_url).to match(/\/fr\/account/)
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -111,7 +111,7 @@ RSpec.describe Spree::User, type: :model do
|
|
111
111
|
user = Spree.user_class.new
|
112
112
|
user.email = FFaker::Internet.email
|
113
113
|
user.password = user.password_confirmation = 'pass1234'
|
114
|
-
user.save
|
114
|
+
user.save!
|
115
115
|
|
116
116
|
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
|
117
117
|
user, anything, { current_store_id: default_store.id }).and_return(double(deliver: true)
|
@@ -126,7 +126,7 @@ RSpec.describe Spree::User, type: :model do
|
|
126
126
|
user = Spree.user_class.new
|
127
127
|
user.email = FFaker::Internet.email
|
128
128
|
user.password = user.password_confirmation = 'pass1234'
|
129
|
-
user.save
|
129
|
+
user.save!
|
130
130
|
|
131
131
|
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(
|
132
132
|
user, anything, { current_store_id: store.id }).and_return(double(deliver: true)
|
@@ -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
|
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.
|
4
|
+
version: 4.6.1
|
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:
|
12
|
+
date: 2024-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -93,7 +93,6 @@ files:
|
|
93
93
|
- ".github/dependabot.yml"
|
94
94
|
- ".gitignore"
|
95
95
|
- ".rspec"
|
96
|
-
- ".travis.yml"
|
97
96
|
- CHANGELOG.md
|
98
97
|
- Gemfile
|
99
98
|
- LICENSE.md
|
@@ -213,9 +212,9 @@ licenses:
|
|
213
212
|
- BSD-3-Clause
|
214
213
|
metadata:
|
215
214
|
bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
|
216
|
-
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.
|
215
|
+
changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.6.1
|
217
216
|
documentation_uri: https://guides.spreecommerce.org/
|
218
|
-
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.
|
217
|
+
source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.6.1
|
219
218
|
post_install_message:
|
220
219
|
rdoc_options: []
|
221
220
|
require_paths:
|
@@ -232,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
232
231
|
version: '0'
|
233
232
|
requirements:
|
234
233
|
- none
|
235
|
-
rubygems_version: 3.
|
234
|
+
rubygems_version: 3.5.3
|
236
235
|
signing_key:
|
237
236
|
specification_version: 4
|
238
237
|
summary: Provides authentication and authorization services for use with Spree by
|
data/.travis.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
os: linux
|
2
|
-
dist: bionic
|
3
|
-
|
4
|
-
addons:
|
5
|
-
apt:
|
6
|
-
sources:
|
7
|
-
- google-chrome
|
8
|
-
packages:
|
9
|
-
- google-chrome-stable
|
10
|
-
|
11
|
-
services:
|
12
|
-
- mysql
|
13
|
-
- postgresql
|
14
|
-
- redis-server
|
15
|
-
|
16
|
-
language: ruby
|
17
|
-
|
18
|
-
rvm:
|
19
|
-
- 2.7
|
20
|
-
- 3.0
|
21
|
-
|
22
|
-
env:
|
23
|
-
- DB=mysql
|
24
|
-
- DB=postgres
|
25
|
-
|
26
|
-
before_install:
|
27
|
-
- mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
|
28
|
-
|
29
|
-
before_script:
|
30
|
-
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
|
31
|
-
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
|
32
|
-
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
|
33
|
-
- unzip chromedriver_linux64.zip -d ~/bin
|
34
|
-
|
35
|
-
script:
|
36
|
-
- bundle exec rake test_app
|
37
|
-
- bundle exec rake spec
|