solidus_auth_devise 2.5.9 → 2.6.0

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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/.git-blame-ignore-revs +2 -0
  3. data/.github/workflows/test.yml +22 -0
  4. data/.rubocop.yml +0 -8
  5. data/Gemfile +33 -19
  6. data/README.md +1 -1
  7. data/Rakefile +5 -5
  8. data/app/models/spree/user.rb +3 -12
  9. data/app/patches/controllers/solidus_auth_devise/application_controller_patch.rb +29 -0
  10. data/bin/rspec +16 -0
  11. data/config/initializers/devise.rb +7 -5
  12. data/config/routes.rb +31 -31
  13. data/db/default/users.rb +5 -5
  14. data/db/migrate/20101026184949_create_users.rb +19 -19
  15. data/db/migrate/20101026184950_rename_columns_for_devise.rb +1 -3
  16. data/db/migrate/20101214150824_convert_user_remember_field.rb +1 -1
  17. data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +1 -1
  18. data/db/migrate/20120605211305_make_users_email_index_unique.rb +1 -1
  19. data/db/migrate/20140904000425_add_deleted_at_to_users.rb +1 -1
  20. data/db/migrate/20141002154641_add_confirmable_to_users.rb +1 -1
  21. data/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +3 -3
  22. data/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb +1 -1
  23. data/db/seeds.rb +1 -1
  24. data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +3 -3
  25. data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +7 -7
  26. data/lib/controllers/frontend/spree/user_confirmations_controller.rb +1 -1
  27. data/lib/controllers/frontend/spree/user_passwords_controller.rb +2 -2
  28. data/lib/controllers/frontend/spree/user_registrations_controller.rb +2 -2
  29. data/lib/controllers/frontend/spree/user_sessions_controller.rb +6 -6
  30. data/lib/controllers/frontend/spree/users_controller.rb +5 -4
  31. data/lib/generators/solidus/auth/install/install_generator.rb +7 -7
  32. data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb.erb +4 -0
  33. data/lib/generators/solidus_auth_devise/install/install_generator.rb +2 -2
  34. data/lib/{decorators/backend/controllers/spree/admin/base_controller_decorator.rb → patches/backend/controllers/solidus_auth_devise/admin/base_controller_patch.rb} +2 -2
  35. data/lib/patches/backend/controllers/solidus_auth_devise/admin/orders/customer_details_controller_patch.rb +28 -0
  36. data/lib/{decorators/frontend/controllers/spree/checkout_controller_decorator.rb → patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb} +7 -7
  37. data/lib/solidus_auth_devise/configuration.rb +1 -1
  38. data/lib/solidus_auth_devise/engine.rb +1 -1
  39. data/lib/solidus_auth_devise/version.rb +1 -1
  40. data/lib/solidus_auth_devise.rb +9 -11
  41. data/lib/spree/auth/engine.rb +10 -15
  42. data/lib/spree/auth/version.rb +1 -1
  43. data/lib/tasks/auth.rake +1 -1
  44. data/solidus_auth_devise.gemspec +20 -21
  45. metadata +19 -96
  46. data/.circleci/config.yml +0 -73
  47. data/.rubocop_todo.yml +0 -397
  48. data/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb +0 -22
  49. data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +0 -3
  50. data/lib/spree/authentication_helpers.rb +0 -27
  51. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -53
  52. data/spec/controllers/spree/admin/user_passwords_controller_spec.rb +0 -14
  53. data/spec/controllers/spree/admin/user_sessions_controller_spec.rb +0 -20
  54. data/spec/controllers/spree/base_controller_spec.rb +0 -53
  55. data/spec/controllers/spree/checkout_controller_spec.rb +0 -192
  56. data/spec/controllers/spree/products_controller_spec.rb +0 -24
  57. data/spec/controllers/spree/user_passwords_controller_spec.rb +0 -45
  58. data/spec/controllers/spree/user_registrations_controller_spec.rb +0 -97
  59. data/spec/controllers/spree/user_sessions_controller_spec.rb +0 -125
  60. data/spec/controllers/spree/users_controller_spec.rb +0 -79
  61. data/spec/factories/confirmed_user.rb +0 -9
  62. data/spec/features/account_spec.rb +0 -59
  63. data/spec/features/admin/password_reset_spec.rb +0 -80
  64. data/spec/features/admin/products_spec.rb +0 -10
  65. data/spec/features/admin/sign_in_spec.rb +0 -45
  66. data/spec/features/admin/sign_out_spec.rb +0 -42
  67. data/spec/features/admin_permissions_spec.rb +0 -47
  68. data/spec/features/change_email_spec.rb +0 -27
  69. data/spec/features/checkout_spec.rb +0 -158
  70. data/spec/features/confirmation_spec.rb +0 -28
  71. data/spec/features/order_spec.rb +0 -59
  72. data/spec/features/password_reset_spec.rb +0 -37
  73. data/spec/features/sign_in_spec.rb +0 -53
  74. data/spec/features/sign_out_spec.rb +0 -26
  75. data/spec/features/sign_up_spec.rb +0 -31
  76. data/spec/mailers/user_mailer_spec.rb +0 -47
  77. data/spec/models/order_spec.rb +0 -27
  78. data/spec/models/user_spec.rb +0 -103
  79. data/spec/requests/spree/frontend/user_update_spec.rb +0 -42
  80. data/spec/spec_helper.rb +0 -33
  81. data/spec/support/ability.rb +0 -17
  82. data/spec/support/authentication_helpers.rb +0 -16
  83. data/spec/support/confirm_helpers.rb +0 -27
  84. data/spec/support/email.rb +0 -7
  85. data/spec/support/features/fill_addresses_fields.rb +0 -29
  86. data/spec/support/preferences.rb +0 -13
  87. data/spec/support/spree.rb +0 -11
