spree_auth_devise 4.0.0.rc2 → 4.1.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 +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +3 -21
- data/Appraisals +3 -19
- data/Gemfile +2 -2
- data/README.md +3 -12
- data/app/controllers/spree/user_confirmations_controller.rb +24 -0
- data/app/controllers/spree/user_passwords_controller.rb +2 -0
- data/app/controllers/spree/user_registrations_controller.rb +27 -1
- data/app/controllers/spree/user_sessions_controller.rb +23 -1
- data/app/views/spree/user_passwords/edit.html.erb +20 -17
- data/app/views/spree/user_passwords/new.html.erb +17 -15
- data/app/views/spree/user_registrations/new.html.erb +12 -17
- data/app/views/spree/user_sessions/new.html.erb +11 -12
- data/config/locales/en.yml +3 -1
- data/config/routes.rb +2 -3
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +1 -1
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +2 -2
- data/lib/controllers/frontend/spree/users_controller.rb +11 -6
- data/lib/generators/spree/auth/install/install_generator.rb +0 -4
- data/lib/spree/testing_support/auth_helpers.rb +36 -0
- data/lib/spree/testing_support/checkout_helpers.rb +24 -0
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +1 -1
- data/lib/views/backend/spree/admin/user_sessions/new.html.erb +1 -1
- data/spec/controllers/spree/admin/orders_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
- data/spec/controllers/spree/checkout_controller_spec.rb +15 -16
- data/spec/controllers/spree/products_controller_spec.rb +1 -1
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
- data/spec/controllers/spree/user_registrations_controller_spec.rb +8 -8
- data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
- data/spec/controllers/spree/users_controller_spec.rb +4 -4
- data/spec/features/account_spec.rb +10 -8
- data/spec/features/admin/password_reset_spec.rb +2 -4
- data/spec/features/admin/sign_in_spec.rb +5 -7
- data/spec/features/admin/sign_out_spec.rb +1 -1
- data/spec/features/admin_permissions_spec.rb +1 -1
- data/spec/features/change_email_spec.rb +1 -7
- data/spec/features/checkout_spec.rb +38 -63
- data/spec/features/confirmation_spec.rb +3 -5
- data/spec/features/order_spec.rb +9 -15
- data/spec/features/password_reset_spec.rb +2 -4
- data/spec/features/sign_in_spec.rb +7 -9
- data/spec/features/sign_out_spec.rb +16 -23
- data/spec/features/sign_up_spec.rb +6 -4
- data/spec/mailers/user_mailer_spec.rb +1 -1
- data/spec/models/user_spec.rb +5 -5
- data/spec/requests/spree/frontend/user_update_spec.rb +42 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/add_to_cart.rb +11 -4
- data/spec/support/authentication_helpers.rb +1 -1
- data/spec/support/capybara.rb +15 -8
- data/spree_auth_devise.gemspec +14 -10
- metadata +104 -74
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/views/spree/shared/_login.html.erb +0 -18
- data/app/views/spree/shared/_user_form.html.erb +0 -17
- data/gemfiles/spree_3_2.gemfile +0 -8
- data/gemfiles/spree_3_7.gemfile +0 -9
- data/gemfiles/spree_4_0.gemfile +0 -8
- data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
- data/lib/assets/javascripts/spree/frontend/account.js +0 -8
- data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
- data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
- data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
- data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
- data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
- data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
- data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
- data/lib/views/frontend/spree/users/edit.html.erb +0 -17
- data/lib/views/frontend/spree/users/show.html.erb +0 -48
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
<p><%= Spree.t(:instructions_to_reset_password) %></p>
|
7
7
|
|
8
|
-
<%= form_for Spree
|
8
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.reset_password_path do |f| %>
|
9
9
|
<p>
|
10
10
|
<%= f.label :email, Spree.t(:email) %><br />
|
11
11
|
<%= f.email_field :email %>
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
<div data-hook="login" class="card border-0">
|
6
6
|
<div class="card-body">
|
7
|
-
<%= form_for Spree
|
7
|
+
<%= form_for Spree.user_class.new, :as => :spree_user, :url => spree.admin_create_new_session_path do |f| %>
|
8
8
|
<div id="password-credentials">
|
9
9
|
<div class="form-group text-center">
|
10
10
|
<%= f.label :email, Spree.t(:email) %>
|
@@ -2,7 +2,7 @@ RSpec.describe Spree::Admin::UserSessionsController, type: :controller do
|
|
2
2
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
3
3
|
|
4
4
|
describe '#authorization_failure' do
|
5
|
-
subject {
|
5
|
+
subject { get :authorization_failure }
|
6
6
|
|
7
7
|
context 'user signed in' do
|
8
8
|
before { allow(controller).to receive(:spree_current_user) { build_stubbed(:user) } }
|
@@ -19,14 +19,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
19
19
|
before { allow(controller).to receive(:spree_current_user) { user } }
|
20
20
|
|
21
21
|
it 'proceeds to the first checkout step' do
|
22
|
-
|
22
|
+
get :edit, params: { state: 'address' }
|
23
23
|
expect(response).to render_template :edit
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
context 'when authenticated as guest' do
|
28
28
|
it 'redirects to registration step' do
|
29
|
-
|
29
|
+
get :edit, params: { state: 'address' }
|
30
30
|
expect(response).to redirect_to spree.checkout_registration_path
|
31
31
|
end
|
32
32
|
end
|
@@ -42,14 +42,14 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
42
42
|
before { allow(controller).to receive(:spree_current_user) { user } }
|
43
43
|
|
44
44
|
it 'proceeds to the first checkout step' do
|
45
|
-
|
45
|
+
get :edit, params: { state: 'address' }
|
46
46
|
expect(response).to render_template :edit
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'when authenticated as guest' do
|
51
51
|
it 'proceeds to the first checkout step' do
|
52
|
-
|
52
|
+
get :edit, params: { state: 'address' }
|
53
53
|
expect(response).to render_template :edit
|
54
54
|
end
|
55
55
|
end
|
@@ -81,9 +81,8 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
81
81
|
else
|
82
82
|
request.cookie_jar.signed[:guest_token] = 'ABC'
|
83
83
|
end
|
84
|
-
|
84
|
+
post :update, params: { state: 'confirm' }
|
85
85
|
expect(response).to redirect_to spree.order_path(order)
|
86
|
-
expect(flash.notice).to eq Spree.t(:order_processed_successfully)
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
@@ -99,7 +98,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
99
98
|
end
|
100
99
|
|
101
100
|
it 'redirects to the standard order view' do
|
102
|
-
|
101
|
+
post :update, params: { state: 'confirm' }
|
103
102
|
expect(response).to redirect_to spree.order_path(order)
|
104
103
|
end
|
105
104
|
end
|
@@ -110,7 +109,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
110
109
|
it 'does not check registration' do
|
111
110
|
allow(controller).to receive(:check_authorization)
|
112
111
|
expect(controller).not_to receive(:check_registration)
|
113
|
-
|
112
|
+
get :registration
|
114
113
|
end
|
115
114
|
|
116
115
|
it 'checks if the user is authorized for :edit' do
|
@@ -120,7 +119,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
120
119
|
else
|
121
120
|
request.cookie_jar.signed[:guest_token] = token
|
122
121
|
end
|
123
|
-
|
122
|
+
get :registration, params: {}
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
@@ -129,22 +128,22 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
129
128
|
|
130
129
|
it 'does not check registration' do
|
131
130
|
controller.stub :check_authorization
|
132
|
-
order.stub
|
131
|
+
order.stub update: true
|
133
132
|
controller.should_not_receive :check_registration
|
134
|
-
|
133
|
+
put :update_registration, params: { order: {} }
|
135
134
|
end
|
136
135
|
|
137
136
|
it 'renders the registration view if unable to save' do
|
138
137
|
allow(controller).to receive(:check_authorization)
|
139
|
-
|
138
|
+
put :update_registration, params: { order: { email: 'invalid' } }
|
140
139
|
expect(flash[:error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
|
141
140
|
expect(response).to render_template :registration
|
142
141
|
end
|
143
142
|
|
144
143
|
it 'redirects to the checkout_path after saving' do
|
145
|
-
allow(order).to receive(:
|
144
|
+
allow(order).to receive(:update) { true }
|
146
145
|
allow(controller).to receive(:check_authorization)
|
147
|
-
|
146
|
+
put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' } }
|
148
147
|
expect(response).to redirect_to spree.checkout_state_path(:address)
|
149
148
|
end
|
150
149
|
|
@@ -154,9 +153,9 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
154
153
|
else
|
155
154
|
request.cookie_jar.signed[:guest_token] = token
|
156
155
|
end
|
157
|
-
allow(order).to receive(:
|
156
|
+
allow(order).to receive(:update) { true }
|
158
157
|
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
159
|
-
|
158
|
+
put :update_registration, params: { order: { email: 'jobs@spreecommerce.com' } }
|
160
159
|
end
|
161
160
|
end
|
162
161
|
end
|
@@ -2,7 +2,7 @@ RSpec.describe Spree::ProductsController, type: :controller do
|
|
2
2
|
let!(:product) { create(:product, available_on: 1.year.from_now) }
|
3
3
|
let!(:user) { build_stubbed(:user, spree_api_key: 'fake') }
|
4
4
|
|
5
|
-
subject(:request) {
|
5
|
+
subject(:request) { get :show, params: { id: product.to_param }}
|
6
6
|
|
7
7
|
before do
|
8
8
|
allow(controller).to receive(:before_save_new_order)
|
@@ -6,14 +6,14 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
6
6
|
describe 'GET edit' do
|
7
7
|
context 'when the user token has not been specified' do
|
8
8
|
it 'redirects to the new session path' do
|
9
|
-
|
9
|
+
get :edit
|
10
10
|
expect(response).to redirect_to(
|
11
11
|
'http://test.host/user/spree_user/sign_in'
|
12
12
|
)
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'flashes an error' do
|
16
|
-
|
16
|
+
get :edit
|
17
17
|
expect(flash[:alert]).to include(
|
18
18
|
"You can't access this page without coming from a password reset " \
|
19
19
|
'email'
|
@@ -23,7 +23,7 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
23
23
|
|
24
24
|
context 'when the user token has been specified' do
|
25
25
|
it 'does something' do
|
26
|
-
|
26
|
+
get :edit, params: { reset_password_token: token }
|
27
27
|
expect(response.code).to eq('200')
|
28
28
|
end
|
29
29
|
end
|
@@ -32,7 +32,7 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
32
32
|
context '#update' do
|
33
33
|
context 'when updating password with blank password' do
|
34
34
|
it 'shows error flash message, sets spree_user with token and re-displays password edit form' do
|
35
|
-
|
35
|
+
put :update, params: { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
|
36
36
|
expect(assigns(:spree_user).is_a?(Spree::User)).to eq true
|
37
37
|
expect(assigns(:spree_user).reset_password_token).to eq token
|
38
38
|
expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user])
|
@@ -2,11 +2,11 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
2
2
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
3
3
|
|
4
4
|
context '#create' do
|
5
|
-
before { allow(controller).to receive(:after_sign_up_path_for).and_return(spree.
|
5
|
+
before { allow(controller).to receive(:after_sign_up_path_for).and_return(spree.account_path) }
|
6
6
|
|
7
|
-
it 'redirects to
|
8
|
-
|
9
|
-
expect(response).to redirect_to spree.
|
7
|
+
it 'redirects to account_path' do
|
8
|
+
post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
|
9
|
+
expect(response).to redirect_to spree.account_path
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'with a guest token present' do
|
@@ -24,8 +24,8 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
24
24
|
else
|
25
25
|
order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
26
26
|
end
|
27
|
-
|
28
|
-
user = Spree
|
27
|
+
post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }}
|
28
|
+
user = Spree.user_class.find_by_email('foobar@example.com')
|
29
29
|
|
30
30
|
order.reload
|
31
31
|
expect(order.user_id).to eq user.id
|
@@ -38,7 +38,7 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
38
38
|
else
|
39
39
|
order = create(:order, guest_token: 'ABC', user_id: 200)
|
40
40
|
end
|
41
|
-
|
41
|
+
post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }}
|
42
42
|
|
43
43
|
expect(order.reload.user_id).to eq 200
|
44
44
|
end
|
@@ -49,7 +49,7 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
49
49
|
else
|
50
50
|
order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
|
51
51
|
end
|
52
|
-
|
52
|
+
post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }}
|
53
53
|
|
54
54
|
expect(order.reload.user_id).to be_nil
|
55
55
|
end
|
@@ -14,7 +14,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
14
14
|
|
15
15
|
it 'assigns orders with the correct token and no user present' do
|
16
16
|
order = create(:order, email: user.email, token: 'ABC', user_id: nil, created_by_id: nil)
|
17
|
-
|
17
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
18
18
|
|
19
19
|
order.reload
|
20
20
|
expect(order.user_id).to eq user.id
|
@@ -23,7 +23,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
23
23
|
|
24
24
|
it 'assigns orders with the correct token and no user or email present' do
|
25
25
|
order = create(:order, token: 'ABC', user_id: nil, created_by_id: nil)
|
26
|
-
|
26
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
27
27
|
|
28
28
|
order.reload
|
29
29
|
expect(order.user_id).to eq user.id
|
@@ -34,7 +34,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
34
34
|
order = create(:order, email: user.email, token: 'ABC',
|
35
35
|
user_id: nil, created_by_id: nil,
|
36
36
|
completed_at: 1.minute.ago)
|
37
|
-
|
37
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
38
38
|
|
39
39
|
order.reload
|
40
40
|
expect(order.user_id).to be_nil
|
@@ -43,14 +43,14 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
43
43
|
|
44
44
|
it 'does not assign orders with an existing user' do
|
45
45
|
order = create(:order, token: 'ABC', user_id: 200)
|
46
|
-
|
46
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
47
47
|
|
48
48
|
expect(order.reload.user_id).to eq 200
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'does not assign orders with a different token' do
|
52
52
|
order = create(:order, token: 'DEF', user_id: nil, created_by_id: nil)
|
53
|
-
|
53
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
54
54
|
|
55
55
|
expect(order.reload.user_id).to be_nil
|
56
56
|
end
|
@@ -72,7 +72,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
72
72
|
else
|
73
73
|
order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
74
74
|
end
|
75
|
-
|
75
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
76
76
|
|
77
77
|
order.reload
|
78
78
|
expect(order.user_id).to eq user.id
|
@@ -85,7 +85,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
85
85
|
else
|
86
86
|
order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
87
87
|
end
|
88
|
-
|
88
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
89
89
|
|
90
90
|
order.reload
|
91
91
|
expect(order.user_id).to eq user.id
|
@@ -102,7 +102,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
102
102
|
user_id: nil, created_by_id: nil,
|
103
103
|
completed_at: 1.minute.ago)
|
104
104
|
end
|
105
|
-
|
105
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
106
106
|
|
107
107
|
order.reload
|
108
108
|
expect(order.user_id).to be_nil
|
@@ -115,7 +115,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
115
115
|
else
|
116
116
|
order = create(:order, guest_token: 'ABC', user_id: 200)
|
117
117
|
end
|
118
|
-
|
118
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
119
119
|
|
120
120
|
expect(order.reload.user_id).to eq 200
|
121
121
|
end
|
@@ -126,7 +126,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
126
126
|
else
|
127
127
|
order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
|
128
128
|
end
|
129
|
-
|
129
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
130
130
|
|
131
131
|
expect(order.reload.user_id).to be_nil
|
132
132
|
end
|
@@ -144,7 +144,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
144
144
|
else
|
145
145
|
order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
146
146
|
end
|
147
|
-
|
147
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
148
148
|
|
149
149
|
order.reload
|
150
150
|
expect(order.user_id).to eq user.id
|
@@ -153,15 +153,15 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
153
153
|
end
|
154
154
|
|
155
155
|
context "and html format is used" do
|
156
|
-
it "redirects to
|
157
|
-
|
158
|
-
expect(response).to redirect_to spree.
|
156
|
+
it "redirects to account path after signing in" do
|
157
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }}
|
158
|
+
expect(response).to redirect_to spree.account_path
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
162
|
context "and js format is used" do
|
163
163
|
it "returns a json with ship and bill address" do
|
164
|
-
|
164
|
+
post :create, params: { spree_user: { email: user.email, password: 'secret' }, format: 'js' }
|
165
165
|
parsed = ActiveSupport::JSON.decode(response.body)
|
166
166
|
expect(parsed).to have_key("user")
|
167
167
|
expect(parsed).to have_key("ship_address")
|
@@ -173,7 +173,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
173
173
|
context "using incorrect login information" do
|
174
174
|
context "and html format is used" do
|
175
175
|
it "renders new template again with errors" do
|
176
|
-
|
176
|
+
post :create, params: { spree_user: { email: user.email, password: 'wrong' }}
|
177
177
|
expect(response).to render_template('new')
|
178
178
|
expect(flash[:error]).to eq I18n.t(:'devise.failure.invalid')
|
179
179
|
end
|
@@ -181,7 +181,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
181
181
|
|
182
182
|
context "and js format is used" do
|
183
183
|
it "returns a json with the error" do
|
184
|
-
|
184
|
+
post :create, params: { spree_user: { email: user.email, password: 'wrong' }, format: 'js' }
|
185
185
|
parsed = ActiveSupport::JSON.decode(response.body)
|
186
186
|
expect(parsed).to have_key("error")
|
187
187
|
end
|
@@ -8,14 +8,14 @@ RSpec.describe Spree::UsersController, type: :controller do
|
|
8
8
|
context '#load_object' do
|
9
9
|
it 'redirects to signup path if user is not found' do
|
10
10
|
allow(controller).to receive(:spree_current_user) { nil }
|
11
|
-
|
11
|
+
put :update, params: { user: { email: 'foobar@example.com' } }
|
12
12
|
expect(response).to redirect_to spree.login_path
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
16
|
context '#create' do
|
17
17
|
it 'creates a new user' do
|
18
|
-
|
18
|
+
post :create, params: { user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
|
19
19
|
expect(assigns[:user].new_record?).to be false
|
20
20
|
end
|
21
21
|
end
|
@@ -23,14 +23,14 @@ RSpec.describe Spree::UsersController, type: :controller do
|
|
23
23
|
context '#update' do
|
24
24
|
context 'when updating own account' do
|
25
25
|
it 'performs update' do
|
26
|
-
|
26
|
+
put :update, params: { user: { email: 'mynew@email-address.com' } }
|
27
27
|
expect(assigns[:user].email).to eq 'mynew@email-address.com'
|
28
28
|
expect(response).to redirect_to spree.account_url(only_path: true)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'does not update roles' do
|
33
|
-
|
33
|
+
put :update, params: { user: { spree_role_ids: [role.id] }}
|
34
34
|
expect(assigns[:user].spree_roles).to_not include role
|
35
35
|
end
|
36
36
|
end
|
@@ -10,9 +10,9 @@ RSpec.feature 'Accounts', type: :feature do
|
|
10
10
|
|
11
11
|
fill_in 'Email', with: user.email
|
12
12
|
fill_in 'Password', with: user.password
|
13
|
-
click_button '
|
13
|
+
click_button 'Log in'
|
14
14
|
|
15
|
-
|
15
|
+
show_user_account
|
16
16
|
expect(page).to have_text 'admin@person.com'
|
17
17
|
end
|
18
18
|
|
@@ -22,11 +22,12 @@ RSpec.feature 'Accounts', type: :feature do
|
|
22
22
|
fill_in 'Email', with: 'email@person.com'
|
23
23
|
fill_in 'Password', with: 'password'
|
24
24
|
fill_in 'Password Confirmation', with: 'password'
|
25
|
-
click_button '
|
25
|
+
click_button 'Sign Up'
|
26
26
|
|
27
|
-
|
27
|
+
show_user_account
|
28
28
|
expect(page).to have_text 'email@person.com'
|
29
|
-
|
29
|
+
|
30
|
+
find('a.account-page-user-info-item-title-edit').click
|
30
31
|
|
31
32
|
fill_in 'Password', with: 'foobar'
|
32
33
|
fill_in 'Password Confirmation', with: 'foobar'
|
@@ -42,11 +43,12 @@ RSpec.feature 'Accounts', type: :feature do
|
|
42
43
|
|
43
44
|
fill_in 'Email', with: user.email
|
44
45
|
fill_in 'Password', with: user.password
|
45
|
-
click_button '
|
46
|
+
click_button 'Log in'
|
46
47
|
|
47
|
-
|
48
|
+
show_user_account
|
48
49
|
expect(page).to have_text 'email@person.com'
|
49
|
-
|
50
|
+
|
51
|
+
find('a.account-page-user-info-item-title-edit').click
|
50
52
|
|
51
53
|
fill_in 'Password', with: 'foobar'
|
52
54
|
fill_in 'Password Confirmation', with: 'foobar'
|
@@ -1,6 +1,4 @@
|
|
1
1
|
RSpec.feature 'Admin - Reset Password', type: :feature do
|
2
|
-
let!(:store) { create(:store) }
|
3
|
-
|
4
2
|
background do
|
5
3
|
ActionMailer::Base.default_url_options[:host] = 'http://example.com'
|
6
4
|
end
|
@@ -8,7 +6,7 @@ RSpec.feature 'Admin - Reset Password', type: :feature do
|
|
8
6
|
scenario 'allows a user to supply an email for the password reset' do
|
9
7
|
user = create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret')
|
10
8
|
visit spree.admin_login_path
|
11
|
-
click_link 'Forgot
|
9
|
+
click_link 'Forgot password?'
|
12
10
|
fill_in 'Email', with: 'foobar@example.com'
|
13
11
|
click_button 'Reset my password'
|
14
12
|
expect(page).to have_text 'You will receive an email with instructions'
|
@@ -16,7 +14,7 @@ RSpec.feature 'Admin - Reset Password', type: :feature do
|
|
16
14
|
|
17
15
|
scenario 'shows errors if no email is supplied' do
|
18
16
|
visit spree.admin_login_path
|
19
|
-
click_link 'Forgot
|
17
|
+
click_link 'Forgot password?'
|
20
18
|
click_button 'Reset my password'
|
21
19
|
expect(page).to have_text "Email can't be blank"
|
22
20
|
end
|
@@ -10,14 +10,12 @@ RSpec.feature 'Admin - Sign In', type: :feature do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
scenario 'lets a user sign in successfully', js: true do
|
13
|
-
|
14
|
-
|
15
|
-
click_button 'Login'
|
13
|
+
log_in(email: @user.email, password: 'secret')
|
14
|
+
show_user_menu
|
16
15
|
|
17
|
-
expect(page).to have_text 'Logged in successfully'
|
18
16
|
expect(page).not_to have_text 'Login'
|
19
|
-
expect(page).to have_text '
|
20
|
-
expect(current_path).to eq '/'
|
17
|
+
expect(page).to have_text 'LOG OUT'
|
18
|
+
expect(current_path).to eq '/account'
|
21
19
|
end
|
22
20
|
|
23
21
|
scenario 'shows validation errors' do
|
@@ -35,7 +33,7 @@ RSpec.feature 'Admin - Sign In', type: :feature do
|
|
35
33
|
|
36
34
|
fill_in 'Email', with: user.email
|
37
35
|
fill_in 'Password', with: 'secret'
|
38
|
-
click_button '
|
36
|
+
click_button 'Log in'
|
39
37
|
within '.user-menu' do
|
40
38
|
expect(page).to have_text 'admin@person.com'
|
41
39
|
end
|
@@ -13,7 +13,7 @@ RSpec.feature 'Admin - Sign Out', type: :feature do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
scenario 'allows a signed in user to logout', js: true do
|
16
|
-
|
16
|
+
log_out
|
17
17
|
visit spree.admin_login_path
|
18
18
|
expect(page).to have_button 'Login'
|
19
19
|
expect(page).not_to have_text 'Logout'
|
@@ -3,13 +3,7 @@ RSpec.feature 'Change email', type: :feature do
|
|
3
3
|
allow_bypass_sign_in
|
4
4
|
|
5
5
|
user = create(:user, email: 'old@spree.com', password: 'secret')
|
6
|
-
|
7
|
-
click_link 'Login'
|
8
|
-
|
9
|
-
fill_in 'spree_user[email]', with: user.email
|
10
|
-
fill_in 'spree_user[password]', with: 'secret'
|
11
|
-
click_button 'Login'
|
12
|
-
|
6
|
+
log_in(email: user.email, password: 'secret')
|
13
7
|
visit spree.edit_account_path
|
14
8
|
end
|
15
9
|
|