spree_auth_devise 4.3.3 → 4.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88bd67ceeb209cf0a5429d736103ffad339942eefd7cf7f75d6b84dfbb25a553
4
- data.tar.gz: 261b34f941e7f6584dfa9fb4a50dc76c8b4aae6f9785db618ef630da1f881312
3
+ metadata.gz: 3e12256ddf3e493e918afe0f529f5abf35fe8db54ac04623081c96f82c4b8bb1
4
+ data.tar.gz: 898d1757061761ff25aeb56dbc09a8c111d21881051526fd0e842c30a6d264e4
5
5
  SHA512:
6
- metadata.gz: 489cf73cb272c2318cc35761e736a9b65fb0549e8ba938550fdf63ed16727a562180e22bfd6f210a6e6384fd8e4bb589e9a4bebf37d0e287e0c712c83e1e7214
7
- data.tar.gz: 9e16a12db4e028e6318896d5fded01acda724348587a5f6628e437c81be41ccb4f4c6e537aac344c0ed05d223c27cfc03bcf275513ea7d84fa15eafd1f6b271a
6
+ metadata.gz: b54d41d158228c72e3167d8354f1ba352030533885776a3a7c2a30dc675ac2055627bf48c5da724e5104e0004b4f8cfca1504ded6ceaed0e4c632edc9c95cce4
7
+ data.tar.gz: dfc8ac967964ee75c706e138c015b627e303798c7bbb88fe4ee63077149717ece0c8474d7888cc6280ea2c0a4fad363ecf1f1f4516f47ef80fe93c0abbf8cfe5
@@ -6,13 +6,16 @@ class Spree::UserConfirmationsController < Devise::ConfirmationsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
13
+
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
16
19
 
17
20
  before_action :set_current_order
18
21
 
@@ -6,17 +6,16 @@ class Spree::UserPasswordsController < Devise::PasswordsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :set_current_order
22
21
 
@@ -6,17 +6,16 @@ class Spree::UserRegistrationsController < Devise::RegistrationsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :check_permissions, only: [:edit, :update]
22
21
  before_action :set_current_order
@@ -6,17 +6,16 @@ class Spree::UserSessionsController < Devise::SessionsController
6
6
  include Spree::Core::ControllerHelpers::Order
7
7
  include Spree::Core::ControllerHelpers::Store
8
8
 
9
- if defined?(Spree::Core::ControllerHelpers::Currency)
10
- include Spree::Core::ControllerHelpers::Currency
11
- end
9
+ include SpreeI18n::ControllerLocaleHelper if defined?(SpreeI18n::ControllerLocaleHelper)
12
10
 
13
- if defined?(Spree::Core::ControllerHelpers::Locale)
14
- include Spree::Core::ControllerHelpers::Locale
15
- end
11
+ include Spree::Core::ControllerHelpers::Currency if defined?(Spree::Core::ControllerHelpers::Currency)
12
+ include Spree::Core::ControllerHelpers::Locale if defined?(Spree::Core::ControllerHelpers::Locale)
16
13
 
17
- if defined?(SpreeI18n::ControllerLocaleHelper)
18
- include SpreeI18n::ControllerLocaleHelper
19
- end
14
+ include Spree::LocaleUrls if defined?(Spree::LocaleUrls)
15
+
16
+ helper 'spree/locale' if defined?(Spree::LocaleHelper)
17
+ helper 'spree/currency' if defined?(Spree::CurrencyHelper)
18
+ helper 'spree/store' if defined?(Spree::StoreHelper)
20
19
 
21
20
  before_action :set_current_order
22
21
 
@@ -66,7 +65,7 @@ class Spree::UserSessionsController < Devise::SessionsController
66
65
  end
67
66
 
68
67
  def after_sign_in_redirect(resource_or_scope)
69
- stored_location_for(resource_or_scope) || account_path
68
+ stored_location_for(resource_or_scope) || spree.account_path
70
69
  end
71
70
 
72
71
  def respond_to_on_destroy
@@ -82,6 +81,6 @@ class Spree::UserSessionsController < Devise::SessionsController
82
81
  scope = Devise::Mapping.find_scope!(resource_or_scope)
83
82
  router_name = Devise.mappings[scope].router_name
84
83
  context = router_name ? send(router_name) : self
85
- context.respond_to?(:login_path) ? context.login_path : "/"
84
+ context.respond_to?(:login_path) ? context.login_path : spree.root_path
86
85
  end
87
86
  end