@@ -1,192 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::CheckoutController, type: :controller do
4
- let(:order) { create(:order_with_line_items, email: nil, user: nil, guest_token: token) }
5
- let(:user) { build(:user, spree_api_key: 'fake') }
6
- let(:token) { 'some_token' }
7
- let(:cookie_token) { token }
8
-
9
- before do
10
- request.cookie_jar.signed[:guest_token] = cookie_token
11
- allow(controller).to receive(:current_order) { order }
12
- allow(order).to receive(:confirmation_required?) { true }
13
- end
14
-
15
- context '#edit' do
16
- context 'when registration step enabled' do
17
- context 'when authenticated as registered user' do
18
- before { allow(controller).to receive(:spree_current_user) { user } }
19
-
20
- it 'proceeds to the first checkout step' do
21
- get :edit, params: { state: 'address' }
22
- expect(response).to render_template :edit
23
- end
24
- end
25
-
26
- context 'when not authenticated as guest' do
27
- it 'redirects to registration step' do
28
- get :edit, params: { state: 'address' }
29
- expect(response).to redirect_to spree.checkout_registration_path
30
- end
31
- end
32
-
33
- context 'when authenticated as guest' do
34
- before { order.email = 'guest@solidus.io' }
35
-
36
- it 'proceeds to the first checkout step' do
37
- get :edit, params: { state: 'address' }
38
- expect(response).to render_template :edit
39
- end
40
-
41
- context 'when guest checkout not allowed' do
42
- before do
43
- stub_spree_preferences(allow_guest_checkout: false)
44
- end
45
-
46
- it 'redirects to registration step' do
47
- get :edit, params: { state: 'address' }
48
- expect(response).to redirect_to spree.checkout_registration_path
49
- end
50
- end
51
- end
52
- end
53
-
54
- context 'when registration step disabled' do
55
- before do
56
- stub_spree_preferences(Spree::Auth::Config, registration_step: false)
57
- end
58
-
59
- context 'when authenticated as registered' do
60
- before { allow(controller).to receive(:spree_current_user) { user } }
61
-
62
- it 'proceeds to the first checkout step' do
63
- get :edit, params: { state: 'address' }
64
- expect(response).to render_template :edit
65
- end
66
- end
67
-
68
- context 'when authenticated as guest' do
69
- it 'proceeds to the first checkout step' do
70
- get :edit, params: { state: 'address' }
71
- expect(response).to render_template :edit
72
- end
73
- end
74
- end
75
- end
76
-
77
- context '#update' do
78
- context 'when in the confirm state' do
79
- before do
80
- order.update(email: 'spree@example.com', state: 'confirm')
81
-
82
- # So that the order can transition to complete successfully
83
- allow(order).to receive(:payment_required?) { false }
84
- end
85
-
86
- context 'with a token' do
87
- before { allow(order).to receive(:guest_token) { 'ABC' } }
88
-
89
- it 'redirects to the tokenized order view' do
90
- request.cookie_jar.signed[:guest_token] = 'ABC'
91
- post :update, params: { state: 'confirm' }
92
- expect(response).to redirect_to spree.token_order_path(order, 'ABC')
93
- expect(flash.notice).to eq I18n.t('spree.order_processed_successfully')
94
- end
95
- end
96
-
97
- context 'with a registered user' do
98
- before do
99
- allow(controller).to receive(:spree_current_user) { user }
100
- allow(order).to receive(:user) { user }
101
- allow(order).to receive(:guest_token) { nil }
102
- end
103
-
104
- it 'redirects to the standard order view' do
105
- post :update, params: { state: 'confirm' }
106
- expect(response).to redirect_to spree.order_path(order)
107
- end
108
- end
109
- end
110
- end
111
-
112
- context '#registration' do
113
- it 'does not check registration' do
114
- expect(controller).not_to receive(:check_registration)
115
- get :registration
116
- end
117
-
118
- it 'checks if the user is authorized for :edit' do
119
- expect(controller).to receive(:authorize!).with(:edit, order, token)
120
- request.cookie_jar.signed[:guest_token] = token
121
- get :registration, params: {}
122
- end
123
- end
124
-
125
- context '#update_registration' do
126
- subject { put :update_registration, params: { order: { email: email } } }
127
- let(:email) { 'foo@example.com' }
128
-
129
- it 'does not check registration' do
130
- expect(controller).not_to receive(:check_registration)
131
- subject
132
- end
133
-
134
- it 'redirects to the checkout_path after saving' do
135
- subject
136
- expect(response).to redirect_to spree.checkout_path
137
- end
138
-
139
- # Regression test for https://github.com/solidusio/solidus/issues/1588
140
- context 'order in address state' do
141
- let(:order) do
142
- create(
143
- :order_with_line_items,
144
- email: nil,
145
- user: nil,
146
- guest_token: token,
147
- bill_address: nil,
148
- ship_address: nil,
149
- state: 'address'
150
- )
151
- end
152
-
153
- # This may seem out of left field, but previously there was an issue
154
- # where address would be built in a before filter and then would be saved
155
- # when trying to update the email.
156
- it "doesn't create addresses" do
157
- expect {
158
- subject
159
- }.not_to change { Spree::Address.count }
160
- expect(response).to redirect_to spree.checkout_path
161
- end
162
- end
163
-
164
- context 'invalid email' do
165
- let(:email) { 'invalid' }
166
-
167
- it 'renders the registration view' do
168
- subject
169
- expect(flash[:registration_error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages])
170
- expect(response).to render_template :registration
171
- end
172
- end
173
-
174
- context 'with wrong order token' do
175
- let(:cookie_token) { 'lol_no_access' }
176
-
177
- it 'redirects to login' do
178
- put :update_registration, params: { order: { email: 'foo@example.com' } }
179
- expect(response).to redirect_to(login_path)
180
- end
181
- end
182
-
183
- context 'without order token' do
184
- let(:cookie_token) { nil }
185
-
186
- it 'redirects to login' do
187
- put :update_registration, params: { order: { email: 'foo@example.com' } }
188
- expect(response).to redirect_to(login_path)
189
- end
190
- end
191
- end
192
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::ProductsController, type: :controller do
4
- let!(:product) { create(:product, available_on: 1.year.from_now) }
5
- let!(:user) { build(:user, spree_api_key: 'fake') }
6
-
7
- it 'allows admins to view non-active products' do
8
- allow(controller).to receive(:before_save_new_order)
9
- allow(controller).to receive(:spree_current_user) { user }
10
- allow(user).to receive(:has_spree_role?) { true }
11
- get :show, params: { id: product.to_param }
12
- expect(response.status).to eq(200)
13
- end
14
-
15
- it 'cannot view non-active products' do
16
- allow(controller).to receive(:before_save_new_order)
17
- allow(controller).to receive(:spree_current_user) { user }
18
- allow(user).to receive(:has_spree_role?) { false }
19
-
20
- expect {
21
- get :show, params: { id: product.to_param }
22
- }.to raise_error(ActiveRecord::RecordNotFound)
23
- end
24
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::UserPasswordsController, type: :controller do
4
- let(:token) { 'some_token' }
5
-
6
- before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
7
-
8
- describe 'GET edit' do
9
- context 'when the user token has not been specified' do
10
- it 'redirects to the new session path' do
11
- get :edit
12
- expect(response).to redirect_to(
13
- 'http://test.host/user/spree_user/sign_in'
14
- )
15
- end
16
-
17
- it 'flashes an error' do
18
- get :edit
19
- expect(flash[:alert]).to include(
20
- "You can't access this page without coming from a password reset " \
21
- 'email'
22
- )
23
- end
24
- end
25
-
26
- context 'when the user token has been specified' do
27
- it 'does something' do
28
- get :edit, params: { reset_password_token: token }
29
- expect(response.code).to eq('200')
30
- end
31
- end
32
- end
33
-
34
- context '#update' do
35
- context 'when updating password with blank password' do
36
- it 'shows error flash message, sets spree_user with token and re-displays password edit form' do
37
- put :update, params: { spree_user: { password: '', password_confirmation: '', reset_password_token: token } }
38
- expect(assigns(:spree_user).is_a?(Spree::User)).to eq true
39
- expect(assigns(:spree_user).reset_password_token).to eq token
40
- expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user])
41
- expect(response).to render_template :edit
42
- end
43
- end
44
- end
45
- end
@@ -1,97 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::UserRegistrationsController, type: :controller do
4
- before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] }
5
-
6
- context '#create' do
7
- before do
8
- allow(controller).to receive(:after_sign_up_path_for) do
9
- spree.root_path(thing: 7)
10
- end
11
- end
12
-
13
- let(:password_confirmation) { 'foobar123' }
14
-
15
- subject do
16
- post(:create,
17
- params: {
18
- spree_user: {
19
- email: 'foobar@example.com',
20
- password: 'foobar123',
21
- password_confirmation: password_confirmation
22
- }
23
- }
24
- )
25
- end
26
-
27
- context 'when user created successfuly' do
28
- it 'saves the user' do
29
- expect { subject }.to change { Spree::User.count }.from(0).to(1)
30
- end
31
-
32
- it 'sets flash message' do
33
- subject
34
- expect(flash[:notice]).to eq('Welcome! You have signed up successfully.')
35
- end
36
-
37
- it 'signs in user' do
38
- expect(controller.warden).to receive(:set_user)
39
- subject
40
- end
41
-
42
- it 'sets spree_user_signup session' do
43
- subject
44
- expect(session[:spree_user_signup]).to be true
45
- end
46
-
47
- it 'redirects to after_sign_up path' do
48
- subject
49
- expect(response).to redirect_to spree.root_path(thing: 7)
50
- end
51
-
52
- context 'with a guest token present' do
53
- before do
54
- request.cookie_jar.signed[:guest_token] = 'ABC'
55
- end
56
-
57
- it 'assigns orders with the correct token and no user present' do
58
- order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
59
- subject
60
- user = Spree::User.find_by(email: 'foobar@example.com')
61
-
62
- order.reload
63
- expect(order.user_id).to eq user.id
64
- expect(order.created_by_id).to eq user.id
65
- end
66
-
67
- it 'does not assign orders with an existing user' do
68
- order = create(:order, guest_token: 'ABC', user_id: 200)
69
- subject
70
-
71
- expect(order.reload.user_id).to eq 200
72
- end
73
-
74
- it 'does not assign orders with a different token' do
75
- order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
76
- subject
77
-
78
- expect(order.reload.user_id).to be_nil
79
- end
80
- end
81
- end
82
-
83
- context 'when user not valid' do
84
- let(:password_confirmation) { 'foobard123' }
85
-
86
- it 'resets password fields' do
87
- expect(controller).to receive(:clean_up_passwords)
88
- subject
89
- end
90
-
91
- it 'renders new view' do
92
- subject
93
- expect(:response).to render_template(:new)
94
- end
95
- end
96
- end
97
- end
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::UserSessionsController, type: :controller do
4
- let(:user) { create(:user) }
5
-
6
- before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable
7
-
8
- context "#create" do
9
- let(:format) { :html }
10
- let(:password) { 'secret' }
11
-
12
- subject do
13
- post(:create, params: {
14
- spree_user: {
15
- email: user.email,
16
- password: password
17
- },
18
- format: format
19
- })
20
- end
21
-
22
- context "when using correct login information" do
23
- context 'with a guest token present' do
24
- before do
25
- request.cookie_jar.signed[:guest_token] = 'ABC'
26
- end
27
-
28
- it 'assigns orders with the correct token and no user present' do
29
- order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil)
30
- subject
31
-
32
- order.reload
33
- expect(order.user_id).to eq user.id
34
- expect(order.created_by_id).to eq user.id
35
- end
36
-
37
- it 'assigns orders with the correct token and no user or email present' do
38
- order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil)
39
- subject
40
-
41
- order.reload
42
- expect(order.user_id).to eq user.id
43
- expect(order.created_by_id).to eq user.id
44
- end
45
-
46
- it 'does not assign completed orders' do
47
- order = create(:order, email: user.email, guest_token: 'ABC',
48
- user_id: nil, created_by_id: nil,
49
- completed_at: 1.minute.ago)
50
- subject
51
-
52
- order.reload
53
- expect(order.user_id).to be_nil
54
- expect(order.created_by_id).to be_nil
55
- end
56
-
57
- it 'does not assign orders with an existing user' do
58
- order = create(:order, guest_token: 'ABC', user_id: 200)
59
- subject
60
-
61
- expect(order.reload.user_id).to eq 200
62
- end
63
-
64
- it 'does not assign orders with a different token' do
65
- order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil)
66
- subject
67
-
68
- expect(order.reload.user_id).to be_nil
69
- end
70
- end
71
-
72
- context "when html format is requested" do
73
- it "redirects to default after signing in" do
74
- subject
75
- expect(response).to redirect_to spree.root_path
76
- end
77
- end
78
-
79
- context "when js format is requested" do
80
- let(:format) { :js }
81
-
82
- it "returns a json with ship and bill address" do
83
- subject
84
- parsed = ActiveSupport::JSON.decode(response.body)
85
- expect(parsed).to have_key("user")
86
- expect(parsed).to have_key("ship_address")
87
- expect(parsed).to have_key("bill_address")
88
- end
89
- end
90
- end
91
-
92
- context "when using incorrect login information" do
93
- let(:password) { 'wrong' }
94
-
95
- context "when html format is requested" do
96
- it "renders new template again with errors" do
97
- subject
98
- expect(response).to render_template(:new)
99
- expect(flash[:error]).to eq I18n.t(:'devise.failure.invalid')
100
- end
101
- end
102
-
103
- context "when js format is requested" do
104
- let(:format) { :js }
105
- it "returns json with the error" do
106
- subject
107
- parsed = ActiveSupport::JSON.decode(response.body)
108
- expect(parsed).to have_key("error")
109
- end
110
- end
111
- end
112
- end
113
-
114
- context "#destroy" do
115
- subject do
116
- delete(:destroy)
117
- end
118
-
119
- it "redirects to default after signing out" do
120
- subject
121
- expect(controller.spree_current_user).to be_nil
122
- expect(response).to redirect_to spree.root_path
123
- end
124
- end
125
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::UsersController, type: :controller do
4
- let(:admin_user) { create(:user) }
5
- let(:user) { create(:user) }
6
- let(:role) { create(:role) }
7
-
8
- context '#load_object' do
9
- it 'redirects to signup path if user is not found' do
10
- put :update, params: { user: { email: 'foobar@example.com' } }
11
- expect(response).to redirect_to spree.login_path
12
- end
13
- end
14
-
15
- context '#create' do
16
- it 'creates a new user' do
17
- post :create, params: { user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } }
18
- expect(assigns[:user].new_record?).to be false
19
- end
20
- end
21
-
22
- context '#update' do
23
- before { sign_in(user) }
24
-
25
- context 'when updating own account' do
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
48
- end
49
-
50
- context 'when updating password' do
51
- before do
52
- stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: signout_after_change)
53
- put :update, params: { user: { password: 'foobar123', password_confirmation: 'foobar123' } }
54
- end
55
-
56
- context 'when signout after password change is enabled' do
57
- let(:signout_after_change) { true }
58
-
59
- it 'redirects to login url' do
60
- expect(response).to redirect_to spree.login_url(only_path: true)
61
- end
62
- end
63
-
64
- context 'when signout after password change is disabled' do
65
- let(:signout_after_change) { false }
66
-
67
- it 'redirects to account url' do
68
- expect(response).to redirect_to spree.account_url(only_path: true)
69
- end
70
- end
71
- end
72
- end
73
-
74
- it 'does not update roles' do
75
- put :update, params: { user: { spree_role_ids: [role.id] } }
76
- expect(assigns[:user].spree_roles).to_not include role
77
- end
78
- end
79
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- FactoryBot.define do
4
- factory :confirmed_user, parent: :user do
5
- confirmed_at { Time.zone.now }
6
- confirmation_sent_at { Time.zone.now }
7
- confirmation_token { "12345" }
8
- end
9
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.feature 'Accounts', type: :feature do
4
- context 'editing' do
5
- scenario 'can edit an admin user' do
6
- user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password')
7
- visit spree.login_path
8
-
9
- fill_in 'Email', with: user.email
10
- fill_in 'Password', with: user.password
11
- click_button 'Login'
12
-
13
- click_link 'My Account'
14
- expect(page).to have_text 'admin@person.com'
15
- end
16
-
17
- scenario 'can edit a new user' do
18
- stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false)
19
- visit spree.signup_path
20
-
21
- fill_in 'Email', with: 'email@person.com'
22
- fill_in 'Password', with: 'password'
23
- fill_in 'Password Confirmation', with: 'password'
24
- click_button 'Create'
25
-
26
- click_link 'My Account'
27
- expect(page).to have_text 'email@person.com'
28
- click_link 'Edit'
29
-
30
- fill_in 'Password', with: 'foobar'
31
- fill_in 'Password Confirmation', with: 'foobar'
32
- click_button 'Update'
33
-
34
- expect(page).to have_text 'email@person.com'
35
- expect(page).to have_text 'Account updated'
36
- end
37
-
38
- scenario 'can edit an existing user account' do
39
- stub_spree_preferences(Spree::Auth::Config ,signout_after_password_change: false)
40
- user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret')
41
- visit spree.login_path
42
-
43
- fill_in 'Email', with: user.email
44
- fill_in 'Password', with: user.password
45
- click_button 'Login'
46
-
47
- click_link 'My Account'
48
- expect(page).to have_text 'email@person.com'
49
- click_link 'Edit'
50
-
51
- fill_in 'Password', with: 'foobar'
52
- fill_in 'Password Confirmation', with: 'foobar'
53
- click_button 'Update'
54
-
55
- expect(page).to have_text 'email@person.com'
56
- expect(page).to have_text 'Account updated'
57
- end
58
- end
59
- end