spree_auth_devise 4.0.1 → 4.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of spree_auth_devise might be problematic. Click here for more details.

Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +41 -0
  3. data/.gitignore +1 -0
  4. data/.travis.yml +3 -16
  5. data/Appraisals +3 -14
  6. data/Gemfile +1 -1
  7. data/app/controllers/spree/user_confirmations_controller.rb +2 -0
  8. data/app/controllers/spree/user_passwords_controller.rb +2 -0
  9. data/app/controllers/spree/user_registrations_controller.rb +9 -0
  10. data/app/controllers/spree/user_sessions_controller.rb +23 -1
  11. data/app/views/spree/user_passwords/edit.html.erb +20 -17
  12. data/app/views/spree/user_passwords/new.html.erb +18 -15
  13. data/app/views/spree/user_registrations/new.html.erb +12 -17
  14. data/app/views/spree/user_sessions/new.html.erb +11 -12
  15. data/config/routes.rb +0 -1
  16. data/gemfiles/{spree_3_5.gemfile → spree_4_1.gemfile} +1 -1
  17. data/lib/controllers/frontend/spree/users_controller.rb +2 -7
  18. data/lib/generators/spree/auth/install/install_generator.rb +0 -4
  19. data/lib/spree/testing_support/auth_helpers.rb +36 -0
  20. data/lib/spree/testing_support/checkout_helpers.rb +24 -0
  21. data/spec/controllers/spree/admin/orders_controller_spec.rb +1 -1
  22. data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +1 -1
  23. data/spec/controllers/spree/checkout_controller_spec.rb +12 -13
  24. data/spec/controllers/spree/products_controller_spec.rb +1 -1
  25. data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -4
  26. data/spec/controllers/spree/user_registrations_controller_spec.rb +7 -7
  27. data/spec/controllers/spree/user_sessions_controller_spec.rb +17 -17
  28. data/spec/controllers/spree/users_controller_spec.rb +4 -4
  29. data/spec/features/account_spec.rb +10 -8
  30. data/spec/features/admin/password_reset_spec.rb +2 -4
  31. data/spec/features/admin/sign_in_spec.rb +5 -7
  32. data/spec/features/admin/sign_out_spec.rb +1 -1
  33. data/spec/features/admin_permissions_spec.rb +1 -1
  34. data/spec/features/change_email_spec.rb +1 -7
  35. data/spec/features/checkout_spec.rb +38 -63
  36. data/spec/features/confirmation_spec.rb +1 -3
  37. data/spec/features/order_spec.rb +9 -15
  38. data/spec/features/password_reset_spec.rb +2 -4
  39. data/spec/features/sign_in_spec.rb +7 -9
  40. data/spec/features/sign_out_spec.rb +16 -23
  41. data/spec/features/sign_up_spec.rb +4 -2
  42. data/spec/mailers/user_mailer_spec.rb +1 -1
  43. data/spec/spec_helper.rb +16 -0
  44. data/spec/support/add_to_cart.rb +11 -4
  45. data/spec/support/authentication_helpers.rb +1 -1
  46. data/spec/support/capybara.rb +15 -8
  47. data/spree_auth_devise.gemspec +13 -9
  48. metadata +100 -74
  49. data/app/overrides/auth_shared_login_bar.rb +0 -6
  50. data/app/views/spree/shared/_login.html.erb +0 -18
  51. data/app/views/spree/shared/_user_form.html.erb +0 -17
  52. data/gemfiles/spree_3_2.gemfile +0 -8
  53. data/gemfiles/spree_3_7.gemfile +0 -9
  54. data/gemfiles/spree_4_0.gemfile +0 -8
  55. data/lib/assets/javascripts/spree/backend/spree_auth.js.erb +0 -1
  56. data/lib/assets/javascripts/spree/frontend/account.js +0 -8
  57. data/lib/assets/javascripts/spree/frontend/spree_auth.js.erb +0 -2
  58. data/lib/assets/stylesheets/spree/backend/spree_auth.css.erb +0 -3
  59. data/lib/assets/stylesheets/spree/frontend/spree_auth.css.erb +0 -3
  60. data/lib/controllers/frontend/spree/store_controller_decorator.rb +0 -7
  61. data/lib/views/frontend/spree/checkout/_new_user.html.erb +0 -20
  62. data/lib/views/frontend/spree/checkout/registration.html.erb +0 -25
  63. data/lib/views/frontend/spree/shared/_link_to_account.html.erb +0 -6
  64. data/lib/views/frontend/spree/users/edit.html.erb +0 -17
  65. data/lib/views/frontend/spree/users/show.html.erb +0 -48
  66. data/spec/requests/spree/frontend/user_update_spec.rb +0 -42