@@ -34,7 +34,7 @@ class Spree::UsersController < Spree::StoreController
34
34
  bypass_sign_in(@user)
35
35
  end
36
36
  end
37
- redirect_to spree.account_url, notice: Spree.t(:account_updated)
37
+ redirect_to spree.account_path, notice: Spree.t(:account_updated)
38
38
  else
39
39
  render :edit
40
40
  end
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  module Auth
3
- VERSION = '4.3.3'.freeze
3
+ VERSION = '4.3.4'.freeze
4
4
 
5
5
  def gem_version
6
6
  Gem::Version.new(VERSION)
@@ -1,34 +1,42 @@
1
1
  module Spree
2
2
  module TestingSupport
3
3
  module AuthHelpers
4
- def log_in(email:, password:, remember_me: true)
5
- visit spree.login_path
4
+ def login_button
5
+ Spree.version.to_f == 4.1 ? Spree.t(:log_in) : Spree.t(:login)
6
+ end
7
+
8
+ def logout_button
9
+ Spree.version.to_f == 4.1 ? Spree.t('nav_bar.log_out') : Spree.t(:logout).upcase
10
+ end
11
+
12
+ def log_in(email:, password:, remember_me: true, locale: nil)
13
+ visit spree.login_path(locale: locale)
6
14
 
7
- fill_in 'Email', with: email
8
- fill_in 'Password', with: password
15
+ fill_in Spree.t(:email), with: email
16
+ fill_in Spree.t(:password), with: password
9
17
 
10
18
  # Regression test for #1257
11
- first('label', text: 'Remember me').click if remember_me
12
- click_button 'Log in'
19
+ first('label', text: Spree.t(:remember_me)).click if remember_me
20
+ click_button login_button
13
21
 
14
- expect(page).to have_content 'Logged in successfully'
22
+ expect(page).to have_content Spree.t(:logged_in_succesfully)
15
23
  end
16
24
 
17
25
  def log_out
18
26
  show_user_menu
19
- click_link 'LOG OUT'
27
+ click_link logout_button
20
28
 
21
29
  expect(page).to have_content 'Signed out successfully'
22
30
  end
23
31
 
24
32
  def show_user_menu
25
- find("button[aria-label='Show user menu']").click
33
+ find("button[aria-label='#{Spree.t('nav_bar.show_user_menu')}']").click
26
34
  end
27
35
 
28
36
  def show_user_account
29
37
  within '#nav-bar' do
30
38
  show_user_menu
31
- click_link 'MY ACCOUNT'
39
+ click_link Spree.t(:my_account).upcase
32
40
  end
33
41
  end
34
42
  end
@@ -137,7 +137,7 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
137
137
  request.cookie_jar.signed[:guest_token] = 'ABC'
138
138
  request.cookie_jar.signed[:token] = 'DEF'
139
139
  end
140
-
140
+
141
141
  it 'assigns the correct token attribute for the order' do
142
142
  if Spree.version.to_f > 3.6
143
143
  order = create(:order, email: user.email, token: 'ABC', user_id: nil, created_by_id: nil)
@@ -157,6 +157,18 @@ RSpec.describe Spree::UserSessionsController, type: :controller do
157
157
  post :create, params: { spree_user: { email: user.email, password: 'secret' }}
158
158
  expect(response).to redirect_to spree.account_path
159
159
  end
160
+
161
+ context 'different locale' do
162
+ before do
163
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr') if Spree.version.to_f >= 4.2
164
+ end
165
+
166
+ it 'redirects to localized account path after signing in' do
167
+ skip if Spree.version.to_f < 4.2
168
+ post :create, params: { spree_user: { email: user.email, password: 'secret' }, locale: 'fr' }
169
+ expect(response).to redirect_to spree.account_path(locale: 'fr')
170
+ end
171
+ end
160
172
  end
161
173
 
162
174
  context "and js format is used" do
@@ -25,7 +25,7 @@ RSpec.describe Spree::UsersController, type: :controller do
25
25
  it 'performs update' do
26
26
  put :update, params: { user: { email: 'mynew@email-address.com' } }
27
27
  expect(assigns[:user].email).to eq 'mynew@email-address.com'
28
- expect(response).to redirect_to spree.account_url(only_path: true)
28
+ expect(response).to redirect_to spree.account_path
29
29
  end
30
30
  end
31
31
 
@@ -10,7 +10,7 @@ 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 'Log in'
13
+ click_button login_button
14
14
 
15
15
  show_user_account
16
16
  expect(page).to have_text 'admin@person.com'
