solidus_auth_devise 2.0.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_auth_devise might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/.circleci/config.yml +35 -0
- data/.gem_release.yml +5 -0
- data/.github/stale.yml +17 -0
- data/.gitignore +12 -8
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +284 -145
- data/Gemfile +22 -14
- data/{LICENSE.md → LICENSE} +2 -2
- data/README.md +50 -3
- data/Rakefile +2 -0
- data/app/mailers/spree/user_mailer.rb +4 -2
- data/app/models/spree/auth_configuration.rb +2 -0
- data/app/models/spree/user.rb +30 -20
- data/app/overrides/spree/admin/users/edit/_add_reset_password_form.html.erb.deface +20 -0
- data/bin/console +17 -0
- data/bin/rails +12 -4
- data/bin/setup +8 -0
- data/config/initializers/devise.rb +11 -3
- data/config/initializers/warden.rb +4 -2
- data/config/locales/en.yml +4 -1
- data/config/locales/fr.yml +1 -1
- data/config/locales/it.yml +4 -4
- data/config/routes.rb +16 -15
- data/db/default/users.rb +10 -8
- data/db/migrate/20101026184949_create_users.rb +9 -7
- data/db/migrate/20101026184950_rename_columns_for_devise.rb +3 -1
- data/db/migrate/20101214150824_convert_user_remember_field.rb +2 -0
- data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -0
- data/db/migrate/20120605211305_make_users_email_index_unique.rb +4 -2
- data/db/migrate/20140904000425_add_deleted_at_to_users.rb +2 -0
- data/db/migrate/20141002154641_add_confirmable_to_users.rb +2 -0
- data/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +34 -0
- data/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb +7 -0
- data/db/seeds.rb +2 -0
- data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +7 -4
- data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +12 -10
- data/lib/controllers/frontend/spree/user_confirmations_controller.rb +2 -0
- data/lib/controllers/frontend/spree/user_passwords_controller.rb +4 -1
- data/lib/controllers/frontend/spree/user_registrations_controller.rb +4 -0
- data/lib/controllers/frontend/spree/user_sessions_controller.rb +4 -2
- data/lib/controllers/frontend/spree/users_controller.rb +20 -15
- data/lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb +20 -0
- data/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb +22 -0
- data/lib/{controllers/frontend → decorators/frontend/controllers}/spree/checkout_controller_decorator.rb +29 -19
- data/lib/generators/solidus/auth/install/install_generator.rb +15 -3
- data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +3 -1
- data/lib/solidus/auth.rb +2 -0
- data/lib/solidus_auth_devise.rb +13 -5
- data/lib/spree/auth/devise.rb +2 -7
- data/lib/spree/auth/engine.rb +51 -38
- data/lib/spree/auth/version.rb +7 -0
- data/lib/spree/authentication_helpers.rb +5 -11
- data/lib/tasks/auth.rake +3 -1
- data/lib/views/backend/spree/admin/shared/_navigation_footer.html.erb +13 -6
- data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +4 -4
- data/lib/views/backend/spree/admin/user_passwords/new.html.erb +6 -8
- 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 +9 -9
- data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +4 -4
- data/lib/views/frontend/spree/checkout/registration.html.erb +4 -4
- data/lib/views/frontend/spree/shared/_login.html.erb +4 -4
- data/lib/views/frontend/spree/shared/_login_bar.html.erb +2 -6
- data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +6 -0
- data/lib/views/frontend/spree/shared/_user_form.html.erb +3 -3
- data/lib/views/frontend/spree/user_passwords/edit.html.erb +4 -4
- data/lib/views/frontend/spree/user_passwords/new.html.erb +5 -7
- data/lib/views/frontend/spree/user_registrations/new.html.erb +3 -3
- data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +1 -1
- data/lib/views/frontend/spree/user_sessions/new.html.erb +2 -2
- data/lib/views/frontend/spree/users/edit.html.erb +2 -2
- data/lib/views/frontend/spree/users/show.html.erb +12 -12
- data/solidus_auth_devise.gemspec +38 -31
- data/spec/controllers/spree/admin/base_controller_spec.rb +53 -0
- data/spec/controllers/spree/admin/user_passwords_controller_spec.rb +14 -0
- data/spec/controllers/spree/base_controller_spec.rb +53 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +6 -10
- data/spec/controllers/spree/products_controller_spec.rb +6 -3
- data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -3
- data/spec/controllers/spree/user_registrations_controller_spec.rb +3 -2
- data/spec/controllers/spree/user_sessions_controller_spec.rb +14 -0
- data/spec/controllers/spree/users_controller_spec.rb +26 -8
- data/spec/factories/confirmed_user.rb +7 -5
- data/spec/features/account_spec.rb +4 -3
- data/spec/features/admin/password_reset_spec.rb +66 -10
- data/spec/features/admin/products_spec.rb +2 -1
- data/spec/features/admin/sign_in_spec.rb +2 -1
- data/spec/features/admin/sign_out_spec.rb +2 -1
- data/spec/features/admin_permissions_spec.rb +2 -1
- data/spec/features/change_email_spec.rb +3 -2
- data/spec/features/checkout_spec.rb +14 -37
- data/spec/features/confirmation_spec.rb +6 -10
- data/spec/features/order_spec.rb +2 -1
- data/spec/features/password_reset_spec.rb +23 -10
- data/spec/features/sign_in_spec.rb +2 -1
- data/spec/features/sign_out_spec.rb +4 -3
- data/spec/features/sign_up_spec.rb +2 -1
- data/spec/mailers/user_mailer_spec.rb +2 -1
- data/spec/models/order_spec.rb +2 -1
- data/spec/models/user_spec.rb +57 -38
- data/spec/spec_helper.rb +13 -9
- data/spec/support/ability.rb +3 -1
- data/spec/support/authentication_helpers.rb +2 -0
- data/spec/support/confirm_helpers.rb +23 -10
- data/spec/support/email.rb +2 -0
- data/spec/support/features/fill_addresses_fields.rb +29 -0
- data/spec/support/preferences.rb +10 -2
- data/spec/support/spree.rb +2 -0
- metadata +327 -243
- data/.travis.yml +0 -22
- data/app/overrides/auth_admin_login_navigation_bar.rb +0 -11
- data/app/overrides/auth_shared_login_bar.rb +0 -10
- data/circle.yml +0 -6
- data/lib/assets/javascripts/spree/backend/solidus_auth.js +0 -1
- data/lib/assets/javascripts/spree/frontend/solidus_auth.js +0 -1
- data/lib/assets/stylesheets/spree/backend/solidus_auth.css +0 -3
- data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +0 -3
- data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +0 -11
- data/lib/controllers/backend/spree/admin/admin_orders_controller_decorator.rb +0 -20
- data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +0 -15
- data/spec/features/admin/orders_spec.rb +0 -30
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.describe Spree::CheckoutController, type: :controller do
|
3
4
|
let(:order) { create(:order_with_line_items, email: nil, user: nil, guest_token: token) }
|
4
5
|
let(:user) { build(:user, spree_api_key: 'fake') }
|
5
6
|
let(:token) { 'some_token' }
|
@@ -39,11 +40,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
39
40
|
|
40
41
|
context 'when guest checkout not allowed' do
|
41
42
|
before do
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
after do
|
46
|
-
Spree::Config.set(allow_guest_checkout: true)
|
43
|
+
stub_spree_preferences(allow_guest_checkout: false)
|
47
44
|
end
|
48
45
|
|
49
46
|
it 'redirects to registration step' do
|
@@ -56,7 +53,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
56
53
|
|
57
54
|
context 'when registration step disabled' do
|
58
55
|
before do
|
59
|
-
Spree::Auth::Config
|
56
|
+
stub_spree_preferences(Spree::Auth::Config, registration_step: false)
|
60
57
|
end
|
61
58
|
|
62
59
|
context 'when authenticated as registered' do
|
@@ -80,8 +77,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
80
77
|
context '#update' do
|
81
78
|
context 'when in the confirm state' do
|
82
79
|
before do
|
83
|
-
order.
|
84
|
-
order.update_column(:state, 'confirm')
|
80
|
+
order.update(email: 'spree@example.com', state: 'confirm')
|
85
81
|
|
86
82
|
# So that the order can transition to complete successfully
|
87
83
|
allow(order).to receive(:payment_required?) { false }
|
@@ -94,7 +90,7 @@ RSpec.describe Spree::CheckoutController, type: :controller do
|
|
94
90
|
request.cookie_jar.signed[:guest_token] = 'ABC'
|
95
91
|
post :update, params: { state: 'confirm' }
|
96
92
|
expect(response).to redirect_to spree.token_order_path(order, 'ABC')
|
97
|
-
expect(flash.notice).to eq
|
93
|
+
expect(flash.notice).to eq I18n.t('spree.order_processed_successfully')
|
98
94
|
end
|
99
95
|
end
|
100
96
|
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.describe Spree::ProductsController, type: :controller do
|
3
4
|
let!(:product) { create(:product, available_on: 1.year.from_now) }
|
4
5
|
let!(:user) { build(:user, spree_api_key: 'fake') }
|
5
6
|
|
@@ -15,7 +16,9 @@ RSpec.describe Spree::ProductsController, type: :controller do
|
|
15
16
|
allow(controller).to receive(:before_save_new_order)
|
16
17
|
allow(controller).to receive(:spree_current_user) { user }
|
17
18
|
allow(user).to receive(:has_spree_role?) { false }
|
18
|
-
|
19
|
-
expect
|
19
|
+
|
20
|
+
expect {
|
21
|
+
get :show, params: { id: product.to_param }
|
22
|
+
}.to raise_error(ActiveRecord::RecordNotFound)
|
20
23
|
end
|
21
24
|
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.describe Spree::UserPasswordsController, type: :controller do
|
3
4
|
let(:token) { 'some_token' }
|
4
5
|
|
5
6
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
@@ -16,7 +17,7 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
16
17
|
it 'flashes an error' do
|
17
18
|
get :edit
|
18
19
|
expect(flash[:alert]).to include(
|
19
|
-
"You can't access this page without coming from a password reset "
|
20
|
+
"You can't access this page without coming from a password reset " \
|
20
21
|
'email'
|
21
22
|
)
|
22
23
|
end
|
@@ -34,7 +35,7 @@ RSpec.describe Spree::UserPasswordsController, type: :controller do
|
|
34
35
|
context 'when updating password with blank password' do
|
35
36
|
it 'shows error flash message, sets spree_user with token and re-displays password edit form' do
|
36
37
|
put :update, params: { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
|
37
|
-
expect(assigns(:spree_user).
|
38
|
+
expect(assigns(:spree_user).is_a?(Spree::User)).to eq true
|
38
39
|
expect(assigns(:spree_user).reset_password_token).to eq token
|
39
40
|
expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user])
|
40
41
|
expect(response).to render_template :edit
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
3
4
|
before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
|
4
5
|
|
5
6
|
context '#create' do
|
@@ -56,7 +57,7 @@ RSpec.describe Spree::UserRegistrationsController, type: :controller do
|
|
56
57
|
it 'assigns orders with the correct token and no user present' do
|
57
58
|
order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
|
58
59
|
subject
|
59
|
-
user = Spree::User.
|
60
|
+
user = Spree::User.find_by(email: 'foobar@example.com')
|
60
61
|
|
61
62
|
order.reload
|
62
63
|
expect(order.user_id).to eq user.id
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.describe Spree::UserSessionsController, type: :controller do
|
2
4
|
let(:user) { create(:user) }
|
3
5
|
|
@@ -110,4 +112,16 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
|
|
110
112
|
end
|
111
113
|
end
|
112
114
|
end
|
115
|
+
|
116
|
+
context "#destroy" do
|
117
|
+
subject do
|
118
|
+
delete(:destroy)
|
119
|
+
end
|
120
|
+
|
121
|
+
it "redirects to default after signing out" do
|
122
|
+
subject
|
123
|
+
expect(controller.spree_current_user).to be_nil
|
124
|
+
expect(response).to redirect_to spree.root_path
|
125
|
+
end
|
126
|
+
end
|
113
127
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.describe Spree::UsersController, type: :controller do
|
3
4
|
let(:admin_user) { create(:user) }
|
4
5
|
let(:user) { create(:user) }
|
5
6
|
let(:role) { create(:role) }
|
6
7
|
|
7
|
-
before { allow(controller).to receive(:spree_current_user) { user } }
|
8
|
-
|
9
8
|
context '#load_object' do
|
10
9
|
it 'redirects to signup path if user is not found' do
|
11
|
-
allow(controller).to receive(:spree_current_user) { nil }
|
12
10
|
put :update, params: { user: { email: 'foobar@example.com' } }
|
13
11
|
expect(response).to redirect_to spree.login_path
|
14
12
|
end
|
@@ -22,11 +20,31 @@ RSpec.describe Spree::UsersController, type: :controller do
|
|
22
20
|
end
|
23
21
|
|
24
22
|
context '#update' do
|
23
|
+
before { sign_in(user) }
|
24
|
+
|
25
25
|
context 'when updating own account' do
|
26
|
-
|
27
|
-
put :update, params: { user: { email: 'mynew@email-address.com' } }
|
28
|
-
|
29
|
-
|
26
|
+
context 'when user updated successfuly' do
|
27
|
+
before { put :update, params: { user: { email: 'mynew@email-address.com' } } }
|
28
|
+
|
29
|
+
it 'saves user' do
|
30
|
+
expect(assigns[:user].email).to eq 'mynew@email-address.com'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'updates spree_current_user' do
|
34
|
+
expect(subject.spree_current_user.email).to eq 'mynew@email-address.com'
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'redirects to account url' do
|
38
|
+
expect(response).to redirect_to spree.account_url(only_path: true)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when user not valid' do
|
43
|
+
before { put :update, params: { user: { email: '' } } }
|
44
|
+
|
45
|
+
it 'does not affect spree_current_user' do
|
46
|
+
expect(subject.spree_current_user.email).to eq user.email
|
47
|
+
end
|
30
48
|
end
|
31
49
|
end
|
32
50
|
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
2
4
|
factory :confirmed_user, parent: :user do
|
3
|
-
confirmed_at { Time.now }
|
4
|
-
confirmation_sent_at { Time.now }
|
5
|
-
confirmation_token "12345"
|
5
|
+
confirmed_at { Time.zone.now }
|
6
|
+
confirmation_sent_at { Time.zone.now }
|
7
|
+
confirmation_token { "12345" }
|
6
8
|
end
|
7
|
-
end
|
9
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.feature 'Accounts', type: :feature do
|
3
4
|
context 'editing' do
|
4
5
|
scenario 'can edit an admin user' do
|
5
6
|
user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password')
|
@@ -14,7 +15,7 @@ RSpec.feature 'Accounts', type: :feature do
|
|
14
15
|
end
|
15
16
|
|
16
17
|
scenario 'can edit a new user' do
|
17
|
-
Spree::Auth::Config
|
18
|
+
stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false)
|
18
19
|
visit spree.signup_path
|
19
20
|
|
20
21
|
fill_in 'Email', with: 'email@person.com'
|
@@ -35,7 +36,7 @@ RSpec.feature 'Accounts', type: :feature do
|
|
35
36
|
end
|
36
37
|
|
37
38
|
scenario 'can edit an existing user account' do
|
38
|
-
Spree::Auth::Config
|
39
|
+
stub_spree_preferences(Spree::Auth::Config ,signout_after_password_change: false)
|
39
40
|
user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret')
|
40
41
|
visit spree.login_path
|
41
42
|
|
@@ -1,24 +1,80 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.feature 'Admin - Reset Password', type: :feature do
|
3
4
|
let!(:store) { create(:store) }
|
4
5
|
|
5
6
|
background do
|
6
7
|
ActionMailer::Base.default_url_options[:host] = 'http://example.com'
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
user
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
context 'when an account with this email address exists' do
|
11
|
+
let!(:user) { create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret') }
|
12
|
+
|
13
|
+
scenario 'allows a user to supply an email for the password reset' do
|
14
|
+
visit spree.admin_login_path
|
15
|
+
click_link 'Forgot Password?'
|
16
|
+
fill_in_email
|
17
|
+
click_button 'Reset my password'
|
18
|
+
expect(page).to have_text 'you will receive an email with instructions'
|
19
|
+
end
|
16
20
|
end
|
17
21
|
|
18
|
-
|
22
|
+
# Revealing that an admin email address is not found allows an attacker to
|
23
|
+
# find admin account email addresses by trying email addresses until this
|
24
|
+
# error is not shown.
|
25
|
+
scenario 'does not reveal email addresses if they are not found' do
|
19
26
|
visit spree.admin_login_path
|
20
27
|
click_link 'Forgot Password?'
|
28
|
+
fill_in_email
|
21
29
|
click_button 'Reset my password'
|
22
|
-
expect(page).
|
30
|
+
expect(page).to_not have_text "Email not found"
|
31
|
+
expect(page).to have_text 'you will receive an email with instructions'
|
32
|
+
end
|
33
|
+
|
34
|
+
def fill_in_email
|
35
|
+
fill_in 'Email', with: 'foobar@example.com'
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'password management' do
|
39
|
+
let!(:admin) do
|
40
|
+
create(:admin_user,
|
41
|
+
email: 'admin@example.com',
|
42
|
+
password: 'secret',
|
43
|
+
password_confirmation: 'secret'
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
let!(:user) do
|
48
|
+
create(:user,
|
49
|
+
email: 'user@example.com',
|
50
|
+
password: 'test123',
|
51
|
+
password_confirmation: 'test123'
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
before do
|
56
|
+
visit spree.admin_login_path
|
57
|
+
fill_in 'Email', with: admin.email
|
58
|
+
fill_in 'Password', with: admin.password
|
59
|
+
click_button 'Login'
|
60
|
+
visit spree.admin_users_path
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'if currently logged-in admin' do
|
64
|
+
context "clicks on an user's page" do
|
65
|
+
it 'can reset its password' do
|
66
|
+
within("#spree_user_#{user.id}") do
|
67
|
+
click_link user.email
|
68
|
+
end
|
69
|
+
|
70
|
+
click_button 'Reset password'
|
71
|
+
expect(page).to have_content(
|
72
|
+
'If an account with that email address exists, '\
|
73
|
+
'you will receive an email with instructions about '\
|
74
|
+
'how to reset your password in a few minutes.'
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
23
79
|
end
|
24
80
|
end
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.feature 'Admin products', type: :feature do
|
3
4
|
context 'as anonymous user' do
|
4
5
|
# Regression test for #1250
|
5
6
|
scenario 'redirects to login page when attempting to access product listing' do
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.feature 'Admin Permissions', type: :feature do
|
3
4
|
context 'orders' do
|
4
5
|
background do
|
5
6
|
user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password')
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
RSpec.feature 'Change email', type: :feature do
|
3
4
|
background do
|
4
|
-
Spree::Auth::Config
|
5
|
+
stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false)
|
5
6
|
|
6
7
|
user = create(:user)
|
7
8
|
visit spree.root_path
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.feature 'Checkout', :js, type: :feature do
|
2
4
|
given!(:store) { create(:store) }
|
3
5
|
given!(:country) { create(:country, name: 'United States', states_required: true) }
|
@@ -15,17 +17,17 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
15
17
|
|
16
18
|
background do
|
17
19
|
@product = create(:product, name: 'RoR Mug')
|
18
|
-
@product.master.stock_items.first.
|
20
|
+
@product.master.stock_items.first.set_count_on_hand(1)
|
19
21
|
|
20
22
|
# Bypass gateway error on checkout | ..or stub a gateway
|
21
|
-
|
23
|
+
stub_spree_preferences(allow_checkout_on_gateway_error: true)
|
22
24
|
|
23
25
|
visit spree.root_path
|
24
26
|
end
|
25
27
|
|
26
28
|
# Regression test for https://github.com/solidusio/solidus/issues/1588
|
27
29
|
scenario 'leaving and returning to address step' do
|
28
|
-
Spree::Auth::Config
|
30
|
+
stub_spree_preferences(Spree::Auth::Config, registration_step: true)
|
29
31
|
click_link 'RoR Mug'
|
30
32
|
click_button 'Add To Cart'
|
31
33
|
within('h1') { expect(page).to have_text 'Shopping Cart' }
|
@@ -58,15 +60,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
58
60
|
expect(page).to have_text(/Billing Address/i)
|
59
61
|
expect(page).to have_text(/Shipping Address/i)
|
60
62
|
|
61
|
-
|
62
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
63
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
64
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}"
|
65
|
-
end
|
66
|
-
select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id"
|
67
|
-
check 'order_use_billing'
|
68
|
-
|
63
|
+
fill_addresses_fields_with(address)
|
69
64
|
click_button 'Save and Continue'
|
65
|
+
|
70
66
|
click_button 'Save and Continue'
|
71
67
|
click_button 'Save and Continue'
|
72
68
|
click_button 'Place Order'
|
@@ -90,15 +86,9 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
90
86
|
|
91
87
|
click_button 'Checkout'
|
92
88
|
|
93
|
-
|
94
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
95
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
96
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}"
|
97
|
-
end
|
98
|
-
select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id"
|
99
|
-
check 'order_use_billing'
|
100
|
-
|
89
|
+
fill_addresses_fields_with(address)
|
101
90
|
click_button 'Save and Continue'
|
91
|
+
|
102
92
|
click_button 'Save and Continue'
|
103
93
|
click_button 'Save and Continue'
|
104
94
|
click_button 'Place Order'
|
@@ -109,7 +99,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
109
99
|
|
110
100
|
# Regression test for #890
|
111
101
|
scenario 'associate an incomplete guest order with user after successful password reset' do
|
112
|
-
|
102
|
+
create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
|
113
103
|
click_link 'RoR Mug'
|
114
104
|
click_button 'Add To Cart'
|
115
105
|
|
@@ -132,14 +122,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
132
122
|
click_link 'Cart'
|
133
123
|
click_button 'Checkout'
|
134
124
|
|
135
|
-
|
136
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
137
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
138
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}"
|
139
|
-
end
|
140
|
-
select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id"
|
141
|
-
check 'order_use_billing'
|
142
|
-
|
125
|
+
fill_addresses_fields_with(address)
|
143
126
|
click_button 'Save and Continue'
|
144
127
|
|
145
128
|
expect(page).not_to have_text 'Email is invalid'
|
@@ -161,21 +144,15 @@ RSpec.feature 'Checkout', :js, type: :feature do
|
|
161
144
|
|
162
145
|
expect(page).to have_text 'You have signed up successfully.'
|
163
146
|
|
164
|
-
|
165
|
-
select 'United States', from: "order_#{str_addr}_attributes_country_id"
|
166
|
-
%w(firstname lastname address1 city zipcode phone).each do |field|
|
167
|
-
fill_in "order_#{str_addr}_attributes_#{field}", with: "#{address.send(field)}"
|
168
|
-
end
|
169
|
-
select "#{address.state.name}", from: "order_#{str_addr}_attributes_state_id"
|
170
|
-
check 'order_use_billing'
|
171
|
-
|
147
|
+
fill_addresses_fields_with(address)
|
172
148
|
click_button 'Save and Continue'
|
149
|
+
|
173
150
|
click_button 'Save and Continue'
|
174
151
|
click_button 'Save and Continue'
|
175
152
|
click_button 'Place Order'
|
176
153
|
|
177
154
|
expect(page).to have_text 'Your order has been processed successfully'
|
178
|
-
expect(Spree::Order.first.user).to eq Spree::User.
|
155
|
+
expect(Spree::Order.first.user).to eq Spree::User.find_by(email: 'email@person.com')
|
179
156
|
end
|
180
157
|
end
|
181
158
|
end
|