@@ -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
- spree_get :edit
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
- spree_get :edit
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
- spree_get :edit, reset_password_token: token
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
- spree_put :update, { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
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.root_path(thing: 7)) }
5
+ before { allow(controller).to receive(:after_sign_up_path_for).and_return(spree.account_path) }
6
6
 
7
- it 'redirects to after_sign_up_path_for' do
8
- spree_post :create, { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
9
- expect(response).to redirect_to spree.root_path(thing: 7)
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,7 +24,7 @@ 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
- spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
27
+ post :create, params: { spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }}
28
28
  user = Spree::User.find_by_email('foobar@example.com')
29
29
 
30
30
  order.reload
@@ -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
- spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
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
- spree_post :create, spree_user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
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 default after signing in" do
157
- spree_post :create, spree_user: { email: user.email, password: 'secret' }
158
- expect(response).to redirect_to spree.root_path
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
- spree_post :create, spree_user: { email: user.email, password: 'secret' }, format: 'js'
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
- spree_post :create, spree_user: { email: user.email, password: 'wrong' }
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
- spree_post :create, spree_user: { email: user.email, password: 'wrong' }, format: 'js'
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
- spree_put :update, { user: { email: 'foobar@example.com' } }
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
- spree_post :create, { user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
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
- spree_put :update, { user: { email: 'mynew@email-address.com' } }
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
- spree_put :update, user: { spree_role_ids: [role.id] }
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 'Login'
13
+ click_button 'Log in'
14
14
 
15
- click_link 'My Account'
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 'Create'
25
+ click_button 'Sign Up'
26
26
 
27
- click_link 'My Account'
27
+ show_user_account
28
28
  expect(page).to have_text 'email@person.com'
29
- click_link 'Edit'
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 'Login'
46
+ click_button 'Log in'
46
47
 
47
- click_link 'My Account'
48
+ show_user_account
48
49
  expect(page).to have_text 'email@person.com'
49
- click_link 'Edit'
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 Password?'
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 Password?'
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
- fill_in 'Email', with: @user.email
14
- fill_in 'Password', with: 'secret'
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 'Logout'
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 'Login'
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
- click_link 'Logout'
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'
@@ -7,7 +7,7 @@ RSpec.feature 'Admin Permissions', type: :feature do
7
7
 
8
8
  fill_in 'Email', with: user.email
9
9
  fill_in 'Password', with: user.password
10
- click_button 'Login'
10
+ click_button 'Log in'
11
11
  end
12
12
 
13
13
  context 'admin is restricted from accessing orders' do
@@ -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
- visit spree.root_path
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
- @product = create(:product, name: 'RoR Mug')
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,71 +31,56 @@ 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 'RoR Mug'
35
- click_button 'Checkout'
34
+ add_to_cart(mug)
35
+ click_link 'checkout'
36
36
 
37
- expect(page).to have_content(/Checkout as a Guest/i)
37
+ expect(page).to have_selector(:button, 'Continue as a guest')
38
38
 
39
- within('#guest_checkout') { fill_in 'Email', with: 'spree@test.com' }
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
- str_addr = 'bill_address'
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 'Your order has been processed successfully'
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
- user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
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 'Login'
67
- expect(page).to have_text('Cart')
68
- click_link 'Cart'
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 'Shopping Cart' }
72
-
73
- click_button 'Checkout'
63
+ within('h1') { expect(page).to have_text 'YOUR SHOPPING BAG' }
74
64
 
75
- str_addr = 'bill_address'
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 'Your order has been processed successfully'
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
- create(:store)
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 Password?'
98
- fill_in 'spree_user_email', with: 'email@person.com'
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
@@ -109,49 +94,39 @@ RSpec.feature 'Checkout', :js, type: :feature do
109
94
  fill_in 'Password Confirmation', with: 'password'