@@ -43,7 +43,7 @@ RSpec.feature 'Accounts', type: :feature do
43
43
 
44
44
  fill_in 'Email', with: user.email
45
45
  fill_in 'Password', with: user.password
46
- click_button 'Log in'
46
+ click_button login_button
47
47
 
48
48
  show_user_account
49
49
  expect(page).to have_text 'email@person.com'
@@ -1,6 +1,7 @@
1
1
  RSpec.feature 'Admin orders', type: :feature do
2
2
  background do
3
- sign_in_as! create(:admin_user)
3
+ user = create(:admin_user)
4
+ log_in email: user.email, password: user.password
4
5
  end
5
6
 
6
7
  # Regression #203
@@ -13,8 +13,8 @@ RSpec.feature 'Admin - Sign In', type: :feature do
13
13
  log_in(email: @user.email, password: 'secret')
14
14
  show_user_menu
15
15
 
16
- expect(page).not_to have_text 'Login'
17
- expect(page).to have_text 'LOG OUT'
16
+ expect(page).not_to have_text login_button.upcase
17
+ expect(page).to have_text logout_button.upcase
18
18
  expect(current_path).to eq '/account'
19
19
  end
20
20
 
@@ -33,13 +33,13 @@ RSpec.feature 'Admin - Sign In', type: :feature do
33
33
 
34
34
  fill_in 'Email', with: user.email
35
35
  fill_in 'Password', with: 'secret'
36
+ click_button login_button
37
+
36
38
  if Spree.version.to_f > 4.1
37
- click_button 'Login'
38
39
  within '.navbar .dropdown-menu' do
39
40
  expect(page).to have_text 'admin@person.com'
40
41
  end
41
42
  else
42
- click_button 'Log in'
43
43
  within '.user-menu' do
44
44
  expect(page).to have_text 'admin@person.com'
45
45
  end
@@ -9,13 +9,13 @@ RSpec.feature 'Admin - Sign Out', type: :feature do
9
9
  fill_in 'Password', with: 'secret'
10
10
  # Regression test for #1257
11
11
  check 'Remember me'
12
- click_button 'Login'
12
+ click_button Spree.t(:login)
13
13
  end
14
14
 
15
15
  scenario 'allows a signed in user to logout', js: true do
16
16
  log_out
17
17
  visit spree.admin_login_path
18
- expect(page).to have_button 'Login'
19
- expect(page).not_to have_text 'Logout'
18
+ expect(page).to have_button Spree.t(:login)
19
+ expect(page).not_to have_text Spree.t(:logout)
20
20
  end
21
21
  end
@@ -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 'Log in'
10
+ click_button login_button
11
11
  end
12
12
 
13
13
  context 'admin is restricted from accessing orders' do
@@ -55,7 +55,7 @@ RSpec.feature 'Checkout', :js, type: :feature do
55
55
  visit spree.login_path
56
56
  fill_in 'Email', with: user.email
57
57
  fill_in 'Password', with: user.password
58
- click_button 'Log in'
58
+ click_button login_button
59
59
  expect(page).to have_text('Logged in successfully')
60
60
  find('a.cart-icon').click
61
61
 
@@ -17,7 +17,7 @@ RSpec.feature 'Orders', :js, type: :feature do
17
17
  visit spree.login_path
18
18
  fill_in 'Email', with: user.email
19
19
  fill_in 'Password', with: user.password
20
- click_button 'Log in'
20
+ click_button login_button
21
21
 
22
22
  visit spree.cart_path
23
23
  expect(page).to have_text 'RoR Mug'
@@ -29,7 +29,7 @@ RSpec.feature 'Orders', :js, type: :feature do
29
29
  visit spree.login_path
30
30
  fill_in 'Email', with: user.email
31
31
  fill_in 'Password', with: user.password
32
- click_button 'Log in'
32
+ click_button login_button
33
33
 
34
34
  # Order should have been merged with first session
35
35
  visit spree.cart_path
@@ -13,15 +13,15 @@ RSpec.feature 'Sign In', type: :feature do
13
13
  log_in(email: @user.email, password: @user.password)
14
14
  show_user_menu
15
15
 
16
- expect(page).not_to have_text 'Login'
17
- expect(page).to have_text 'LOG OUT'
16
+ expect(page).not_to have_text login_button.upcase
17
+ expect(page).to have_text logout_button.upcase
18
18
  expect(current_path).to eq '/account'
19
19
  end
20
20
 
21
21
  scenario 'show validation erros' do
