solidus_auth_devise 2.2.0 → 2.5.2

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 (116) hide show
  1. checksums.yaml +4 -4
  2. data/.gem_release.yml +3 -8
  3. data/.github/stale.yml +17 -0
  4. data/.gitignore +12 -8
  5. data/.rubocop.yml +2 -0
  6. data/CHANGELOG.md +350 -163
  7. data/Gemfile +20 -22
  8. data/{LICENSE.md → LICENSE} +2 -2
  9. data/README.md +4 -28
  10. data/Rakefile +2 -0
  11. data/app/mailers/spree/user_mailer.rb +4 -2
  12. data/app/models/spree/user.rb +21 -19
  13. data/app/overrides/spree/admin/users/edit/_add_reset_password_form.html.erb.deface +20 -0
  14. data/bin/console +17 -0
  15. data/bin/rails +12 -4
  16. data/bin/setup +8 -0
  17. data/config/initializers/devise.rb +11 -3
  18. data/config/initializers/warden.rb +4 -2
  19. data/config/locales/en.yml +3 -1
  20. data/config/locales/it.yml +4 -4
  21. data/config/routes.rb +5 -11
  22. data/db/default/users.rb +10 -8
  23. data/db/migrate/20101026184949_create_users.rb +9 -7
  24. data/db/migrate/20101026184950_rename_columns_for_devise.rb +3 -0
  25. data/db/migrate/20101214150824_convert_user_remember_field.rb +2 -0
  26. data/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +2 -0
  27. data/db/migrate/20120605211305_make_users_email_index_unique.rb +4 -2
  28. data/db/migrate/20140904000425_add_deleted_at_to_users.rb +2 -0
  29. data/db/migrate/20141002154641_add_confirmable_to_users.rb +2 -0
  30. data/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +4 -2
  31. data/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb +7 -0
  32. data/db/seeds.rb +2 -0
  33. data/lib/controllers/backend/spree/admin/user_passwords_controller.rb +5 -3
  34. data/lib/controllers/backend/spree/admin/user_sessions_controller.rb +11 -8
  35. data/lib/controllers/frontend/spree/user_confirmations_controller.rb +2 -0
  36. data/lib/controllers/frontend/spree/user_passwords_controller.rb +4 -1
  37. data/lib/controllers/frontend/spree/user_registrations_controller.rb +4 -0
  38. data/lib/controllers/frontend/spree/user_sessions_controller.rb +2 -0
  39. data/lib/controllers/frontend/spree/users_controller.rb +17 -14
  40. data/lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb +20 -0
  41. data/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb +22 -0
  42. data/lib/{controllers/frontend → decorators/frontend/controllers}/spree/checkout_controller_decorator.rb +29 -19
  43. data/lib/generators/solidus/auth/install/install_generator.rb +16 -4
  44. data/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +2 -0
  45. data/lib/solidus/auth.rb +2 -0
  46. data/lib/solidus_auth_devise.rb +12 -12
  47. data/lib/spree/auth/devise.rb +2 -7
  48. data/lib/spree/auth/engine.rb +51 -36
  49. data/lib/spree/auth/version.rb +1 -1
  50. data/{app/models → lib}/spree/auth_configuration.rb +2 -0
  51. data/lib/spree/authentication_helpers.rb +5 -11
  52. data/lib/tasks/auth.rake +3 -1
  53. data/lib/views/backend/spree/admin/shared/_navigation_footer.html.erb +3 -3
  54. data/lib/views/backend/spree/admin/user_passwords/edit.html.erb +4 -4
  55. data/lib/views/backend/spree/admin/user_passwords/new.html.erb +5 -7
  56. data/lib/views/backend/spree/admin/user_sessions/authorization_failure.html.erb +1 -1
  57. data/lib/views/backend/spree/admin/user_sessions/new.html.erb +9 -9
  58. data/lib/views/backend/spree/layouts/admin/_login_nav.html.erb +4 -4
  59. data/lib/views/frontend/spree/checkout/registration.html.erb +4 -4
  60. data/lib/views/frontend/spree/shared/_login.html.erb +4 -4
  61. data/lib/views/frontend/spree/shared/_login_bar_items.html.erb +3 -3
  62. data/lib/views/frontend/spree/shared/_user_form.html.erb +3 -3
  63. data/lib/views/frontend/spree/user_passwords/edit.html.erb +4 -4
  64. data/lib/views/frontend/spree/user_passwords/new.html.erb +5 -7
  65. data/lib/views/frontend/spree/user_registrations/new.html.erb +3 -3
  66. data/lib/views/frontend/spree/user_sessions/authorization_failure.html.erb +1 -1
  67. data/lib/views/frontend/spree/user_sessions/new.html.erb +2 -2
  68. data/lib/views/frontend/spree/users/edit.html.erb +2 -2
  69. data/lib/views/frontend/spree/users/show.html.erb +13 -13
  70. data/solidus_auth_devise.gemspec +40 -35
  71. data/spec/controllers/spree/admin/base_controller_spec.rb +53 -0
  72. data/spec/controllers/spree/admin/user_passwords_controller_spec.rb +2 -0
  73. data/spec/controllers/spree/base_controller_spec.rb +53 -0
  74. data/spec/controllers/spree/checkout_controller_spec.rb +5 -9
  75. data/spec/controllers/spree/products_controller_spec.rb +5 -8
  76. data/spec/controllers/spree/user_passwords_controller_spec.rb +4 -3
  77. data/spec/controllers/spree/user_registrations_controller_spec.rb +3 -2
  78. data/spec/controllers/spree/user_sessions_controller_spec.rb +14 -0
  79. data/spec/controllers/spree/users_controller_spec.rb +2 -2
  80. data/spec/factories/confirmed_user.rb +5 -3
  81. data/spec/features/account_spec.rb +4 -3
  82. data/spec/features/admin/password_reset_spec.rb +66 -10
  83. data/spec/features/admin/products_spec.rb +2 -1
  84. data/spec/features/admin/sign_in_spec.rb +2 -1
  85. data/spec/features/admin/sign_out_spec.rb +2 -1
  86. data/spec/features/admin_permissions_spec.rb +2 -1
  87. data/spec/features/change_email_spec.rb +3 -2
  88. data/spec/features/checkout_spec.rb +14 -37
  89. data/spec/features/confirmation_spec.rb +4 -3
  90. data/spec/features/order_spec.rb +2 -1
  91. data/spec/features/password_reset_spec.rb +23 -10
  92. data/spec/features/sign_in_spec.rb +2 -1
  93. data/spec/features/sign_out_spec.rb +4 -3
  94. data/spec/features/sign_up_spec.rb +2 -1
  95. data/spec/mailers/user_mailer_spec.rb +2 -1
  96. data/spec/models/order_spec.rb +2 -1
  97. data/spec/models/user_spec.rb +15 -9
  98. data/spec/spec_helper.rb +13 -9
  99. data/spec/support/ability.rb +3 -1
  100. data/spec/support/authentication_helpers.rb +2 -0
  101. data/spec/support/confirm_helpers.rb +21 -10
  102. data/spec/support/email.rb +2 -0
  103. data/spec/support/features/fill_addresses_fields.rb +29 -0
  104. data/spec/support/preferences.rb +10 -2
  105. data/spec/support/spree.rb +2 -0
  106. metadata +305 -212
  107. data/.travis.yml +0 -18
  108. data/app/overrides/auth_admin_login_navigation_bar.rb +0 -10
  109. data/app/overrides/auth_shared_login_bar.rb +0 -10
  110. data/lib/assets/javascripts/spree/backend/solidus_auth.js +0 -1
  111. data/lib/assets/javascripts/spree/frontend/solidus_auth.js +0 -1
  112. data/lib/assets/stylesheets/spree/backend/solidus_auth.css +0 -3
  113. data/lib/assets/stylesheets/spree/frontend/solidus_auth.css +0 -3
  114. data/lib/controllers/backend/spree/admin/admin_controller_decorator.rb +0 -11
  115. data/lib/controllers/backend/spree/admin/orders/customer_details_controller_decorator.rb +0 -15
  116. data/spec/features/admin/orders_spec.rb +0 -30