110
95
  click_button 'Update'
111
96
 
112
- expect(page).to have_text('Cart')
113
- click_link 'Cart'
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
- click_button 'Checkout'
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 'RoR Mug'
132
- click_button 'Checkout'
109
+ add_to_cart(mug)
110
+ click_link 'checkout'
133
111
 
134
- expect(page).to have_text 'Registration'
112
+ expect(page).to have_selector(:link, 'Sign Up')
135
113
 
136
- fill_in 'Email', with: 'email@person.com', match: :first
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
- str_addr = 'bill_address'
143
- select 'United States', from: "order_#{str_addr}_attributes_country_id"
144
- %w(firstname lastname address1 city zipcode phone).each do |field|
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 'Your order has been processed successfully'
154
- expect(Spree::Order.first.user).to eq Spree::User.find_by_email('email@person.com')
128
+ expect(page).to have_text 'Order placed successfully'
129
+ expect(Spree::Order.first.user).to eq Spree::User.find_by_email('test@person.com')
155
130
  end
156
131
  end
157
132
  end
@@ -8,8 +8,6 @@ RSpec.feature 'Confirmation', type: :feature, reload_user: true do
8
8
 
9
9
  after(:each) { set_confirmable_option(false) }
10
10
 
11
- let!(:store) { create(:store) }
12
-
13
11
  background do
14
12
  ActionMailer::Base.default_url_options[:host] = 'http://example.com'
15
13
  end
@@ -20,7 +18,7 @@ RSpec.feature 'Confirmation', type: :feature, reload_user: true do
20
18
  fill_in 'Email', with: 'email@person.com'
21
19
  fill_in 'Password', with: 'password'
22
20
  fill_in 'Password Confirmation', with: 'password'
23
- click_button 'Create'
21
+ click_button 'Sign Up'
24
22
 
25
23
  expect(page).to have_text 'You have signed up successfully.'
26
24
  expect(Spree::User.last.confirmed?).to be(false)
@@ -6,46 +6,40 @@ RSpec.feature 'Orders', :js, type: :feature do
6
6
 
7
7
  # regression test for spree/spree#1687
8
8
  scenario 'merge incomplete orders from different sessions' do
9
- skip %{
10
- TODO: has been broken for ~2 months as of:
11
- https://github.com/spree/spree_auth_devise/commit/3157b47b22c559817d34ec34024587d8aa6136dc
12
- I dont think we can decode these sessions anymore since Rails 4 switched to encrypted cookies I believe devise stores session encrypted.
13
- }
14
- create(:product, name: 'RoR Mug')
15
- create(:product, name: 'RoR Shirt')
9
+ ror_mug = create(:product, name: 'RoR Mug')
10
+ ror_shirt = create(:product, name: 'RoR Shirt')
16
11
 
17
12
  user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
18
13
 
19
14
  using_session('first') do
20
- add_to_cart 'RoR Mug'
15
+ add_to_cart ror_mug
21
16
 
22
17
  visit spree.login_path
23
18
  fill_in 'Email', with: user.email
24
19
  fill_in 'Password', with: user.password
25
- click_button 'Login'
20
+ click_button 'Log in'
26
21
 
27
- click_link 'Cart'
22
+ visit spree.cart_path
28
23
  expect(page).to have_text 'RoR Mug'
29
24
  end
30
25
 
31
26
  using_session('second') do
32
- add_to_cart 'RoR Shirt'
27
+ add_to_cart ror_shirt
33
28
 
34
29
  visit spree.login_path
35
30
  fill_in 'Email', with: user.email
36
31
  fill_in 'Password', with: user.password
37
- click_button 'Login'
32
+ click_button 'Log in'
38
33
 
39
34
  # Order should have been merged with first session
40
- click_link 'Cart'
35
+ visit spree.cart_path
41
36
  expect(page).to have_text 'RoR Mug'
42
37
  expect(page).to have_text 'RoR Shirt'
43
38
  end
44
39
 
45
40
  using_session('first') do
46
41
  visit spree.root_path
47
-
48
- click_link 'Cart'
42
+ visit spree.cart_path
49
43
 
50
44
  # Order should have been merged with second session
51
45
  expect(page).to have_text 'RoR Mug'