spree_auth_devise 4.0.0 → 4.3.1
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.
Potentially problematic release.
This version of spree_auth_devise might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.circleci/config.yml +41 -0
- data/.gitignore +1 -0
- data/.travis.yml +33 -37
- data/Appraisals +3 -14
- data/Gemfile +1 -1
- data/README.md +3 -12
- data/Rakefile +9 -3
- data/app/controllers/spree/api/v2/storefront/account_confirmations_controller.rb +20 -0
- data/app/controllers/spree/api/v2/storefront/passwords_controller.rb +35 -0
- data/app/controllers/spree/user_confirmations_controller.rb +38 -0
- data/app/controllers/spree/user_passwords_controller.rb +9 -1
- data/app/controllers/spree/user_registrations_controller.rb +34 -1
- data/app/controllers/spree/user_sessions_controller.rb +23 -1
- data/app/mailers/spree/user_mailer.rb +11 -4
- data/app/models/spree/user.rb +42 -0
- data/app/services/spree/account/create.rb +19 -0
- data/app/services/spree/account/update.rb +17 -0
- data/app/views/spree/user_mailer/confirmation_instructions.html.erb +20 -0
- data/app/views/spree/user_mailer/confirmation_instructions.text.erb +8 -5
- data/app/views/spree/user_mailer/reset_password_instructions.html.erb +20 -0
- data/app/views/spree/user_mailer/reset_password_instructions.text.erb +7 -5
- 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/de.yml +16 -0
- data/config/locales/en.yml +21 -6
- data/config/locales/zh-TW.yml +58 -0
- data/config/routes.rb +12 -3
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -2
- data/gemfiles/{spree_3_2.gemfile → spree_4_1.gemfile} +1 -1
- data/lib/controllers/api/spree/api/v2/storefront/account_controller_decorator.rb +41 -0
- data/lib/controllers/frontend/spree/checkout_controller_decorator.rb +3 -2
- data/lib/controllers/frontend/spree/users_controller.rb +4 -4
- data/lib/generators/spree/auth/install/install_generator.rb +0 -4
- data/lib/spree/auth/engine.rb +14 -1
- data/lib/spree/testing_support/auth_helpers.rb +36 -0
- data/lib/spree/testing_support/checkout_helpers.rb +24 -0
- data/lib/spree_auth_devise.rb +0 -1
- 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/api/v2/storefront/passwords_controller_spec.rb +63 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +12 -13
- 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 +13 -9
- 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 +40 -65
- data/spec/features/confirmation_spec.rb +4 -6
- data/spec/features/order_spec.rb +9 -15
- data/spec/features/password_reset_spec.rb +2 -4
- data/spec/features/sign_in_spec.rb +21 -17
- data/spec/features/sign_out_spec.rb +14 -23
- data/spec/features/sign_up_spec.rb +6 -4
- data/spec/mailers/user_mailer_spec.rb +4 -4
- data/spec/models/user_spec.rb +10 -8
- data/spec/requests/spree/api/v2/storefront/account_confirmation_spec.rb +48 -0
- data/spec/requests/spree/api/v2/storefront/account_spec.rb +101 -0
- data/spec/spec_helper.rb +7 -22
- data/spree_auth_devise.gemspec +14 -27
- metadata +35 -337
- data/app/overrides/auth_shared_login_bar.rb +0 -6
- data/app/overrides/spree/admin/shared/_header/auth_admin_login_navigation_bar.html.erb.deface +0 -4
- 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_5.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
- data/spec/support/add_to_cart.rb +0 -15
- data/spec/support/authentication_helpers.rb +0 -14
- data/spec/support/cache_helpers.rb +0 -5
- data/spec/support/capybara.rb +0 -16
- data/spec/support/database_cleaner.rb +0 -17
- data/spec/support/factory_girl.rb +0 -5
- data/spec/support/spree.rb +0 -10
@@ -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,9 +33,15 @@ 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 '
|
39
|
-
|
40
|
-
|
36
|
+
click_button 'Log in'
|
37
|
+
if Spree.version.to_f > 4.1
|
38
|
+
within '.navbar .dropdown-menu' do
|
39
|
+
expect(page).to have_text 'admin@person.com'
|
40
|
+
end
|
41
|
+
else
|
42
|
+
within '.user-menu' do
|
43
|
+
expect(page).to have_text 'admin@person.com'
|
44
|
+
end
|
41
45
|
end
|
42
46
|
expect(current_path).to eq '/admin/orders'
|
43
47
|
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
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
RSpec.feature 'Checkout', :js, type: :feature do
|
2
|
-
given!(:store) { create(:store) }
|
3
2
|
given!(:country) { create(:country, name: 'United States', states_required: true) }
|
4
3
|
given!(:state) { create(:state, name: 'Maryland', country: country) }
|
5
4
|
given!(:shipping_method) do
|
@@ -9,12 +8,13 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
9
8
|
shipping_method.tap(&:save)
|
10
9
|
end
|
11
10
|
|
11
|
+
given!(:user) { create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password') }
|
12
12
|
given!(:zone) { create(:zone) }
|
13
13
|
given!(:address) { create(:address, state: state, country: country) }
|
14
|
+
given!(:mug) { create(:product, name: 'RoR Mug') }
|
14
15
|
|
15
16
|
background do
|
16
|
-
|
17
|
-
@product.master.stock_items.first.update_column(:count_on_hand, 1)
|
17
|
+
mug.master.stock_items.first.update_column(:count_on_hand, 1)
|
18
18
|
|
19
19
|
# Bypass gateway error on checkout | ..or stub a gateway
|
20
20
|
Spree::Config[:allow_checkout_on_gateway_error] = true
|
@@ -31,127 +31,102 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
31
31
|
|
32
32
|
scenario 'allow a visitor to checkout as guest, without registration' do
|
33
33
|
Spree::Auth::Config.set(registration_step: true)
|
34
|
-
add_to_cart
|
35
|
-
|
34
|
+
add_to_cart(mug)
|
35
|
+
click_link 'checkout'
|
36
36
|
|
37
|
-
expect(page).to
|
37
|
+
expect(page).to have_selector(:button, 'Continue as a guest')
|
38
38
|
|
39
|
-
within('#
|
39
|
+
within('#checkout_form_registration') { fill_in 'Email', with: 'spree@test.com' }
|
40
40
|
click_button 'Continue'
|
41
41
|
|
42
42
|
expect(page).to have_text(/Billing Address/i)
|
43
43
|
expect(page).to have_text(/Shipping Address/i)
|
44
44
|
|
45
|
-
|
46
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
47
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
48
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
49
|
-
end
|
50
|
-
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
51
|
-
check 'order_use_billing'
|
52
|
-
|
45
|
+
fill_in_address
|
53
46
|
click_button 'Save and Continue'
|
54
47
|
click_button 'Save and Continue'
|
55
48
|
|
56
|
-
expect(page).to have_text '
|
49
|
+
expect(page).to have_text 'Order placed successfully'
|
57
50
|
end
|
58
51
|
|
59
52
|
scenario 'associate an uncompleted guest order with user after logging in' do
|
60
|
-
|
61
|
-
add_to_cart 'RoR Mug'
|
53
|
+
add_to_cart(mug)
|
62
54
|
|
63
55
|
visit spree.login_path
|
64
56
|
fill_in 'Email', with: user.email
|
65
57
|
fill_in 'Password', with: user.password
|
66
|
-
click_button '
|
67
|
-
expect(page).to have_text('
|
68
|
-
|
58
|
+
click_button 'Log in'
|
59
|
+
expect(page).to have_text('Logged in successfully')
|
60
|
+
find('a.cart-icon').click
|
69
61
|
|
70
62
|
expect(page).to have_text 'RoR Mug'
|
71
|
-
within('h1') { expect(page).to have_text '
|
72
|
-
|
73
|
-
click_button 'Checkout'
|
63
|
+
within('h1') { expect(page).to have_text 'YOUR SHOPPING CART' }
|
74
64
|
|
75
|
-
|
76
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
77
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
78
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
79
|
-
end
|
80
|
-
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
81
|
-
check 'order_use_billing'
|
65
|
+
click_link 'checkout'
|
82
66
|
|
67
|
+
fill_in_address
|
83
68
|
click_button 'Save and Continue'
|
84
69
|
click_button 'Save and Continue'
|
85
70
|
|
86
|
-
expect(page).to have_text '
|
71
|
+
expect(page).to have_text 'Order placed successfully'
|
87
72
|
expect(Spree::Order.first.user).to eq user
|
88
73
|
end
|
89
74
|
|
90
75
|
# Regression test for #890
|
91
76
|
scenario 'associate an incomplete guest order with user after successful password reset' do
|
92
|
-
|
93
|
-
user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
|
94
|
-
add_to_cart 'RoR Mug'
|
77
|
+
add_to_cart(mug)
|
95
78
|
|
96
79
|
visit spree.login_path
|
97
|
-
click_link 'Forgot
|
98
|
-
fill_in
|
80
|
+
click_link 'Forgot password?'
|
81
|
+
fill_in('Email', with: 'email@person.com')
|
82
|
+
find('#spree_user_email').set('email@person.com')
|
83
|
+
|
99
84
|
click_button 'Reset my password'
|
100
85
|
|
101
86
|
# Need to do this now because the token stored in the DB is the encrypted version
|
102
87
|
# The 'plain-text' version is sent in the email and there's one way to get that!
|
103
88
|
reset_password_email = ActionMailer::Base.deliveries.first
|
104
89
|
token_url_regex = /^http:\/\/www.example.com\/user\/spree_user\/password\/edit\?reset_password_token=(.*)$/
|
105
|
-
token = token_url_regex.match(reset_password_email.body.
|
90
|
+
token = token_url_regex.match(reset_password_email.body.encoded)[1]
|
106
91
|
|
107
|
-
visit spree.edit_spree_user_password_path(reset_password_token: token)
|
92
|
+
visit spree.edit_spree_user_password_path(reset_password_token: token).tr("%0D","")
|
108
93
|
fill_in 'Password', with: 'password'
|
109
94
|
fill_in 'Password Confirmation', with: 'password'
|
110
95
|
click_button 'Update'
|
111
96
|
|
112
|
-
expect(page).to have_text('
|
113
|
-
|
97
|
+
expect(page).to have_text('Your password was changed successfully')
|
98
|
+
find('a.cart-icon').click
|
114
99
|
expect(page).to have_text('RoR Mug')
|
115
|
-
|
116
|
-
|
117
|
-
str_addr = 'bill_address'
|
118
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
119
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
120
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
121
|
-
end
|
122
|
-
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
123
|
-
check 'order_use_billing'
|
100
|
+
click_link 'checkout'
|
124
101
|
|
102
|
+
fill_in_address
|
125
103
|
click_button 'Save and Continue'
|
126
104
|
|
127
105
|
expect(page).not_to have_text 'Email is invalid'
|
128
106
|
end
|
129
107
|
|
130
108
|
scenario 'allow a user to register during checkout' do
|
131
|
-
add_to_cart
|
132
|
-
|
109
|
+
add_to_cart(mug)
|
110
|
+
click_link 'checkout'
|
133
111
|
|
134
|
-
expect(page).to
|
112
|
+
expect(page).to have_selector(:link, 'Sign Up')
|
135
113
|
|
136
|
-
|
114
|
+
click_link 'Sign Up'
|
115
|
+
|
116
|
+
fill_in 'Email', with: 'test@person.com'
|
137
117
|
fill_in 'Password', with: 'spree123'
|
138
118
|
fill_in 'Password Confirmation', with: 'spree123'
|
139
|
-
click_button 'Create'
|
140
|
-
expect(page).to have_text 'You have signed up successfully.'
|
141
119
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: address.send(field).to_s
|
146
|
-
end
|
147
|
-
select address.state.name.to_s, from: "order_#{str_addr}_attributes_state_id"
|
148
|
-
check 'order_use_billing'
|
120
|
+
click_button 'Sign Up'
|
121
|
+
|
122
|
+
expect(page).to have_text 'You have signed up successfully.'
|
149
123
|
|
124
|
+
fill_in_address
|
150
125
|
click_button 'Save and Continue'
|
151
126
|
click_button 'Save and Continue'
|
152
127
|
|
153
|
-
expect(page).to have_text '
|
154
|
-
expect(Spree::Order.first.user).to eq Spree
|
128
|
+
expect(page).to have_text 'Order placed successfully'
|
129
|
+
expect(Spree::Order.first.user).to eq Spree.user_class.find_by_email('test@person.com')
|
155
130
|
end
|
156
131
|
end
|
157
132
|
end
|