@@ -1,5 +1,6 @@
1
- RSpec.describe Spree::UsersController, type: :controller do
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) }
@@ -22,7 +23,6 @@ RSpec.describe Spree::UsersController, type: :controller do
22
23
  before { sign_in(user) }
23
24
 
24
25
  context 'when updating own account' do
25
-
26
26
  context 'when user updated successfuly' do
27
27
  before { put :update, params: { user: { email: 'mynew@email-address.com' } } }
28
28
 
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  FactoryBot.define do
2
4
  factory :confirmed_user, parent: :user do
3
- confirmed_at { Time.now }
4
- confirmation_sent_at { Time.now }
5
+ confirmed_at { Time.zone.now }
6
+ confirmation_sent_at { Time.zone.now }
5
7
  confirmation_token { "12345" }
6
8
  end
7
- end
9
+ end
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Accounts', type: :feature do
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.set(signout_after_password_change: false)
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.set(signout_after_password_change: false)
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
- RSpec.feature 'Admin - Reset Password', type: :feature do
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
- scenario 'allows a user to supply an email for the password reset' do
10
- user = create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret')
11
- visit spree.admin_login_path
12
- click_link 'Forgot Password?'
13
- fill_in 'Email', with: 'foobar@example.com'
14
- click_button 'Reset my password'
15
- expect(page).to have_text 'You will receive an email with instructions'
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
- scenario 'shows errors if no email is supplied' do
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).to have_text "Email can't be blank"
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
- RSpec.feature 'Admin products', type: :feature do
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
- RSpec.feature 'Admin - Sign In', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Admin - Sign In', type: :feature do
3
4
  background do