22
22
  fill_in 'Email', with: @user.email
23
23
  fill_in 'Password', with: 'wrong_password'
24
- click_button 'Log in'
24
+ click_button login_button
25
25
 
26
26
  expect(page).to have_text 'Invalid email or password'
27
27
  expect(page).to have_text 'Log in'
@@ -35,12 +35,12 @@ RSpec.feature 'Sign In', type: :feature do
35
35
  fill_in 'Password', with: user.password
36
36
 
37
37
  if Spree.version.to_f > 4.1
38
- click_button 'Login'
38
+ click_button login_button
39
39
  within '.navbar .dropdown-menu' do
40
40
  expect(page).to have_text 'admin@person.com'
41
41
  end
42
42
  else
43
- click_button 'Log in'
43
+ click_button login_button
44
44
  within '.user-menu' do
45
45
  expect(page).to have_text 'admin@person.com'
46
46
  end
@@ -52,7 +52,29 @@ RSpec.feature 'Sign In', type: :feature do
52
52
  visit spree.account_path
53
53
  fill_in 'Email', with: @user.email
54
54
  fill_in 'Password', with: @user.password
55
- click_button 'Log in'
55
+ click_button login_button
56
56
  expect(current_path).to eq '/account'
57
57
  end
58
+
59
+ context 'localized' do
60
+ before do
61
+ if Spree.version.to_f >= 4.2
62
+ add_french_locales
63
+ Spree::Store.default.update(default_locale: 'en', supported_locales: 'en,fr')
64
+ I18n.locale = :fr
65
+ end
66
+ end
67
+
68
+ after { I18n.locale = :en }
69
+
70
+ scenario 'let a user sign in successfully', js: true do
71
+ skip if Spree.version.to_f < 4.2
72
+ log_in(email: @user.email, password: @user.password, locale: 'fr')
73
+ show_user_menu
74
+
75
+ expect(page).not_to have_text Spree.t(:login).upcase
76
+ expect(page).to have_text Spree.t(:logout).upcase
77
+ expect(current_url).to match(/\/account\?locale\=fr$/)
78
+ end
79
+ end
58
80
  end
@@ -16,8 +16,8 @@ RSpec.feature 'Sign Out', type: :feature, js: true do
16
16
  visit spree.root_path
17
17
  show_user_menu
18
18
 
19
- expect(page).to have_link 'LOG IN'
20
- expect(page).not_to have_link 'LOG OUT'
19
+ expect(page).to have_link login_button.upcase
20
+ expect(page).not_to have_link logout_button.upcase
21
21
  end
22
22
 
23
23
  describe 'before_logout' do
data/spec/spec_helper.rb CHANGED
@@ -9,10 +9,14 @@ require 'spree_dev_tools/rspec/spec_helper'
9
9
  # in spec/support/ and its subdirectories.
10
10
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
11
11
 
12
+ require 'spree/testing_support/locale_helpers' if Spree.version.to_f >= 4.2
13
+
12
14
  RSpec.configure do |config|
13
15
  config.before(:each) do
14
16
  allow(RSpec::Rails::ViewRendering::EmptyTemplateHandler)
15
17
  .to receive(:call)
16
18
  .and_return(%("")) if Rails.gem_version >= Gem::Version.new('6.0.0.beta1')
17
19
  end
20
+
21
+ config.include Spree::TestingSupport::LocaleHelpers if defined?(Spree::TestingSupport::LocaleHelpers)
18
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_auth_devise
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.3
4
+ version: 4.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Schofield
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-02-04 00:00:00.000000000 Z
12
+ date: 2021-02-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -222,9 +222,9 @@ licenses:
222
222
  - BSD-3-Clause
223
223
  metadata:
224
224
  bug_tracker_uri: https://github.com/spree/spree_auth_devise/issues
225
- changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.3.3
225
+ changelog_uri: https://github.com/spree/spree_auth_devise/releases/tag/v4.3.4
226
226
  documentation_uri: https://guides.spreecommerce.org/
227
- source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.3.3
227
+ source_code_uri: https://github.com/spree/spree_auth_devise/tree/v4.3.4
228
228
  post_install_message:
229
229
  rdoc_options: []
230
230
  require_paths:
@@ -241,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
241
241
  version: '0'
242
242
  requirements:
243
243
  - none
244
- rubygems_version: 3.1.4
244
+ rubygems_version: 3.2.3
245
245
  signing_key:
246
246
  specification_version: 4
247
247
  summary: Provides authentication and authorization services for use with Spree by