spree_auth_devise 4.4.2 → 4.6.0
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 -73
- data/Gemfile +8 -1
- data/README.md +5 -11
- data/config/initializers/devise.rb +1 -1
- data/config/routes.rb +47 -45
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +1 -1
- data/lib/controllers/backend/spree/{admin → auth/admin}/base_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders/customer_details_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/{admin → auth/admin}/orders_controller_decorator.rb +2 -2
- data/lib/controllers/backend/spree/auth/admin/resource_controller_decorator.rb +6 -0
- data/lib/controllers/frontend/spree/{checkout_controller_decorator.rb → auth/checkout_controller_decorator.rb} +4 -4
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +2 -2
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +5 -3
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +2 -2
- data/lib/mailers/spree/user_mailer.rb +38 -0
- data/lib/spree/auth/configuration.rb +33 -0
- data/lib/spree/auth/engine.rb +14 -3
- data/lib/spree/auth/version.rb +1 -1
- data/lib/spree/authentication_helpers.rb +6 -6
- data/lib/spree/testing_support/auth_helpers.rb +8 -0
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +17 -15
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +13 -13
- data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +8 -9
- data/lib/views/backend/spree/layouts/login.html.erb +1 -1
- data/lib/views/frontend/spree/user_registrations/new.html.erb +1 -1
- data/spec/controllers/spree/api/v2/storefront/passwords_controller_spec.rb +2 -2
- data/spec/controllers/spree/checkout_controller_spec.rb +34 -2
- data/spec/controllers/spree/products_controller_spec.rb +1 -0
- 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/account_spec.rb +1 -0
- data/spec/features/admin/sign_in_spec.rb +20 -1
- data/spec/features/checkout_spec.rb +5 -4
- data/spec/features/confirmation_spec.rb +1 -1
- data/spec/features/sign_in_spec.rb +2 -2
- data/spec/mailers/user_mailer_spec.rb +3 -3
- data/spec/models/user_spec.rb +3 -3
- data/spec/support/configuration_helpers.rb +1 -1
- data/spec/support/confirm_helpers.rb +3 -1
- data/spree_auth_devise.gemspec +1 -1
- metadata +18 -18
- data/app/mailers/spree/user_mailer.rb +0 -23
- data/app/models/spree/auth_configuration.rb +0 -8
- data/lib/controllers/backend/spree/admin/resource_controller_decorator.rb +0 -6
- /data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.html.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/confirmation_instructions.text.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.html.erb +0 -0
- /data/{app/views → lib/views/emails}/spree/user_mailer/reset_password_instructions.text.erb +0 -0
@@ -1,16 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<%= form_for @spree_user, as: :spree_user, url: spree.admin_update_password_path, method: :put do |f| %>
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
<div id="forgot-password" class="card mt-5 shadow-sm">
|
2
|
+
<div class="card-body">
|
3
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
|
4
|
+
<h5 class="card-title"><%= Spree.t(:change_my_password) %></h5>
|
5
|
+
<%= form_for @spree_user, as: :spree_user, url: spree.admin_update_password_path, method: :put do |f| %>
|
6
|
+
<div class="form-group">
|
7
|
+
<%= f.label :password, Spree.t(:password) %>
|
8
|
+
<%= f.password_field :password, class: 'form-control', required: true %>
|
9
|
+
</div>
|
10
|
+
<div class="form-group">
|
11
|
+
<%= f.label :password_confirmation, Spree.t(:confirm_password) %>
|
12
|
+
<%= f.password_field :password_confirmation, class: 'form-control', required: true %>
|
13
|
+
</div>
|
14
|
+
<%= f.hidden_field :reset_password_token %>
|
15
|
+
<%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block' %>
|
16
|
+
<% end %>
|
9
17
|
</div>
|
10
|
-
|
11
|
-
<%= f.label :password_confirmation, Spree.t(:confirm_password) %>
|
12
|
-
<%= f.password_field :password_confirmation, class: 'form-control', required: true %>
|
13
|
-
</div>
|
14
|
-
<%= f.hidden_field :reset_password_token %>
|
15
|
-
<%= f.submit Spree.t(:update), class: 'btn btn-primary btn-block' %>
|
16
|
-
<% end %>
|
18
|
+
</div>
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
<div id="forgot-password" class="card mt-5 shadow-sm">
|
2
|
+
<div class="card-body">
|
3
|
+
<%= render partial: 'spree/admin/shared/error_messages', locals: { target: @spree_user } %>
|
2
4
|
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<%= f.
|
11
|
-
|
12
|
-
|
13
|
-
<%= f.submit Spree.t(:reset_password), class: 'btn btn-primary' %>
|
14
|
-
<% end %>
|
5
|
+
<h5 class="card-title"><%= Spree.t(:forgot_password) %></h5>
|
6
|
+
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
7
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_reset_password_path, data: { turbo: false } do |f| %>
|
8
|
+
<div class="form-group">
|
9
|
+
<%= f.label :email, Spree.t(:email) %>
|
10
|
+
<%= f.email_field :email, class: 'form-control', required: true %>
|
11
|
+
</div>
|
12
|
+
<%= f.submit Spree.t(:reset_password), class: 'btn btn-primary' %>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
15
|
</div>
|
@@ -1,17 +1,16 @@
|
|
1
|
-
|
2
|
-
<div class="alert alert-danger"><%= flash[:alert] %></div>
|
3
|
-
<% end %>
|
4
|
-
|
5
|
-
<div data-hook="login" class="card border-0">
|
1
|
+
<div data-hook="login" class="card mt-5 shadow-sm">
|
6
2
|
<div class="card-body">
|
3
|
+
<% if flash[:error] %>
|
4
|
+
<div class="alert alert-danger"><%= flash[:error] %></div>
|
5
|
+
<% end %>
|
6
|
+
<h5 class="card-title"><%= Spree.t(:login) %></h5>
|
7
|
+
|
7
8
|
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
8
9
|
<div id="password-credentials">
|
9
|
-
<div class="form-group
|
10
|
-
<%= f.label :email, Spree.t(:email) %>
|
10
|
+
<div class="form-group">
|
11
11
|
<%= f.email_field :email, class: 'form-control', tabindex: 1, placeholder: Spree.t(:email) %>
|
12
12
|
</div>
|
13
|
-
<div class="form-group
|
14
|
-
<%= f.label :password, Spree.t(:password) %>
|
13
|
+
<div class="form-group">
|
15
14
|
<%= f.password_field :password, :class => 'form-control', :tabindex => 2, placeholder: Spree.t(:password) %>
|
16
15
|
</div>
|
17
16
|
</div>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<div class="col-lg-6 offset-lg-3">
|
4
4
|
<h3 class="spree-header spree-mb-large spree-mt-large"><%= Spree.t(:new_customer) %></h3>
|
5
5
|
<div id="new-customer" data-hook="login">
|
6
|
-
<%= form_for resource, as: :spree_user, url: spree.registration_path do |f| %>
|
6
|
+
<%= form_for resource, as: :spree_user, url: spree.registration_path, data: { turbo: false } do |f| %>
|
7
7
|
<div data-hook="signup_inside_form">
|
8
8
|
<%= render partial: 'spree/shared/user_form', locals: { f: f, remember_me_field: true } %>
|
9
9
|
<div><%= f.submit Spree.t(:sign_up), class: 'btn btn-primary btn-block spree-btn mb-5' %></div>
|
@@ -32,7 +32,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
|
|
32
32
|
context 'when updating password with blank password' do
|
33
33
|
let(:params) {
|
34
34
|
{
|
35
|
-
id: user.send_reset_password_instructions(Spree::Store.
|
35
|
+
id: user.send_reset_password_instructions(Spree::Store.default),
|
36
36
|
user: {
|
37
37
|
password: '',
|
38
38
|
password_confirmation: ''
|
@@ -49,7 +49,7 @@ RSpec.describe Spree::Api::V2::Storefront::PasswordsController, type: :controlle
|
|
49
49
|
context 'when updating password with specified password' do
|
50
50
|
let(:params) {
|
51
51
|
{
|
52
|
-
id: user.send_reset_password_instructions(Spree::Store.
|
52
|
+
id: user.send_reset_password_instructions(Spree::Store.default),
|
53
53
|
user: {
|
54
54
|
password: password,
|
55
55
|
password_confirmation: password
|
@@ -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
|
@@ -17,6 +17,7 @@ RSpec.describe Spree::ProductsController, type: :controller do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'cannot view non-active products' do
|
20
|
+
skip if Spree.version.to_f > 4.0
|
20
21
|
allow(user).to receive(:has_spree_role?) { false }
|
21
22
|
|
22
23
|
# this behaviour was introduced in rails 5.1 & Spree 3.5
|
@@ -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
|
|
@@ -28,6 +28,7 @@ RSpec.feature 'Accounts', type: :feature do
|
|
28
28
|
expect(page).to have_text 'email@person.com'
|
29
29
|
|
30
30
|
find('a.account-page-user-info-item-title-edit').click
|
31
|
+
wait_for_turbo
|
31
32
|
|
32
33
|
fill_in 'Password', with: 'foobar'
|
33
34
|
fill_in 'Password Confirmation', with: 'foobar'
|
@@ -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'
|
@@ -44,6 +63,6 @@ RSpec.feature 'Admin - Sign In', type: :feature do
|
|
44
63
|
expect(page).to have_text 'admin@person.com'
|
45
64
|
end
|
46
65
|
end
|
47
|
-
expect(current_path).to
|
66
|
+
expect(current_path).to match('/admin')
|
48
67
|
end
|
49
68
|
end
|
@@ -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
|
|
@@ -73,7 +73,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
# Regression test for #890
|
76
|
-
|
76
|
+
xscenario 'associate an incomplete guest order with user after successful password reset' do
|
77
77
|
add_to_cart(mug)
|
78
78
|
|
79
79
|
visit spree.login_path
|
@@ -81,12 +81,12 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
81
81
|
fill_in('Email', with: 'email@person.com')
|
82
82
|
find('#spree_user_email').set('email@person.com')
|
83
83
|
|
84
|
-
click_button 'Reset my password'
|
84
|
+
expect { click_button 'Reset my password' }.to change { ActionMailer::Base.deliveries.size }.by(1)
|
85
85
|
|
86
86
|
# Need to do this now because the token stored in the DB is the encrypted version
|
87
87
|
# The 'plain-text' version is sent in the email and there's one way to get that!
|
88
88
|
reset_password_email = ActionMailer::Base.deliveries.first
|
89
|
-
token_url_regex = /^http:\/\/www.example.com\/
|
89
|
+
token_url_regex = /^http:\/\/www.example.com\/password\/change\?reset_password_token=(.*)$/
|
90
90
|
token = token_url_regex.match(reset_password_email.body.encoded)[1]
|
91
91
|
|
92
92
|
visit spree.edit_spree_user_password_path(reset_password_token: token.strip).tr("%0D","")
|
@@ -103,6 +103,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
103
103
|
click_button 'Save and Continue'
|
104
104
|
|
105
105
|
expect(page).not_to have_text 'Email is invalid'
|
106
|
+
ActiveJob::Base.queue_adapter = :test
|
106
107
|
end
|
107
108
|
|
108
109
|
scenario 'allow a user to register during checkout' do
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
RSpec.feature 'Confirmation', type: :feature, confirmable: true do
|
4
4
|
before do
|
5
|
-
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.
|
5
|
+
expect(Spree::UserMailer).to receive(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
|
6
6
|
end
|
7
7
|
|
8
8
|
background do
|
@@ -45,7 +45,7 @@ RSpec.feature 'Sign In', type: :feature do
|
|
45
45
|
expect(page).to have_text 'admin@person.com'
|
46
46
|
end
|
47
47
|
end
|
48
|
-
expect(current_path).to
|
48
|
+
expect(current_path).to match('/admin')
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should store the user previous location' do
|
@@ -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
|
@@ -5,7 +5,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
5
5
|
describe '#reset_password_instructions' do
|
6
6
|
describe 'message contents' do
|
7
7
|
before do
|
8
|
-
@message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.
|
8
|
+
@message = described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id })
|
9
9
|
end
|
10
10
|
|
11
11
|
context 'subject includes' do
|
@@ -22,7 +22,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
22
22
|
|
23
23
|
context 'body includes' do
|
24
24
|
it 'password reset url' do
|
25
|
-
expect(@message.body.encoded).to include "http://#{store.url}/
|
25
|
+
expect(@message.body.encoded).to include "http://#{store.url}/password/change"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -30,7 +30,7 @@ RSpec.describe Spree::UserMailer, type: :mailer do
|
|
30
30
|
describe 'legacy support for User object' do
|
31
31
|
it 'sends an email' do
|
32
32
|
expect {
|
33
|
-
described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.
|
33
|
+
described_class.reset_password_instructions(user, 'token goes here', { current_store_id: Spree::Store.default.id }).deliver_now
|
34
34
|
}.to change(ActionMailer::Base.deliveries, :size).by(1)
|
35
35
|
end
|
36
36
|
end
|
data/spec/models/user_spec.rb
CHANGED
@@ -9,7 +9,7 @@ RSpec.describe Spree::User, type: :model do
|
|
9
9
|
|
10
10
|
it 'generates the reset password token' do
|
11
11
|
user = build(:user)
|
12
|
-
current_store = Spree::Store.
|
12
|
+
current_store = Spree::Store.default
|
13
13
|
expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, { current_store_id: current_store.id }).and_return(double(deliver: true))
|
14
14
|
user.send_reset_password_instructions(current_store)
|
15
15
|
expect(user.reset_password_token).not_to be_nil
|
@@ -94,7 +94,7 @@ RSpec.describe Spree::User, type: :model do
|
|
94
94
|
|
95
95
|
describe "confirmable" do
|
96
96
|
it "is confirmable if the confirmable option is enabled", confirmable: true do
|
97
|
-
Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.
|
97
|
+
Spree::UserMailer.stub(:confirmation_instructions).with(anything, anything, { current_store_id: Spree::Store.default.id }).and_return(double(deliver: true))
|
98
98
|
expect(Spree.user_class.devise_modules).to include(:confirmable)
|
99
99
|
end
|
100
100
|
|
@@ -112,7 +112,7 @@ RSpec.describe Spree::User, type: :model do
|
|
112
112
|
user.email = FFaker::Internet.email
|
113
113
|
user.password = user.password_confirmation = 'pass1234'
|
114
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)
|
118
118
|
)
|
@@ -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__)
|
data/spree_auth_devise.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_dependency 'devise', '~> 4.7'
|
34
34
|
s.add_dependency 'devise-encryptable', '0.2.0'
|
35
35
|
|
36
|
-
spree_version = '>= 4.
|
36
|
+
spree_version = '>= 4.5.0'
|
37
37
|
s.add_dependency 'spree_core', spree_version
|
38
38
|
s.add_dependency 'spree_extension'
|
39
39
|
|