4
5
  @user = create(:user, email: 'email@person.com')
5
6
  visit spree.admin_login_path
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Admin - Sign Out', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Admin - Sign Out', type: :feature, js: true do
3
4
  given!(:user) do
4
5
  create :user, email: 'email@person.com'
5
6
  end
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Admin Permissions', type: :feature do
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
- RSpec.feature 'Change email', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Change email', type: :feature do
3
4
  background do
4
- Spree::Auth::Config.set(signout_after_password_change: false)
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.update_column(:count_on_hand, 1)
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
- Spree::Config[:allow_checkout_on_gateway_error] = true
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.set(registration_step: true)
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
- str_addr = 'bill_address'
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
- str_addr = 'bill_address'
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
- user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password')
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
- str_addr = 'bill_address'
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
- str_addr = 'bill_address'
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.find_by_email('email@person.com')
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
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- feature 'Confirmation' do
5
+ RSpec.feature 'Confirmation' do
4
6
  before do
5
- set_confirmable_option(false)
6
7
  allow(Spree::UserMailer).to receive(:confirmation_instructions)
7
8
  .and_return(double(deliver: true))
8
9
  end
@@ -13,7 +14,7 @@ feature 'Confirmation' do
13
14
  ActionMailer::Base.default_url_options[:host] = 'http://example.com'
14
15
  end
15
16
 
16
- scenario 'create a new user', :js do
17
+ scenario 'create a new user', js: true, confirmable: false do
17
18
  visit spree.signup_path
18
19
 
19
20
  fill_in 'Email', with: 'email@person.com'
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Orders', :js, type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Orders', :js, type: :feature do
3
4
  scenario 'allow a user to view their cart at any time' do
4
5
  visit spree.cart_path
5
6
  expect(page).to have_text 'Your cart is empty'
