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,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::UserMailer, type: :mailer do
4
- let!(:store) { create(:store) }
5
- let(:user) { create(:user) }
6
-
7
- before do
8
- user = create(:user)
9
- Spree::UserMailer.reset_password_instructions(user, 'token goes here').deliver_now
10
- @message = ActionMailer::Base.deliveries.last
11
- end
12
-
13
- describe '#reset_password_instructions' do
14
- describe 'message contents' do
15
- before do
16
- described_class.reset_password_instructions(user, 'token goes here').deliver_now
17
- @message = ActionMailer::Base.deliveries.last
18
- end
19
-
20
- context 'subject includes' do
21
- it 'translated devise instructions' do
22
- expect(@message.subject).to include(
23
- I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions])
24
- )
25
- end
26
-
27
- it 'Spree site name' do
28
- expect(@message.subject).to include store.name
29
- end
30
- end
31
-
32
- context 'body includes' do
33
- it 'password reset url' do
34
- expect(@message.body.raw_source).to include "http://#{store.url}/user/spree_user/password/edit"
35
- end
36
- end
37
- end
38
-
39
- describe 'legacy support for User object' do
40
- it 'sends an email' do
41
- expect {
42
- described_class.reset_password_instructions(user, 'token goes here').deliver_now
43
- }.to change(ActionMailer::Base.deliveries, :size).by(1)
44
- end
45
- end
46
- end
47
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::Order, type: :model do
4
- let(:order) { described_class.new }
5
-
6
- context '#associate_user!' do
7
- let(:user) { build_stubbed(:user, email: 'spree@example.com') }
8
- before { allow(order).to receive(:save!) { true } }
9
-
10
- it 'associates the order with the specified user' do
11
- order.associate_user! user
12
- expect(order.user).to eq user
13
- end
14
-
15
- it "sets the order's email attribute to that of the specified user" do
16
- order.associate_user! user
17
- expect(order.email).to eq user.email
18
- end
19
-
20
- it 'destroys any previous association with a guest user' do
21
- guest_user = build_stubbed(:user)
22
- order.user = guest_user
23
- order.associate_user! user
24
- expect(order.user).not_to eq guest_user
25
- end
26
- end
27
- end
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe Spree::User, type: :model do
4
- before(:all) { Spree::Role.create name: 'admin' }
5
-
6
- it '#admin?' do
7
- expect(create(:admin_user).admin?).to be true
8
- expect(create(:user).admin?).to be false
9
- end
10
-
11
- context "recoverable" do
12
- let(:user) { create(:user) }
13
-
14
- it 'generates the reset password token' do
15
- expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, {}).and_return(double(deliver: true))
16
- expect { user.send_reset_password_instructions }.to change(user, :reset_password_token).to be_present
17
- end
18
-
19
- it "regenerates a spree api key on successful password change" do
20
- user.generate_spree_api_key!
21
-
22
- expect {
23
- user.password = "123456678"
24
- user.password_confirmation = "123456678"
25
- user.save!
26
- }.to change(user, :spree_api_key)
27
- expect(user.spree_api_key).to be_present
28
- end
29
-
30
- it "does not generate a spree api key if password is empty" do
31
- user.generate_spree_api_key!
32
-
33
- expect {
34
- user.password = ""
35
- user.password_confirmation = ""
36
- user.save!
37
- }.not_to change(user, :spree_api_key)
38
- end
39
-
40
- it "does not generate a spree api key on password change if no key existed previously" do
41
- user.clear_spree_api_key!
42
-
43
- expect {
44
- user.password = "123456678"
45
- user.password_confirmation = "123456678"
46
- user.save!
47
- }.not_to change(user, :spree_api_key)
48
- expect(user.reload.spree_api_key).to be_nil
49
- end
50
- end
51
-
52
- describe '#destroy' do
53
- let(:user) { create(:user) }
54
-
55
- context 'with same email address as previously deleted account' do
56
- it 'allows users to register later' do
57
- user1 = build(:user)
58
- user1.save
59
-
60
- user2 = build(:user)
61
- user2.email = user1.email
62
- expect(user2.save).to be false
63
- expect(user2.errors.messages[:email].first).to eq "has already been taken"
64
-
65
- user1.discard
66
- expect(user2.save).to be true
67
- end
68
- end
69
- end
70
-
71
- describe '#destroy' do
72
- let(:user) { create(:user) }
73
-
74
- it 'removes the record from the database' do
75
- user.destroy
76
-
77
- if defined?(Spree::ParanoiaDeprecations)
78
- expect(Spree::User.with_discarded.exists?(id: user.id)).to eql true
79
- else
80
- expect(Spree::User.with_discarded.exists?(id: user.id)).to eql false
81
- end
82
- end
83
- end
84
-
85
- describe '#really_destroy!', if: defined?(Spree::ParanoiaDeprecations) do
86
- let(:user) { create(:user) }
87
-
88
- it 'removes the record from the database' do
89
- user.really_destroy!
90
- expect(Spree::User.with_deleted.exists?(id: user.id)).to eql false
91
- end
92
- end
93
-
94
- describe "confirmable" do
95
- it "loads Devise's :confirmable module when :confirmable is true", confirmable: true do
96
- expect(Spree::User.ancestors).to include(Devise::Models::Confirmable)
97
- end
98
-
99
- it "does not load Devise's :confirmable module when :confirmable is false", confirmable: false do
100
- expect(Spree::User.ancestors).not_to include(Devise::Models::Confirmable)
101
- end
102
- end
103
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.feature 'User update', type: :request do
4
- context 'CSRF protection' do
5
- %i[exception reset_session null_session].each do |strategy|
6
- # Completely clean the configuration of forgery protection for the
7
- # controller and reset it after the expectations. However, besides `:with`,
8
- # the options given to `protect_from_forgery` are processed on the fly.
9
- # I.e., there's no way to retain them. The initial setup corresponds to the
10
- # dummy application, which uses the default Rails skeleton in that regard.
11
- # So, if at some point Rails changed the given options, we should update it
12
- # here.
13
- around do |example|
14
- controller = Spree::UsersController
15
- old_allow_forgery_protection_value = controller.allow_forgery_protection
16
- old_forgery_protection_strategy = controller.forgery_protection_strategy
17
- controller.skip_forgery_protection
18
- controller.allow_forgery_protection = true
19
- controller.protect_from_forgery with: strategy
20
-
21
- example.run
22
-
23
- controller.allow_forgery_protection = old_allow_forgery_protection_value
24
- controller.forgery_protection_strategy = old_forgery_protection_strategy
25
- end
26
-
27
- it "is not possible to take account over with the #{strategy} forgery protection strategy" do
28
- user = create(:user, email: 'legit@mail.com', password: 'password')
29
-
30
- post '/login', params: "spree_user[email]=legit@mail.com&spree_user[password]=password"
31
- begin
32
- put '/users/123456', params: 'user[email]=hacked@example.com'
33
- rescue
34
- # testing that the account is not compromised regardless of any raised
35
- # exception
36
- end
37
-
38
- expect(user.reload.email).to eq('legit@mail.com')
39
- end
40
- end
41
- end
42
- end
data/spec/spec_helper.rb DELETED
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Configure Rails Environment
4
- ENV['RAILS_ENV'] = 'test'
5
-
6
- require 'rails-controller-testing'
7
-
8
- # Run Coverage report
9
- require 'solidus_dev_support/rspec/coverage'
10
-
11
- # Create the dummy app if it's still missing.
12
- dummy_env = "#{__dir__}/dummy/config/environment.rb"
13
- system 'bin/rake extension:test_app' unless File.exist? dummy_env
14
- require dummy_env
15
-
16
- # Requires factories and other useful helpers defined in spree_core.
17
- require 'solidus_dev_support/rspec/feature_helper'
18
-
19
- # Requires supporting ruby files with custom matchers and macros, etc,
20
- # in spec/support/ and its subdirectories.
21
- Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
22
-
23
- # Requires factories defined in lib/solidus_auth_devise/testing_support/factories.rb
24
- SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAuthDevise::Engine)
25
-
26
- RSpec.configure do |config|
27
- config.infer_spec_type_from_file_location!
28
- config.use_transactional_fixtures = false
29
-
30
- if Spree.solidus_gem_version < Gem::Version.new('2.11')
31
- config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
32
- end
33
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.after do
5
- Spree::Ability.abilities.delete(AbilityDecorator) if Spree::Ability.abilities.include?(AbilityDecorator)
6
- end
7
- end
8
-
9
- if defined? CanCan::Ability
10
- class AbilityDecorator
11
- include CanCan::Ability
12
-
13
- def initialize(_user)
14
- cannot :manage, Spree::Order
15
- end
16
- end
17
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module AuthenticationHelpers
4
- def sign_in_as!(user)
5
- visit '/login'
6
- fill_in 'Email', with: user.email
7
- fill_in 'Password', with: 'secret'
8
- click_button 'Login'
9
- end
10
- end
11
-
12
- RSpec.configure do |config|
13
- config.include AuthenticationHelpers, type: :feature
14
- config.include Devise::Test::ControllerHelpers, type: :controller
15
- config.include Rack::Test::Methods, type: :feature
16
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.around do |example|
5
- if example.metadata.key?(:confirmable)
6
- old_user = Spree::User
7
-
8
- begin
9
- example.run
10
- ensure
11
- Spree.send(:remove_const, :User)
12
- Spree.const_set('User', old_user)
13
- end
14
- else
15
- example.run
16
- end
17
- end
18
-
19
- config.before do |example|
20
- if example.metadata.key?(:confirmable)
21
- stub_spree_preferences(Spree::Auth::Config, confirmable: example.metadata[:confirmable])
22
-
23
- Spree.send(:remove_const, :User)
24
- load File.expand_path('../../../app/models/spree/user.rb', __FILE__)
25
- end
26
- end
27
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- config.before do
5
- ActionMailer::Base.deliveries.clear
6
- end
7
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module FillAddressFields
4
- def fill_addresses_fields_with(address)
5
- fields = %w[
6
- address1
7
- city
8
- zipcode
9
- phone
10
- ]
11
- fields += if SolidusSupport.combined_first_and_last_name_in_address?
12
- %w[name]
13
- else
14
- %w[firstname lastname]
15
- end
16
-
17
- fields.each do |field|
18
- fill_in "order_bill_address_attributes_#{field}", with: address.send(field).to_s
19
- end
20
- select 'United States', from: "order_bill_address_attributes_country_id"
21
- select address.state.name.to_s, from: "order_bill_address_attributes_state_id"
22
-
23
- check 'order_use_billing'
24
- end
25
- end
26
-
27
- RSpec.configure do |config|
28
- config.include FillAddressFields, type: :feature
29
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.configure do |config|
4
- if SolidusSupport.reset_spree_preferences_deprecated?
5
- config.before :suite do
6
- Spree::TestingSupport::Preferences.freeze_preferences(Spree::Auth::Config)
7
- end
8
- else
9
- config.before do
10
- Spree::Auth::Config.preference_store = Spree::Auth::Config.default_preferences
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spree/testing_support/url_helpers'
4
- require 'spree/testing_support/controller_requests'
5
- require 'spree/testing_support/authorization_helpers'
6
- require 'spree/testing_support/capybara_ext'
7
-
8
- RSpec.configure do |config|
9
- config.include Spree::TestingSupport::UrlHelpers
10
- config.include Spree::TestingSupport::ControllerRequests, type: :controller
11
- end