@@ -1,24 +1,37 @@
1
- RSpec.feature 'Reset Password', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature '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
- scenario 'allow a user to supply an email for the password reset' do
10
- user = create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret')
11
- visit spree.login_path
12
- click_link 'Forgot Password?'
13
- fill_in 'Email', with: 'foobar@example.com'
14
- click_button 'Reset my password'
15
- expect(page).to have_text 'You will receive an email with instructions'
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.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
- scenario 'shows errors if no email is supplied' do
22
+ # Test that we are extending the functionality from
23
+ # https://github.com/solidusio/solidus_auth_devise/pull/155
24
+ # to the non-admin login
25
+ scenario 'does not reveal email addresses if they are not found' do
19
26
  visit spree.login_path
20
27
  click_link 'Forgot Password?'
28
+ fill_in_email
21
29
  click_button 'Reset my password'
22
- expect(page).to have_text "Email can't be blank"
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'
23
36
  end
24
37
  end
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Sign In', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Sign In', type: :feature do
3
4
  background do
4
5
  @user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret')
5
6
  visit spree.login_path
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Sign Out', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Sign Out', type: :feature, js: true do
3
4
  given!(:user) do
4
5
  create(:user,
5
6
  email: 'email@person.com',
@@ -19,7 +20,7 @@ RSpec.feature 'Sign Out', type: :feature do
19
20
  scenario 'allow a signed in user to logout' do
20
21
  click_link 'Logout'
21
22
  visit spree.root_path
22
- expect(page).to have_text 'Login'
23
- expect(page).not_to have_text 'Logout'
23
+ expect(page).to have_text 'LOGIN'
24
+ expect(page).not_to have_text 'LOGOUT'
24
25
  end
25
26
  end
@@ -1,5 +1,6 @@
1
- RSpec.feature 'Sign Up', type: :feature do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.feature 'Sign Up', type: :feature do
3
4
  context 'with valid data' do
4
5
  scenario 'create a new user' do
5
6
  visit spree.signup_path
@@ -1,5 +1,6 @@
1
- RSpec.describe Spree::UserMailer, type: :mailer do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.describe Spree::UserMailer, type: :mailer do
3
4
  let!(:store) { create(:store) }
4
5
  let(:user) { create(:user) }
5
6
 
@@ -1,5 +1,6 @@
1
- RSpec.describe Spree::Order, type: :model do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.describe Spree::Order, type: :model do
3
4
  let(:order) { described_class.new }
4
5
 
5
6
  context '#associate_user!' do
@@ -1,5 +1,6 @@
1
- RSpec.describe Spree::User, type: :model do
1
+ # frozen_string_literal: true
2
2
 
3
+ RSpec.describe Spree::User, type: :model do
3
4
  before(:all) { Spree::Role.create name: 'admin' }
4
5
 
5
6
  it '#admin?' do
@@ -77,17 +78,22 @@ RSpec.describe Spree::User, type: :model do
77
78
  end
78
79
  end
79
80
 
81
+ describe '#really_destroy!' do
82
+ let(:user) { create(:user) }
83
+
84
+ it 'removes the record from the database' do
85
+ user.really_destroy!
86
+ expect(Spree::User.with_deleted.exists?(id: user.id)).to eql false
87
+ end
88
+ end
89
+
80
90
  describe "confirmable" do
81
- it "is confirmable if the confirmable option is enabled" do
82
- set_confirmable_option(true)
83
- allow(Spree::UserMailer).to receive(:confirmation_instructions).and_return(double(deliver: true))
84
- expect(Spree::User.devise_modules).to include(:confirmable)
85
- set_confirmable_option(false)
91
+ it "loads Devise's :confirmable module when :confirmable is true", confirmable: true do
92
+ expect(Spree::User.ancestors).to include(Devise::Models::Confirmable)
86
93
  end
87
94
 
88
- it "is not confirmable if the confirmable option is disabled" do
89
- set_confirmable_option(false)
90
- expect(Spree::User.devise_modules).to_not include(:confirmable)
95
+ it "does not load Devise's :confirmable module when :confirmable is false", confirmable: false do
96
+ expect(Spree::User.ancestors).not_to include(Devise::Models::Confirmable)
91
97
  end
92
98
  end
93
99
  end