From 512fc625c097fe5cd99ec9c7e592e93ce658a2a7 Mon Sep 17 00:00:00 2001 From: Jonathan Tapia Date: Tue, 26 Jul 2022 11:56:02 -0500 Subject: [PATCH 01/49] Fix autoload issue on Solidus v3.1.0 --- app/models/spree/user.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index ab0fd927..a97357f8 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -3,21 +3,12 @@ module Spree class User < Spree::Base include UserMethods + include Spree::SoftDeletable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :encryptable devise :confirmable if Spree::Auth::Config[:confirmable] - if defined?(Spree::SoftDeletable) - include Spree::SoftDeletable - else - acts_as_paranoid - include Spree::ParanoiaDeprecations - - include Discard::Model - self.discard_column = :deleted_at - end - after_destroy :scramble_email_and_password after_discard :scramble_email_and_password From ddf33cfcbc3288928841891563916e7855e6ff39 Mon Sep 17 00:00:00 2001 From: Alberto Vena Date: Thu, 4 May 2023 17:04:43 +0200 Subject: [PATCH 02/49] Release v2.5.8 --- lib/solidus_auth_devise/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solidus_auth_devise/version.rb b/lib/solidus_auth_devise/version.rb index 7178a1f2..6217903b 100644 --- a/lib/solidus_auth_devise/version.rb +++ b/lib/solidus_auth_devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusAuthDevise - VERSION = '2.5.7' + VERSION = '2.5.8' end From fde22ebeef89239163eb7f40bad730c70fe2f336 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Wed, 31 May 2023 17:28:43 +0200 Subject: [PATCH 03/49] Ensure the admin sign in root path fallback is '/admin' Previously relied on solidus_frontend defining `spree.root_path`, and used it redirecting admin users to the store home page. --- .../spree/admin/user_sessions_controller.rb | 4 ++++ .../admin/user_sessions_controller_spec.rb | 22 +++++++++++++++++++ spec/features/admin/sign_in_spec.rb | 4 ++-- 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 spec/controllers/spree/admin/user_sessions_controller_spec.rb diff --git a/lib/controllers/backend/spree/admin/user_sessions_controller.rb b/lib/controllers/backend/spree/admin/user_sessions_controller.rb index 7fcdbb75..366c281f 100644 --- a/lib/controllers/backend/spree/admin/user_sessions_controller.rb +++ b/lib/controllers/backend/spree/admin/user_sessions_controller.rb @@ -35,6 +35,10 @@ def authorization_failure private + def signed_in_root_path(_resource) + spree.admin_path + end + # NOTE: as soon as this gem stops supporting Solidus 3.1 if-else should be removed and left only include if defined?(::Spree::Admin::SetsUserLanguageLocaleKey) include ::Spree::Admin::SetsUserLanguageLocaleKey diff --git a/spec/controllers/spree/admin/user_sessions_controller_spec.rb b/spec/controllers/spree/admin/user_sessions_controller_spec.rb new file mode 100644 index 00000000..167d8aec --- /dev/null +++ b/spec/controllers/spree/admin/user_sessions_controller_spec.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +RSpec.describe Spree::Admin::UserSessionsController, type: :controller do + let(:user) { create(:user, password: 'secret') } + + before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + + it "redirects to the admin root after signing in with no stored location" do + get :new + + post(:create, + params: { + spree_user: { + email: user.email, + password: 'secret' + }, + } + ) + + expect(response).to redirect_to spree.admin_path + end +end diff --git a/spec/features/admin/sign_in_spec.rb b/spec/features/admin/sign_in_spec.rb index 25840f1c..fc1d70e8 100644 --- a/spec/features/admin/sign_in_spec.rb +++ b/spec/features/admin/sign_in_spec.rb @@ -2,7 +2,7 @@ RSpec.feature 'Admin - Sign In', type: :feature do background do - @user = create(:user, email: 'email@person.com') + @user = create(:admin_user, email: 'email@person.com') visit spree.admin_login_path end @@ -19,7 +19,7 @@ expect(page).to have_text 'Logged in successfully' expect(page).not_to have_text 'Login' expect(page).to have_text 'Logout' - expect(current_path).to eq '/' + expect(current_path).to eq '/admin/orders' end scenario 'shows validation erros' do From 7bd486fde633582286135687cb408e62bbefac99 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Tue, 27 Jun 2023 14:31:34 +0200 Subject: [PATCH 04/49] Fix some rubocop issues --- .rubocop_todo.yml | 3 +-- .../admin/user_sessions_controller_spec.rb | 16 +++++++--------- .../spree/user_sessions_controller_spec.rb | 18 ++++++++---------- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 58909603..bf5aaba1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -105,7 +105,7 @@ RSpec/BeforeAfterAll: # Offense count: 5 # This cop supports safe autocorrection (--autocorrect). -RSpec/Capybara/CurrentPathExpectation: +Capybara/CurrentPathExpectation: Exclude: - 'spec/features/admin/sign_in_spec.rb' - 'spec/features/sign_in_spec.rb' @@ -221,7 +221,6 @@ RSpec/InstanceVariable: - 'spec/controllers/spree/admin/user_passwords_controller_spec.rb' - 'spec/controllers/spree/user_passwords_controller_spec.rb' - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - 'spec/features/admin/sign_in_spec.rb' - 'spec/features/checkout_spec.rb' - 'spec/features/sign_in_spec.rb' diff --git a/spec/controllers/spree/admin/user_sessions_controller_spec.rb b/spec/controllers/spree/admin/user_sessions_controller_spec.rb index 167d8aec..febfa3aa 100644 --- a/spec/controllers/spree/admin/user_sessions_controller_spec.rb +++ b/spec/controllers/spree/admin/user_sessions_controller_spec.rb @@ -3,19 +3,17 @@ RSpec.describe Spree::Admin::UserSessionsController, type: :controller do let(:user) { create(:user, password: 'secret') } - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable it "redirects to the admin root after signing in with no stored location" do get :new - post(:create, - params: { - spree_user: { - email: user.email, - password: 'secret' - }, - } - ) + post(:create, params: { + spree_user: { + email: user.email, + password: 'secret' + }, + }) expect(response).to redirect_to spree.admin_path end diff --git a/spec/controllers/spree/user_sessions_controller_spec.rb b/spec/controllers/spree/user_sessions_controller_spec.rb index d49de10c..84619372 100644 --- a/spec/controllers/spree/user_sessions_controller_spec.rb +++ b/spec/controllers/spree/user_sessions_controller_spec.rb @@ -3,22 +3,20 @@ RSpec.describe Spree::UserSessionsController, type: :controller do let(:user) { create(:user) } - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable context "#create" do let(:format) { :html } let(:password) { 'secret' } subject do - post(:create, - params: { - spree_user: { - email: user.email, - password: password - }, - format: format - } - ) + post(:create, params: { + spree_user: { + email: user.email, + password: password + }, + format: format + }) end context "when using correct login information" do From d46e3425129b8d333fa6d5b721c0a2fdf32de50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Busqu=C3=A9?= Date: Tue, 29 Aug 2023 15:30:33 +0200 Subject: [PATCH 05/49] Adapt to the new default branch name of `main` --- .circleci/config.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6b257885..02788bfd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,7 +61,7 @@ workflows: filters: branches: only: - - master + - main jobs: - run-specs: name: *name diff --git a/README.md b/README.md index 0e9ec33a..0739fbaf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Solidus Auth Devise [![CircleCI](https://circleci.com/gh/solidusio/solidus_auth_devise.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_auth_devise) -[![codecov](https://codecov.io/gh/solidusio/solidus_auth_devise/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_auth_devise) +[![codecov](https://codecov.io/gh/solidusio/solidus_auth_devise/branch/main/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_auth_devise) Provides authentication services for Solidus, using the Devise gem. From 3f2a2fdbb751c9e336df5d507067f521b7e16158 Mon Sep 17 00:00:00 2001 From: Rainer Dema Date: Wed, 4 Oct 2023 17:17:01 +0200 Subject: [PATCH 06/49] Fix admin logout feature spec Update the admin logout feature spec to accommodate the UI changes in the admin navigation bar. The 'Logout' link is now nested within a 'details' tag and must be clicked/expanded to access the logout functionality. --- spec/features/admin/sign_out_spec.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/sign_out_spec.rb b/spec/features/admin/sign_out_spec.rb index 420ad145..c8447ed8 100644 --- a/spec/features/admin/sign_out_spec.rb +++ b/spec/features/admin/sign_out_spec.rb @@ -15,9 +15,28 @@ end scenario 'allows a signed in user to logout' do - click_link 'Logout' + click_logout_link visit spree.admin_login_path expect(page).to have_text 'Login' expect(page).not_to have_text 'Logout' end + + def click_logout_link + new_version? ? logout_new_version : logout_old_version + end + + def new_version? + Gem::Requirement.new('>= 4.2').satisfied_by?(Spree.solidus_gem_version) + end + + def logout_new_version + find('details div', text: user.email, wait: 10).click + within('details') do + click_link 'Logout' + end + end + + def logout_old_version + click_link 'Logout' + end end From 3534fd02177513dfc4568bb5215a94f38ce3379d Mon Sep 17 00:00:00 2001 From: Rainer Dema Date: Wed, 4 Oct 2023 17:17:07 +0200 Subject: [PATCH 07/49] Fix RuboCop offense in warden initializer ``` config/initializers/warden.rb:7:99: C: [Correctable] Rails/FindEach: Use find_each instead of each. ``` --- config/initializers/warden.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index f044dc13..9369d7f1 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -4,7 +4,7 @@ Warden::Manager.after_set_user except: :fetch do |user, auth, _opts| if auth.cookies.signed[:guest_token].present? if user.is_a?(Spree::User) - Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).each do |order| + Spree::Order.incomplete.where(guest_token: auth.cookies.signed[:guest_token], user_id: nil).find_each do |order| order.associate_user!(user) end end From 4faf85b8b0e5a402419ea47d315cad4394ada65a Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 25 Jan 2024 13:45:21 +0100 Subject: [PATCH 08/49] Add empty :new action to Spree::UsersController Without this, specs fail with ``` AbstractController::ActionNotFound: The new action could not be found for the :authorize_actions callback on Spree::UsersController, but it is listed in the controller's :only option. ``` I guess this is because the views are not in the standard place, thus impeding Rails' ability to dynamically generate empty actions if matching views are present. Anyways: This is good, because it's more explicit. --- lib/controllers/frontend/spree/users_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/controllers/frontend/spree/users_controller.rb b/lib/controllers/frontend/spree/users_controller.rb index b6f31b45..66db9743 100644 --- a/lib/controllers/frontend/spree/users_controller.rb +++ b/lib/controllers/frontend/spree/users_controller.rb @@ -4,6 +4,8 @@ class Spree::UsersController < Spree::StoreController skip_before_action :set_current_order, only: :show, raise: false prepend_before_action :authorize_actions, only: :new + def new; end + def show load_object @orders = @user.orders.complete.order('completed_at desc') From 1ffd9dea602179a8cf01ad62042ca04c1c34344e Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 25 Jan 2024 13:54:37 +0100 Subject: [PATCH 09/49] Rubocop fix --- spec/models/user_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c3e6e544..11a1b25b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -53,7 +53,7 @@ let(:user) { create(:user) } context 'with same email address as previously deleted account' do - it 'will allow users to register later' do + it 'allows users to register later' do user1 = build(:user) user1.save From 9f2500706b54e414bf31938bf5ed0509887007e0 Mon Sep 17 00:00:00 2001 From: andrea longhi Date: Tue, 30 Jan 2024 18:18:31 +0100 Subject: [PATCH 10/49] Release v2.5.9 --- lib/solidus_auth_devise/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solidus_auth_devise/version.rb b/lib/solidus_auth_devise/version.rb index 6217903b..724ca8d4 100644 --- a/lib/solidus_auth_devise/version.rb +++ b/lib/solidus_auth_devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusAuthDevise - VERSION = '2.5.8' + VERSION = '2.5.9' end From 6957f68f4b2964d03a81010937acfa476717c6d1 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 16 Dec 2024 15:32:24 +0100 Subject: [PATCH 11/49] CI: Lint with Ruby 3.1 We install latest Solidus during linting code and this requires at least Ruby 3.1 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 02788bfd..eb47bec3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: lint-code: executor: name: solidusio_extensions/sqlite - ruby_version: "3.0" + ruby_version: "3.1" steps: - solidusio_extensions/lint-code From 7bedc871c2139cb7ed8a519e7027d6e2c2e5db1e Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 16 Dec 2024 15:52:22 +0100 Subject: [PATCH 12/49] CI: Pin sqlite to v1.4 Rails 7.0 does not work with sqlite 2.0, which is loaded, if we do not set a specific version. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8d10117d..6d2cfa48 100644 --- a/Gemfile +++ b/Gemfile @@ -22,7 +22,7 @@ when 'mysql' when 'postgresql' gem 'pg' else - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' end if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') From 14d176f850ce19dafc2e05e56483690453a9fdb6 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 30 Nov 2024 16:07:43 +0100 Subject: [PATCH 13/49] Set User Class on Boot For most of the Rails boot process, an app running solidus_auth_devise believes that its user class is whatever is configured in the config/spree.rb initializer. However, if `solidus_auth_devise` is installed, that is changed after most things have been configured. It need not be this way: If we want this gem to set a default, we should set it really early on, not in one of the last initializers to run (they also run alphabetically, so `solidus_auth_devise` initializers run quite late. --- lib/spree/auth/engine.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index d32f0035..f0e98489 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -13,16 +13,14 @@ class Engine < Rails::Engine isolate_namespace Spree engine_name 'solidus_auth' + Spree.user_class = "Spree::User" + initializer "spree.auth.environment", before: :load_config_initializers do |_app| require 'spree/auth_configuration' Spree::Auth::Config = Spree::AuthConfiguration.new end - initializer "solidus_auth_devise.set_user_class", after: :load_config_initializers do - Spree.user_class = "Spree::User" - end - config.to_prepare do Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available? Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available? From 2b5c3d2990c94d9d72d238bd629869b83582834e Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 17 Dec 2024 11:05:00 +0100 Subject: [PATCH 14/49] Spec setup: Set user class to `Spree::User` With the generated dummy `spree.rb` now running after the default in the solidus_auth_devise `engine.rb`, we need to make sure that `config/initializers/spree.rb` contains the correct user class. Before this commit, it would generate one with the `Spree::LegacyUser`. --- Rakefile | 2 +- solidus_auth_devise.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index f2c8a958..2640ab94 100644 --- a/Rakefile +++ b/Rakefile @@ -6,6 +6,6 @@ ENV['SKIP_SOLIDUS_BOLT'] = 'true' require 'bundler/gem_tasks' require 'solidus_dev_support/rake_tasks' -SolidusDevSupport::RakeTasks.install +SolidusDevSupport::RakeTasks.install(user_class: "Spree::User") task default: 'extension:specs' diff --git a/solidus_auth_devise.gemspec b/solidus_auth_devise.gemspec index d8704049..17a4032a 100644 --- a/solidus_auth_devise.gemspec +++ b/solidus_auth_devise.gemspec @@ -36,6 +36,6 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'solidus_backend' spec.add_development_dependency 'solidus_frontend' - spec.add_development_dependency 'solidus_dev_support', '~> 2.5' + spec.add_development_dependency 'solidus_dev_support', '~> 2.10' spec.add_development_dependency 'rails-controller-testing' end From faa2ccf19144fc8615b8a77e2bdfd22ade2c125e Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 21 Dec 2024 17:32:38 +0100 Subject: [PATCH 15/49] Do not reload routes before application startup This devise.rb initializer is run for most stores, and by setting `reload_routes` to `false`, we can avoid Devise reloading the routes in an initializer. Rails will do this just fine, but not in the initializer chain. --- config/initializers/devise.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 5f724ef1..522ce5dd 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -143,4 +143,6 @@ config.reset_password_within = 6.hours config.case_insensitive_keys = [:email] + + config.reload_routes = false end From 2b2e0de02af8172305beb315c0f0e233bffc6a70 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 2 Dec 2022 13:19:49 +0100 Subject: [PATCH 16/49] Remove unused authentication_token column This column dates back to 2013, when token authentication was removed from Devise. We should not keep it. This allows new stores to start without the unused column, while old stores can still use any tokens they might be using. --- db/migrate/20101026184950_rename_columns_for_devise.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/db/migrate/20101026184950_rename_columns_for_devise.rb b/db/migrate/20101026184950_rename_columns_for_devise.rb index 09babcb2..5b9dbb33 100644 --- a/db/migrate/20101026184950_rename_columns_for_devise.rb +++ b/db/migrate/20101026184950_rename_columns_for_devise.rb @@ -14,14 +14,12 @@ def up rename_column :spree_users, :last_login_at, :last_sign_in_at rename_column :spree_users, :current_login_ip, :current_sign_in_ip rename_column :spree_users, :last_login_ip, :last_sign_in_ip - add_column :spree_users, :authentication_token, :string add_column :spree_users, :unlock_token, :string add_column :spree_users, :locked_at, :datetime remove_column :spree_users, :openid_identifier end def down - remove_column :spree_users, :authentication_token remove_column :spree_users, :locked_at remove_column :spree_users, :unlock_token rename_column :spree_users, :last_sign_in_ip, :last_login_ip From 3234e4917a0cb81216add20088ba0f255ff1f557 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Mon, 16 Dec 2024 15:21:27 +0100 Subject: [PATCH 17/49] Use flickwerk-style patches This moves the patches in this gem from `lib/decorators/` to `lib/patches`, allowing Flickwerk to take over the patching. --- .../backend/controllers/spree/admin/base_controller_patch.rb} | 2 +- .../spree/admin/orders/customer_details_controller_patch.rb} | 2 +- .../frontend/controllers/spree/checkout_controller_patch.rb} | 2 +- solidus_auth_devise.gemspec | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename lib/{decorators/backend/controllers/spree/admin/base_controller_decorator.rb => patches/backend/controllers/spree/admin/base_controller_patch.rb} (90%) rename lib/{decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb => patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb} (88%) rename lib/{decorators/frontend/controllers/spree/checkout_controller_decorator.rb => patches/frontend/controllers/spree/checkout_controller_patch.rb} (98%) diff --git a/lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb b/lib/patches/backend/controllers/spree/admin/base_controller_patch.rb similarity index 90% rename from lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb rename to lib/patches/backend/controllers/spree/admin/base_controller_patch.rb index f0017543..7bcccf63 100644 --- a/lib/decorators/backend/controllers/spree/admin/base_controller_decorator.rb +++ b/lib/patches/backend/controllers/spree/admin/base_controller_patch.rb @@ -2,7 +2,7 @@ module Spree module Admin - module BaseControllerDecorator + module BaseControllerPatch protected def model_class diff --git a/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb b/lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb similarity index 88% rename from lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb rename to lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb index 1628f53b..1674abd7 100644 --- a/lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb +++ b/lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Spree::Admin::Orders::CustomerDetailsControllerDecorator +module Spree::Admin::Orders::CustomerDetailsControllerPatch def self.prepended(base) base.before_action :check_authorization end diff --git a/lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb b/lib/patches/frontend/controllers/spree/checkout_controller_patch.rb similarity index 98% rename from lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb rename to lib/patches/frontend/controllers/spree/checkout_controller_patch.rb index a0f55a19..672cb08b 100644 --- a/lib/decorators/frontend/controllers/spree/checkout_controller_decorator.rb +++ b/lib/patches/frontend/controllers/spree/checkout_controller_patch.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Spree - module CheckoutControllerDecorator + module CheckoutControllerPatch def self.prepended(base) base.before_action :check_registration, except: [:registration, :update_registration] base.before_action :check_authorization diff --git a/solidus_auth_devise.gemspec b/solidus_auth_devise.gemspec index 17a4032a..9cdb8912 100644 --- a/solidus_auth_devise.gemspec +++ b/solidus_auth_devise.gemspec @@ -32,7 +32,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'devise', '~> 4.1' spec.add_dependency 'devise-encryptable', '0.2.0' spec.add_dependency 'solidus_core', ['>= 3', '< 5'] - spec.add_dependency 'solidus_support', '~> 0.5' + spec.add_dependency 'solidus_support', '~> 0.11' spec.add_development_dependency 'solidus_backend' spec.add_development_dependency 'solidus_frontend' From 15818b06ac5be891898bae7620371799be90c6a9 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Tue, 17 Dec 2024 12:53:18 +0100 Subject: [PATCH 18/49] Move Patches out of Spree namespace This names the patches such that they do not live in the Spree namespace. It also fixes a Rubocop offense. --- .../admin/base_controller_patch.rb | 2 +- .../customer_details_controller_patch.rb | 28 +++++++++++++++++++ .../customer_details_controller_patch.rb | 22 --------------- .../checkout_controller_patch.rb | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) rename lib/patches/backend/controllers/{spree => solidus_auth_devise}/admin/base_controller_patch.rb (93%) create mode 100644 lib/patches/backend/controllers/solidus_auth_devise/admin/orders/customer_details_controller_patch.rb delete mode 100644 lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb rename lib/patches/frontend/controllers/{spree => solidus_auth_devise}/checkout_controller_patch.rb (98%) diff --git a/lib/patches/backend/controllers/spree/admin/base_controller_patch.rb b/lib/patches/backend/controllers/solidus_auth_devise/admin/base_controller_patch.rb similarity index 93% rename from lib/patches/backend/controllers/spree/admin/base_controller_patch.rb rename to lib/patches/backend/controllers/solidus_auth_devise/admin/base_controller_patch.rb index 7bcccf63..2bf97c3e 100644 --- a/lib/patches/backend/controllers/spree/admin/base_controller_patch.rb +++ b/lib/patches/backend/controllers/solidus_auth_devise/admin/base_controller_patch.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Spree +module SolidusAuthDevise module Admin module BaseControllerPatch protected diff --git a/lib/patches/backend/controllers/solidus_auth_devise/admin/orders/customer_details_controller_patch.rb b/lib/patches/backend/controllers/solidus_auth_devise/admin/orders/customer_details_controller_patch.rb new file mode 100644 index 00000000..62b0ca75 --- /dev/null +++ b/lib/patches/backend/controllers/solidus_auth_devise/admin/orders/customer_details_controller_patch.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module SolidusAuthDevise + module Admin + module Orders + module CustomerDetailsControllerPatch + def self.prepended(base) + base.before_action :check_authorization + end + + private + + def check_authorization + load_order + session[:access_token] ||= params[:token] + + resource = @order + action = params[:action].to_sym + action = :edit if action == :show # show route renders :edit for this controller + + authorize! action, resource, session[:access_token] + end + + Spree::Admin::Orders::CustomerDetailsController.prepend self + end + end + end +end diff --git a/lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb b/lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb deleted file mode 100644 index 1674abd7..00000000 --- a/lib/patches/backend/controllers/spree/admin/orders/customer_details_controller_patch.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Spree::Admin::Orders::CustomerDetailsControllerPatch - def self.prepended(base) - base.before_action :check_authorization - end - - private - - def check_authorization - load_order - session[:access_token] ||= params[:token] - - resource = @order - action = params[:action].to_sym - action = :edit if action == :show # show route renders :edit for this controller - - authorize! action, resource, session[:access_token] - end - - Spree::Admin::Orders::CustomerDetailsController.prepend self -end diff --git a/lib/patches/frontend/controllers/spree/checkout_controller_patch.rb b/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb similarity index 98% rename from lib/patches/frontend/controllers/spree/checkout_controller_patch.rb rename to lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb index 672cb08b..ca28a1f9 100644 --- a/lib/patches/frontend/controllers/spree/checkout_controller_patch.rb +++ b/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module Spree +module SolidusAuthDevise module CheckoutControllerPatch def self.prepended(base) base.before_action :check_registration, except: [:registration, :update_registration] From e6dface2d43e292cef88b3a01ba9fc7efe0a852c Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Sat, 21 Dec 2024 23:45:19 +0100 Subject: [PATCH 19/49] Convert AuthenticationHelpers module to a patch This way, we don't need to load ApplicationController in a config.to_prepare block either. --- .rubocop_todo.yml | 2 -- .../application_controller_patch.rb | 29 +++++++++++++++++++ lib/solidus_auth_devise.rb | 2 -- lib/spree/auth/engine.rb | 2 -- lib/spree/authentication_helpers.rb | 27 ----------------- 5 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 app/patches/controllers/solidus_auth_devise/application_controller_patch.rb delete mode 100644 lib/spree/authentication_helpers.rb diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bf5aaba1..c30b3d35 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,7 +21,6 @@ Gemspec/OrderedDependencies: Layout/ArgumentAlignment: Exclude: - 'app/models/spree/user.rb' - - 'lib/spree/authentication_helpers.rb' - 'spec/controllers/spree/user_sessions_controller_spec.rb' - 'spec/features/sign_out_spec.rb' @@ -351,7 +350,6 @@ Style/GuardClause: - 'db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb' - 'db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb' - 'db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb' - - 'lib/spree/authentication_helpers.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). diff --git a/app/patches/controllers/solidus_auth_devise/application_controller_patch.rb b/app/patches/controllers/solidus_auth_devise/application_controller_patch.rb new file mode 100644 index 00000000..07b0bc40 --- /dev/null +++ b/app/patches/controllers/solidus_auth_devise/application_controller_patch.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module SolidusAuthDevise + module ApplicationControllerPatch + def self.prepended(base) + return unless base.respond_to?(:helper_method) + + base.send(:helper_method, :spree_current_user) + + return unless SolidusSupport.frontend_available? + + base.send(:helper_method, :spree_login_path) + base.send(:helper_method, :spree_signup_path) + base.send(:helper_method, :spree_logout_path) + end + + def spree_current_user + current_spree_user + end + + if SolidusSupport.frontend_available? + delegate :login_path, :signup_path, :logout_path, + to: :spree, + prefix: :spree + end + + ApplicationController.prepend self + end +end diff --git a/lib/solidus_auth_devise.rb b/lib/solidus_auth_devise.rb index f38cd2f4..56f69a53 100644 --- a/lib/solidus_auth_devise.rb +++ b/lib/solidus_auth_devise.rb @@ -10,5 +10,3 @@ require 'solidus_auth_devise/configuration' require 'solidus_auth_devise/version' require 'solidus_auth_devise/engine' - -require 'spree/authentication_helpers' diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index f0e98489..3d4db4a3 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -24,8 +24,6 @@ class Engine < Rails::Engine config.to_prepare do Spree::Auth::Engine.prepare_backend if SolidusSupport.backend_available? Spree::Auth::Engine.prepare_frontend if SolidusSupport.frontend_available? - - ApplicationController.include Spree::AuthenticationHelpers end def self.redirect_back_on_unauthorized? diff --git a/lib/spree/authentication_helpers.rb b/lib/spree/authentication_helpers.rb deleted file mode 100644 index d62a20c4..00000000 --- a/lib/spree/authentication_helpers.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module Spree - module AuthenticationHelpers - def self.included(receiver) - if receiver.send(:respond_to?, :helper_method) - receiver.send(:helper_method, :spree_current_user) - - if SolidusSupport.frontend_available? - receiver.send(:helper_method, :spree_login_path) - receiver.send(:helper_method, :spree_signup_path) - receiver.send(:helper_method, :spree_logout_path) - end - end - end - - def spree_current_user - current_spree_user - end - - if SolidusSupport.frontend_available? - delegate :login_path, :signup_path, :logout_path, - to: :spree, - prefix: :spree - end - end -end From 3f7cc794f14290a28e78836c20e745c096deb3dc Mon Sep 17 00:00:00 2001 From: Senem Soy Date: Wed, 30 Apr 2025 13:30:00 -0700 Subject: [PATCH 20/49] Use email regexp configured on Solidus This is to prevent a situation where an email is valid on the User, but invalid on the Order. This ensures that when an email is being copied from the User when an order is being created, there are no validation errors. Co-authored-by: Jared Norman --- .../solidus/auth/install/templates/config/initializers/devise.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb b/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb index ffe0f494..fb67406c 100644 --- a/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +++ b/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true Devise.secret_key = SecureRandom.hex(50).inspect +Devise.email_regexp = Spree::Config[:default_email_regexp] From ab212014b4dc7ecc7411d7ca53e1d417c41d515c Mon Sep 17 00:00:00 2001 From: Senem Soy Date: Thu, 1 May 2025 15:29:43 -0700 Subject: [PATCH 21/49] Fix default configuration for `Devise.secret_key` This is the default configuration Devise uses. What we had previously sets the `Devise.secret_key` to a random value at application boot that is not known across different instances of the same application. --- .../auth/install/templates/config/initializers/devise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb b/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb index fb67406c..3e1a9b0d 100644 --- a/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb +++ b/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true -Devise.secret_key = SecureRandom.hex(50).inspect +Devise.secret_key = '<%= SecureRandom.hex(64) %>' Devise.email_regexp = Spree::Config[:default_email_regexp] From 3eadb065d2624ed844d396578495264c930083e8 Mon Sep 17 00:00:00 2001 From: Senem Soy Date: Wed, 7 May 2025 13:19:51 -0700 Subject: [PATCH 22/49] Rename Devise initializer template This makes it obvious that this is an ERB template. Co-authored-by: Jared Norman --- lib/generators/solidus/auth/install/install_generator.rb | 2 +- .../templates/config/initializers/{devise.rb => devise.rb.erb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/generators/solidus/auth/install/templates/config/initializers/{devise.rb => devise.rb.erb} (100%) diff --git a/lib/generators/solidus/auth/install/install_generator.rb b/lib/generators/solidus/auth/install/install_generator.rb index c6ef547e..a569bc6a 100644 --- a/lib/generators/solidus/auth/install/install_generator.rb +++ b/lib/generators/solidus/auth/install/install_generator.rb @@ -14,7 +14,7 @@ class InstallGenerator < Rails::Generators::Base source_root "#{__dir__}/templates" def generate_devise_key - template 'config/initializers/devise.rb', 'config/initializers/devise.rb', skip: true + template 'config/initializers/devise.rb.erb', 'config/initializers/devise.rb', skip: true end def add_migrations diff --git a/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb b/lib/generators/solidus/auth/install/templates/config/initializers/devise.rb.erb similarity index 100% rename from lib/generators/solidus/auth/install/templates/config/initializers/devise.rb rename to lib/generators/solidus/auth/install/templates/config/initializers/devise.rb.erb From 2a16e360d00ccddfb2f2d4be706dbf227488d377 Mon Sep 17 00:00:00 2001 From: Senem Soy Date: Fri, 6 Jun 2025 10:08:04 -0700 Subject: [PATCH 23/49] Address checkout spec race conditions We want to avoid clicking the same 'Save and Continue' button three times in a row, so we've added assertions that make sure we have navigated to the next page before trying to click it again. Co-authored-by: Jared Norman --- spec/features/checkout_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index 3221aaae..2453ca22 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -63,7 +63,12 @@ fill_addresses_fields_with(address) click_button 'Save and Continue' + expect(page).to have_content 'UPS Ground' + click_button 'Save and Continue' + + expect(page).to have_content(/Payment Information/i) + click_button 'Save and Continue' click_button 'Place Order' @@ -89,7 +94,12 @@ fill_addresses_fields_with(address) click_button 'Save and Continue' + expect(page).to have_content 'UPS Ground' + click_button 'Save and Continue' + + expect(page).to have_content(/Payment Information/i) + click_button 'Save and Continue' click_button 'Place Order' @@ -145,9 +155,15 @@ expect(page).to have_text 'You have signed up successfully.' fill_addresses_fields_with(address) + click_button 'Save and Continue' + expect(page).to have_content 'UPS Ground' + click_button 'Save and Continue' + + expect(page).to have_content(/Payment Information/i) + click_button 'Save and Continue' click_button 'Place Order' From b68d80d910d408e635eae7a6cbe09b1070994657 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 15 May 2025 15:20:31 +0200 Subject: [PATCH 24/49] Fix SQLite version depending on Rails version --- Gemfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 6d2cfa48..3897a8d6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,6 +7,9 @@ branch = ENV.fetch('SOLIDUS_BRANCH', 'main') gem 'solidus', github: 'solidusio/solidus', branch: branch gem 'solidus_backend', github: 'solidusio/solidus', branch: branch +rails_requirement_string = ENV.fetch('RAILS_VERSION', '~> 7.0') +gem 'rails', rails_requirement_string + # The solidus_frontend gem has been pulled out since v3.2 if branch >= 'v3.2' gem 'solidus_frontend' @@ -22,7 +25,10 @@ when 'mysql' when 'postgresql' gem 'pg' else - gem 'sqlite3', '~> 1.4' + rails_version = Gem::Requirement.new(rails_requirement_string).requirements[0][1] + sqlite_version = rails_version < Gem::Version.new(7.2) ? "~> 1.4" : "~> 2.0" + + gem 'sqlite3', sqlite_version end if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') From b56e7590a31a9bf081f16411ef140317181f3589 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 15 May 2025 15:26:15 +0200 Subject: [PATCH 25/49] Use standard rubocop configuration --- .rubocop.yml | 8 - .rubocop_todo.yml | 395 ---------------------------------------------- 2 files changed, 403 deletions(-) delete mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml index 57ddb8ea..6207a647 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,2 @@ -inherit_from: .rubocop_todo.yml - require: - solidus_dev_support/rubocop - -AllCops: - NewCops: disable - -Gemspec/RequiredRubyVersion: - Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml deleted file mode 100644 index c30b3d35..00000000 --- a/.rubocop_todo.yml +++ /dev/null @@ -1,395 +0,0 @@ -# This configuration was generated by -# `rubocop --auto-gen-config` -# on 2022-09-09 11:12:37 UTC using RuboCop version 1.36.0. -# The point is for the user to remove these configuration records -# one by one as the offenses are removed from the code base. -# Note that changes in the inspected code, or installation of new -# versions of RuboCop, may require this file to be generated again. - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemspec -Gemspec/OrderedDependencies: - Exclude: - - 'solidus_auth_devise.gemspec' - -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_argument, with_fixed_indentation -Layout/ArgumentAlignment: - Exclude: - - 'app/models/spree/user.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/features/sign_out_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/ElseAlignment: - Exclude: - - 'config/initializers/devise.rb' - - 'spec/support/features/fill_addresses_fields.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. -Layout/EmptyLineBetweenDefs: - Exclude: - - 'lib/spree/auth/engine.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLines: - Exclude: - - 'lib/spree/auth/engine.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleAlignWith, Severity. -# SupportedStylesAlignWith: keyword, variable, start_of_line -Layout/EndAlignment: - Exclude: - - 'config/initializers/devise.rb' - - 'spec/support/features/fill_addresses_fields.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Width, AllowedPatterns, IgnoredPatterns. -Layout/IndentationWidth: - Exclude: - - 'config/initializers/devise.rb' - - 'spec/features/admin/sign_out_spec.rb' - - 'spec/features/sign_out_spec.rb' - - 'spec/support/features/fill_addresses_fields.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/features/admin/password_reset_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAfterComma: - Exclude: - - 'spec/features/account_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceBeforeComma: - Exclude: - - 'spec/features/account_spec.rb' - -# Offense count: 1 -# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods. -Lint/AmbiguousBlockAssociation: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -RSpec/BeEql: - Exclude: - - 'spec/models/user_spec.rb' - -# Offense count: 1 -RSpec/BeforeAfterAll: - Exclude: - - 'spec/models/user_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Capybara/CurrentPathExpectation: - Exclude: - - 'spec/features/admin/sign_in_spec.rb' - - 'spec/features/sign_in_spec.rb' - -# Offense count: 69 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnabledMethods. -RSpec/Capybara/FeatureMethods: - Exclude: - - 'spec/features/account_spec.rb' - - 'spec/features/admin/password_reset_spec.rb' - - 'spec/features/admin/products_spec.rb' - - 'spec/features/admin/sign_in_spec.rb' - - 'spec/features/admin/sign_out_spec.rb' - - 'spec/features/admin_permissions_spec.rb' - - 'spec/features/change_email_spec.rb' - - 'spec/features/checkout_spec.rb' - - 'spec/features/confirmation_spec.rb' - - 'spec/features/order_spec.rb' - - 'spec/features/password_reset_spec.rb' - - 'spec/features/sign_in_spec.rb' - - 'spec/features/sign_out_spec.rb' - - 'spec/features/sign_up_spec.rb' - - 'spec/requests/spree/frontend/user_update_spec.rb' - -# Offense count: 12 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ContextMethod: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - - 'spec/controllers/spree/user_passwords_controller_spec.rb' - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/controllers/spree/users_controller_spec.rb' - - 'spec/models/order_spec.rb' - -# Offense count: 26 -# Configuration parameters: Prefixes. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - - 'spec/controllers/spree/user_passwords_controller_spec.rb' - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/controllers/spree/users_controller_spec.rb' - - 'spec/features/account_spec.rb' - - 'spec/features/admin/password_reset_spec.rb' - - 'spec/features/admin/products_spec.rb' - - 'spec/features/admin_permissions_spec.rb' - - 'spec/mailers/user_mailer_spec.rb' - - 'spec/models/order_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/requests/spree/frontend/user_update_spec.rb' - -# Offense count: 6 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: SkipBlocks, EnforcedStyle. -# SupportedStyles: described_class, explicit -RSpec/DescribedClass: - Exclude: - - 'spec/mailers/user_mailer_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterFinalLet: - Exclude: - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/models/order_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterSubject: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords. -RSpec/ExampleWording: - Exclude: - - 'spec/features/sign_in_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ExpectActual: - Exclude: - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: method_call, block -RSpec/ExpectChange: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - -# Offense count: 3 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Exclude: - - 'spec/mailers/user_mailer_spec.rb' - - 'spec/models/order_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 15 -# Configuration parameters: AssignmentOnly. -RSpec/InstanceVariable: - Exclude: - - 'spec/controllers/spree/admin/user_passwords_controller_spec.rb' - - 'spec/controllers/spree/user_passwords_controller_spec.rb' - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/features/admin/sign_in_spec.rb' - - 'spec/features/checkout_spec.rb' - - 'spec/features/sign_in_spec.rb' - - 'spec/mailers/user_mailer_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -RSpec/LeadingSubject: - Exclude: - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - -# Offense count: 5 -RSpec/LetSetup: - Exclude: - - 'spec/features/admin/password_reset_spec.rb' - - 'spec/features/confirmation_spec.rb' - - 'spec/features/password_reset_spec.rb' - -# Offense count: 6 -# Configuration parameters: . -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - EnforcedStyle: receive - -# Offense count: 39 -RSpec/MultipleExpectations: - Max: 5 - -# Offense count: 26 -# Configuration parameters: IgnoreSharedExamples. -RSpec/NamedSubject: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - - 'spec/controllers/spree/user_registrations_controller_spec.rb' - - 'spec/controllers/spree/user_sessions_controller_spec.rb' - - 'spec/controllers/spree/users_controller_spec.rb' - -# Offense count: 30 -RSpec/NestedGroups: - Max: 5 - -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: not_to, to_not -RSpec/NotToNot: - Exclude: - - 'spec/controllers/spree/users_controller_spec.rb' - - 'spec/features/admin/password_reset_spec.rb' - - 'spec/features/password_reset_spec.rb' - -# Offense count: 2 -RSpec/RepeatedExampleGroupDescription: - Exclude: - - 'spec/models/user_spec.rb' - -# Offense count: 7 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: and_return, block -RSpec/ReturnFromStub: - Exclude: - - 'spec/controllers/spree/checkout_controller_spec.rb' - - 'spec/controllers/spree/products_controller_spec.rb' - - 'spec/models/order_spec.rb' - -# Offense count: 1 -RSpec/StubbedMock: - Exclude: - - 'spec/models/user_spec.rb' - -# Offense count: 2 -# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. -RSpec/VerifiedDoubles: - Exclude: - - 'spec/features/confirmation_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 12 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Include. -# Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb -Rails/Output: - Exclude: - - 'db/default/users.rb' - -# Offense count: 8 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Exclude: - - 'lib/controllers/backend/spree/admin/user_passwords_controller.rb' - - 'lib/controllers/backend/spree/admin/user_sessions_controller.rb' - - 'lib/controllers/frontend/spree/user_confirmations_controller.rb' - - 'lib/controllers/frontend/spree/user_passwords_controller.rb' - - 'lib/controllers/frontend/spree/user_registrations_controller.rb' - - 'lib/controllers/frontend/spree/user_sessions_controller.rb' - - 'lib/controllers/frontend/spree/users_controller.rb' - - 'lib/decorators/backend/controllers/spree/admin/orders/customer_details_controller_decorator.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: compact, expanded -Style/EmptyMethod: - Exclude: - - 'lib/controllers/backend/spree/admin/user_sessions_controller.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/ExpandPathArguments: - Exclude: - - 'spec/support/confirm_helpers.rb' - -# Offense count: 3 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - 'db/default/users.rb' - -# Offense count: 6 -# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. -Style/GuardClause: - Exclude: - - 'db/migrate/20101026184949_create_users.rb' - - 'db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb' - - 'db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb' - - 'db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantFileExtensionInRequire: - Exclude: - - 'db/seeds.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'spec/features/checkout_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, explicit -Style/RescueStandardError: - Exclude: - - 'spec/requests/spree/frontend/user_update_spec.rb' - -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowModifier. -Style/SoleNestedConditional: - Exclude: - - 'config/initializers/warden.rb' - -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: Mode. -Style/StringConcatenation: - Exclude: - - 'app/models/spree/user.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns. -# URISchemes: http, https -Layout/LineLength: - Max: 227 From eaba0e4370a03d10a6064466a9197c330bb92c64 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 15 May 2025 15:26:33 +0200 Subject: [PATCH 26/49] standardrb --fix --- Gemfile | 44 ++--- Rakefile | 8 +- app/models/spree/user.rb | 4 +- config/initializers/devise.rb | 10 +- config/routes.rb | 62 +++---- db/default/users.rb | 10 +- db/migrate/20101026184949_create_users.rb | 36 ++-- ...set_password_token_index_to_spree_users.rb | 4 +- db/seeds.rb | 2 +- .../spree/admin/user_passwords_controller.rb | 6 +- .../spree/admin/user_sessions_controller.rb | 14 +- .../spree/user_confirmations_controller.rb | 2 +- .../spree/user_passwords_controller.rb | 4 +- .../spree/user_registrations_controller.rb | 4 +- .../spree/user_sessions_controller.rb | 12 +- .../frontend/spree/users_controller.rb | 9 +- .../solidus/auth/install/install_generator.rb | 14 +- .../install/install_generator.rb | 4 +- .../checkout_controller_patch.rb | 10 +- lib/solidus_auth_devise.rb | 18 +- lib/solidus_auth_devise/configuration.rb | 2 +- lib/solidus_auth_devise/engine.rb | 2 +- lib/solidus_auth_devise/version.rb | 2 +- lib/spree/auth/engine.rb | 17 +- lib/spree/auth/version.rb | 2 +- lib/tasks/auth.rake | 2 +- solidus_auth_devise.gemspec | 41 +++-- .../spree/admin/base_controller_spec.rb | 16 +- .../admin/user_passwords_controller_spec.rb | 12 +- .../admin/user_sessions_controller_spec.rb | 8 +- .../controllers/spree/base_controller_spec.rb | 16 +- .../spree/checkout_controller_spec.rb | 114 ++++++------- .../spree/products_controller_spec.rb | 10 +- .../spree/user_passwords_controller_spec.rb | 32 ++-- .../user_registrations_controller_spec.rb | 53 +++--- .../spree/user_sessions_controller_spec.rb | 36 ++-- .../spree/users_controller_spec.rb | 52 +++--- spec/features/account_spec.rb | 72 ++++---- spec/features/admin/password_reset_spec.rb | 60 ++++--- spec/features/admin/products_spec.rb | 6 +- spec/features/admin/sign_in_spec.rb | 50 +++--- spec/features/admin/sign_out_spec.rb | 28 ++-- spec/features/admin_permissions_spec.rb | 36 ++-- spec/features/change_email_spec.rb | 24 +-- spec/features/checkout_spec.rb | 158 +++++++++--------- spec/features/confirmation_spec.rb | 18 +- spec/features/order_spec.rb | 56 +++---- spec/features/password_reset_spec.rb | 26 +-- spec/features/sign_in_spec.rb | 50 +++--- spec/features/sign_out_spec.rb | 26 +-- spec/features/sign_up_spec.rb | 30 ++-- spec/mailers/user_mailer_spec.rb | 24 +-- spec/models/order_spec.rb | 8 +- spec/models/user_spec.rb | 20 +-- .../spree/frontend/user_update_spec.rb | 12 +- spec/spec_helper.rb | 12 +- spec/support/authentication_helpers.rb | 8 +- spec/support/confirm_helpers.rb | 4 +- .../support/features/fill_addresses_fields.rb | 4 +- spec/support/spree.rb | 8 +- 60 files changed, 717 insertions(+), 717 deletions(-) diff --git a/Gemfile b/Gemfile index 3897a8d6..ac76ebf0 100644 --- a/Gemfile +++ b/Gemfile @@ -1,47 +1,47 @@ # frozen_string_literal: true -source 'https://rubygems.org' +source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -branch = ENV.fetch('SOLIDUS_BRANCH', 'main') -gem 'solidus', github: 'solidusio/solidus', branch: branch -gem 'solidus_backend', github: 'solidusio/solidus', branch: branch +branch = ENV.fetch("SOLIDUS_BRANCH", "main") +gem "solidus", github: "solidusio/solidus", branch: branch +gem "solidus_backend", github: "solidusio/solidus", branch: branch -rails_requirement_string = ENV.fetch('RAILS_VERSION', '~> 7.0') -gem 'rails', rails_requirement_string +rails_requirement_string = ENV.fetch("RAILS_VERSION", "~> 7.0") +gem "rails", rails_requirement_string # The solidus_frontend gem has been pulled out since v3.2 -if branch >= 'v3.2' - gem 'solidus_frontend' -elsif branch == 'main' - gem 'solidus_frontend', github: 'solidusio/solidus_frontend' +if branch >= "v3.2" + gem "solidus_frontend" +elsif branch == "main" + gem "solidus_frontend", github: "solidusio/solidus_frontend" else - gem 'solidus_frontend', github: 'solidusio/solidus', branch: branch + gem "solidus_frontend", github: "solidusio/solidus", branch: branch end -case ENV.fetch('DB', nil) -when 'mysql' - gem 'mysql2' -when 'postgresql' - gem 'pg' +case ENV.fetch("DB", nil) +when "mysql" + gem "mysql2" +when "postgresql" + gem "pg" else rails_version = Gem::Requirement.new(rails_requirement_string).requirements[0][1] - sqlite_version = rails_version < Gem::Version.new(7.2) ? "~> 1.4" : "~> 2.0" + sqlite_version = (rails_version < Gem::Version.new(7.2)) ? "~> 1.4" : "~> 2.0" - gem 'sqlite3', sqlite_version + gem "sqlite3", sqlite_version end -if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3') +if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3") # While we still support Ruby < 3 we need to workaround a limitation in # the 'async' gem that relies on the latest ruby, since RubyGems doesn't # resolve gems based on the required ruby version. - gem 'async', '< 3', require: false + gem "async", "< 3", require: false end # 'net/smtp' is required by 'mail', see: # - https://github.com/ruby/net-protocol/issues/10 # - https://stackoverflow.com/a/72474475 -gem 'net-smtp', require: false +gem "net-smtp", require: false gemspec @@ -50,4 +50,4 @@ gemspec # # We use `send` instead of calling `eval_gemfile` to work around an issue with # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658. -send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local' +send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local" diff --git a/Rakefile b/Rakefile index 2640ab94..1f3b5538 100644 --- a/Rakefile +++ b/Rakefile @@ -1,11 +1,11 @@ # frozen_string_literal: true # Don't build a dummy app with solidus_bolt enabled -ENV['SKIP_SOLIDUS_BOLT'] = 'true' +ENV["SKIP_SOLIDUS_BOLT"] = "true" -require 'bundler/gem_tasks' +require "bundler/gem_tasks" -require 'solidus_dev_support/rake_tasks' +require "solidus_dev_support/rake_tasks" SolidusDevSupport::RakeTasks.install(user_class: "Spree::User") -task default: 'extension:specs' +task default: "extension:specs" diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index ab0fd927..9c53e602 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -5,7 +5,7 @@ class User < Spree::Base include UserMethods devise :database_authenticatable, :registerable, :recoverable, - :rememberable, :trackable, :validatable, :encryptable + :rememberable, :trackable, :validatable, :encryptable devise :confirmable if Spree::Auth::Config[:confirmable] if defined?(Spree::SoftDeletable) @@ -35,7 +35,7 @@ def self.admin_created? end def admin? - has_spree_role?('admin') + has_spree_role?("admin") end def confirmed? diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 522ce5dd..e49f81a8 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -5,16 +5,16 @@ Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in DeviseMailer. - config.mailer_sender = 'please-change-me@config-initializers-devise.com' + config.mailer_sender = "please-change-me@config-initializers-devise.com" # Configure the class responsible to send e-mails. - config.mailer = 'Spree::UserMailer' + config.mailer = "Spree::UserMailer" # ==> ORM configuration # Load and configure the ORM. Supports :active_record (default) and # :mongoid (bson_ext recommended) by default. Other ORMs may be # available as additional gems. - require 'devise/orm/active_record' + require "devise/orm/active_record" # ==> Configuration for any authentication mechanism # Configure which keys are used when authenticating an user. By default is @@ -34,13 +34,13 @@ # config.http_authenticatable_on_xhr = false # The realm used in Http Basic Authentication - config.http_authentication_realm = 'Spree Application' + config.http_authentication_realm = "Spree Application" # ==> Configuration for :database_authenticatable # For bcrypt, this is the cost for hashing the password and defaults to 10. If # using other encryptors, it sets how many times you want the password re-encrypted. config.stretches = 20 - config.encryptor = 'authlogic_sha512' + config.encryptor = "authlogic_sha512" # Setup a pepper to generate the encrypted password. config.pepper = if Rails.configuration.respond_to?(:secret_token) && Rails.configuration.secret_token.present? diff --git a/config/routes.rb b/config/routes.rb index 39613b7d..18d3c3c2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,15 +3,15 @@ Spree::Core::Engine.routes.draw do if SolidusSupport.frontend_available? && Spree::Auth::Config.draw_frontend_routes devise_for(:spree_user, { - class_name: 'Spree::User', + class_name: "Spree::User", controllers: { - sessions: 'spree/user_sessions', - registrations: 'spree/user_registrations', - passwords: 'spree/user_passwords', - confirmations: 'spree/user_confirmations' + sessions: "spree/user_sessions", + registrations: "spree/user_registrations", + passwords: "spree/user_passwords", + confirmations: "spree/user_confirmations" }, skip: [:unlocks, :omniauth_callbacks], - path_names: { sign_out: 'logout' }, + path_names: {sign_out: "logout"}, path_prefix: :user, router_name: :spree }) @@ -19,48 +19,48 @@ resources :users, only: [:edit, :update] devise_scope :spree_user do - get '/login', to: 'user_sessions#new', as: :login - post '/login', to: 'user_sessions#create', as: :create_new_session - match '/logout', to: 'user_sessions#destroy', as: :logout, via: Devise.sign_out_via - get '/signup', to: 'user_registrations#new', as: :signup - post '/signup', to: 'user_registrations#create', as: :registration - get '/password/recover', to: 'user_passwords#new', as: :recover_password - post '/password/recover', to: 'user_passwords#create', as: :reset_password - get '/password/change', to: 'user_passwords#edit', as: :edit_password - put '/password/change', to: 'user_passwords#update', as: :update_password - get '/confirm', to: 'user_confirmations#show', as: :confirmation if Spree::Auth::Config[:confirmable] + get "/login", to: "user_sessions#new", as: :login + post "/login", to: "user_sessions#create", as: :create_new_session + match "/logout", to: "user_sessions#destroy", as: :logout, via: Devise.sign_out_via + get "/signup", to: "user_registrations#new", as: :signup + post "/signup", to: "user_registrations#create", as: :registration + get "/password/recover", to: "user_passwords#new", as: :recover_password + post "/password/recover", to: "user_passwords#create", as: :reset_password + get "/password/change", to: "user_passwords#edit", as: :edit_password + put "/password/change", to: "user_passwords#update", as: :update_password + get "/confirm", to: "user_confirmations#show", as: :confirmation if Spree::Auth::Config[:confirmable] end - get '/checkout/registration', to: 'checkout#registration', as: :checkout_registration - put '/checkout/registration', to: 'checkout#update_registration', as: :update_checkout_registration + get "/checkout/registration", to: "checkout#registration", as: :checkout_registration + put "/checkout/registration", to: "checkout#update_registration", as: :update_checkout_registration - resource :account, controller: 'users' + resource :account, controller: "users" end if SolidusSupport.backend_available? && Spree::Auth::Config.draw_backend_routes namespace :admin do devise_for(:spree_user, { - class_name: 'Spree::User', + class_name: "Spree::User", singular: :spree_user, skip: :all, - path_names: { sign_out: 'logout' }, + path_names: {sign_out: "logout"}, controllers: { - sessions: 'spree/admin/user_sessions', - passwords: 'spree/admin/user_passwords' + sessions: "spree/admin/user_sessions", + passwords: "spree/admin/user_passwords" }, router_name: :spree }) devise_scope :spree_user do - get '/authorization_failure', to: 'user_sessions#authorization_failure', as: :unauthorized - get '/login', to: 'user_sessions#new', as: :login - post '/login', to: 'user_sessions#create', as: :create_new_session - match '/logout', to: 'user_sessions#destroy', as: :logout, via: Devise.sign_out_via + get "/authorization_failure", to: "user_sessions#authorization_failure", as: :unauthorized + get "/login", to: "user_sessions#new", as: :login + post "/login", to: "user_sessions#create", as: :create_new_session + match "/logout", to: "user_sessions#destroy", as: :logout, via: Devise.sign_out_via - get '/password/recover', to: 'user_passwords#new', as: :recover_password - post '/password/recover', to: 'user_passwords#create', as: :reset_password - get '/password/change', to: 'user_passwords#edit', as: :edit_password - put '/password/change', to: 'user_passwords#update', as: :update_password + get "/password/recover", to: "user_passwords#new", as: :recover_password + post "/password/recover", to: "user_passwords#create", as: :reset_password + get "/password/change", to: "user_passwords#edit", as: :edit_password + put "/password/change", to: "user_passwords#update", as: :update_password end end end diff --git a/db/default/users.rb b/db/default/users.rb index 2e034bd8..0b40f0f4 100644 --- a/db/default/users.rb +++ b/db/default/users.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true -admin_role = Spree::Role.find_or_create_by(name: 'admin') +admin_role = Spree::Role.find_or_create_by(name: "admin") if Spree::User.admin.any? - puts 'No admin user created.' + puts "No admin user created." return end -email = ENV['ADMIN_EMAIL'] || 'admin@example.com' -password = ENV['ADMIN_PASSWORD'] || 'test123' +email = ENV["ADMIN_EMAIL"] || "admin@example.com" +password = ENV["ADMIN_PASSWORD"] || "test123" puts "Creating admin user with:" puts " - email: #{email}" @@ -24,7 +24,7 @@ password: password, password_confirmation: password, email: email, - login: email, + login: email ) if admin.save diff --git a/db/migrate/20101026184949_create_users.rb b/db/migrate/20101026184949_create_users.rb index 2647585d..c5d1809a 100644 --- a/db/migrate/20101026184949_create_users.rb +++ b/db/migrate/20101026184949_create_users.rb @@ -4,27 +4,27 @@ class CreateUsers < SolidusSupport::Migration[4.2] def up unless table_exists?("spree_users") create_table "spree_users", force: true do |t| - t.string "crypted_password", limit: 128 - t.string "salt", limit: 128 - t.string "email" - t.string "remember_token" - t.string "remember_token_expires_at" - t.string "persistence_token" - t.string "single_access_token" - t.string "perishable_token" - t.integer "login_count", default: 0, null: false - t.integer "failed_login_count", default: 0, null: false + t.string "crypted_password", limit: 128 + t.string "salt", limit: 128 + t.string "email" + t.string "remember_token" + t.string "remember_token_expires_at" + t.string "persistence_token" + t.string "single_access_token" + t.string "perishable_token" + t.integer "login_count", default: 0, null: false + t.integer "failed_login_count", default: 0, null: false t.datetime "last_request_at" t.datetime "current_login_at" t.datetime "last_login_at" - t.string "current_login_ip" - t.string "last_login_ip" - t.string "login" - t.integer "ship_address_id" - t.integer "bill_address_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "openid_identifier" + t.string "current_login_ip" + t.string "last_login_ip" + t.string "login" + t.integer "ship_address_id" + t.integer "bill_address_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "openid_identifier" end end end diff --git a/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb b/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb index 0c80795a..e6e69919 100644 --- a/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +++ b/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb @@ -8,7 +8,7 @@ class AddResetPasswordTokenIndexToSpreeUsers < SolidusSupport::Migration[4.2] # standard name + "_solidus_auth_devise"; the length is 61 chars which is # still OK for Sqlite, mySQL and Postgres. def custom_index_name - 'index_spree_users_on_reset_password_token_solidus_auth_devise' + "index_spree_users_on_reset_password_token_solidus_auth_devise" end def default_index_exists? @@ -21,7 +21,7 @@ def custom_index_exists? def up Spree::User.reset_column_information - if Spree::User.column_names.include?('reset_password_token') && !default_index_exists? && !custom_index_exists? + if Spree::User.column_names.include?("reset_password_token") && !default_index_exists? && !custom_index_exists? add_index :spree_users, :reset_password_token, unique: true, name: custom_index_name end end diff --git a/db/seeds.rb b/db/seeds.rb index af76ec94..219054d4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require_relative 'default/users.rb' +require_relative "default/users" diff --git a/lib/controllers/backend/spree/admin/user_passwords_controller.rb b/lib/controllers/backend/spree/admin/user_passwords_controller.rb index 9c520748..fc5ce69a 100644 --- a/lib/controllers/backend/spree/admin/user_passwords_controller.rb +++ b/lib/controllers/backend/spree/admin/user_passwords_controller.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true class Spree::Admin::UserPasswordsController < Devise::PasswordsController - helper 'spree/base' + helper "spree/base" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common include Spree::Core::ControllerHelpers::Store - helper 'spree/admin/navigation' - layout 'spree/layouts/admin' + helper "spree/admin/navigation" + layout "spree/layouts/admin" skip_before_action :require_no_authentication, only: [:create] diff --git a/lib/controllers/backend/spree/admin/user_sessions_controller.rb b/lib/controllers/backend/spree/admin/user_sessions_controller.rb index 366c281f..9deced44 100644 --- a/lib/controllers/backend/spree/admin/user_sessions_controller.rb +++ b/lib/controllers/backend/spree/admin/user_sessions_controller.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true class Spree::Admin::UserSessionsController < Devise::SessionsController - helper 'spree/base' + helper "spree/base" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common include Spree::Core::ControllerHelpers::Store - helper 'spree/admin/navigation' - layout 'spree/layouts/admin' + helper "spree/admin/navigation" + layout "spree/layouts/admin" def create authenticate_spree_user! @@ -16,16 +16,16 @@ def create if spree_user_signed_in? respond_to do |format| format.html { - flash[:success] = I18n.t('spree.logged_in_succesfully') + flash[:success] = I18n.t("spree.logged_in_succesfully") redirect_back_or_default(after_sign_in_path_for(spree_current_user)) } format.js { user = resource.record - render json: { ship_address: user.ship_address, bill_address: user.bill_address }.to_json + render json: {ship_address: user.ship_address, bill_address: user.bill_address}.to_json } end else - flash.now[:error] = t('devise.failure.invalid') + flash.now[:error] = t("devise.failure.invalid") render :new end end @@ -49,7 +49,7 @@ def set_user_language_locale_key end def accurate_title - I18n.t('spree.login') + I18n.t("spree.login") end def redirect_back_or_default(default) diff --git a/lib/controllers/frontend/spree/user_confirmations_controller.rb b/lib/controllers/frontend/spree/user_confirmations_controller.rb index 41bace4a..8b05cf37 100644 --- a/lib/controllers/frontend/spree/user_confirmations_controller.rb +++ b/lib/controllers/frontend/spree/user_confirmations_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Spree::UserConfirmationsController < Devise::ConfirmationsController - helper 'spree/base', 'spree/store' + helper "spree/base", "spree/store" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common diff --git a/lib/controllers/frontend/spree/user_passwords_controller.rb b/lib/controllers/frontend/spree/user_passwords_controller.rb index 80d24d53..946a3ea2 100644 --- a/lib/controllers/frontend/spree/user_passwords_controller.rb +++ b/lib/controllers/frontend/spree/user_passwords_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Spree::UserPasswordsController < Devise::PasswordsController - helper 'spree/base', 'spree/store' + helper "spree/base", "spree/store" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common @@ -44,7 +44,7 @@ def update protected def translation_scope - 'devise.user_passwords' + "devise.user_passwords" end def new_session_path(resource_name) diff --git a/lib/controllers/frontend/spree/user_registrations_controller.rb b/lib/controllers/frontend/spree/user_registrations_controller.rb index b1b42195..567ebdf5 100644 --- a/lib/controllers/frontend/spree/user_registrations_controller.rb +++ b/lib/controllers/frontend/spree/user_registrations_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Spree::UserRegistrationsController < Devise::RegistrationsController - helper 'spree/base', 'spree/store' + helper "spree/base", "spree/store" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common @@ -29,7 +29,7 @@ def create protected def translation_scope - 'devise.user_registrations' + "devise.user_registrations" end def check_permissions diff --git a/lib/controllers/frontend/spree/user_sessions_controller.rb b/lib/controllers/frontend/spree/user_sessions_controller.rb index dfa67d99..dab19350 100644 --- a/lib/controllers/frontend/spree/user_sessions_controller.rb +++ b/lib/controllers/frontend/spree/user_sessions_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Spree::UserSessionsController < Devise::SessionsController - helper 'spree/base', 'spree/store' + helper "spree/base", "spree/store" include Spree::Core::ControllerHelpers::Auth include Spree::Core::ControllerHelpers::Common @@ -18,7 +18,7 @@ def create if spree_user_signed_in? respond_to do |format| format.html do - flash[:success] = I18n.t('spree.logged_in_succesfully') + flash[:success] = I18n.t("spree.logged_in_succesfully") redirect_back_or_default(after_sign_in_path_for(spree_current_user)) end format.js { render success_json } @@ -26,11 +26,11 @@ def create else respond_to do |format| format.html do - flash.now[:error] = t('devise.failure.invalid') + flash.now[:error] = t("devise.failure.invalid") render :new end format.js do - render json: { error: t('devise.failure.invalid') }, + render json: {error: t("devise.failure.invalid")}, status: :unprocessable_entity end end @@ -40,13 +40,13 @@ def create protected def translation_scope - 'devise.user_sessions' + "devise.user_sessions" end private def accurate_title - I18n.t('spree.login') + I18n.t("spree.login") end def redirect_back_or_default(default) diff --git a/lib/controllers/frontend/spree/users_controller.rb b/lib/controllers/frontend/spree/users_controller.rb index 66db9743..531c4bd6 100644 --- a/lib/controllers/frontend/spree/users_controller.rb +++ b/lib/controllers/frontend/spree/users_controller.rb @@ -4,11 +4,12 @@ class Spree::UsersController < Spree::StoreController skip_before_action :set_current_order, only: :show, raise: false prepend_before_action :authorize_actions, only: :new - def new; end + def new + end def show load_object - @orders = @user.orders.complete.order('completed_at desc') + @orders = @user.orders.complete.order("completed_at desc") end def create @@ -43,7 +44,7 @@ def update bypass_sign_in(@user) end end - redirect_to redirect_url, notice: I18n.t('spree.account_updated') + redirect_to redirect_url, notice: I18n.t("spree.account_updated") else render :edit end @@ -65,6 +66,6 @@ def authorize_actions end def accurate_title - I18n.t('spree.my_account') + I18n.t("spree.my_account") end end diff --git a/lib/generators/solidus/auth/install/install_generator.rb b/lib/generators/solidus/auth/install/install_generator.rb index a569bc6a..a3805aeb 100644 --- a/lib/generators/solidus/auth/install/install_generator.rb +++ b/lib/generators/solidus/auth/install/install_generator.rb @@ -14,12 +14,12 @@ class InstallGenerator < Rails::Generators::Base source_root "#{__dir__}/templates" def generate_devise_key - template 'config/initializers/devise.rb.erb', 'config/initializers/devise.rb', skip: true + template "config/initializers/devise.rb.erb", "config/initializers/devise.rb", skip: true end def add_migrations - admin_email = options[:admin_email] || (options[:interactive] && ask("Email:", default: 'admin@example.com')) - admin_password = options[:admin_password] || (options[:interactive] && ask("Password:", default: 'test123')) + admin_email = options[:admin_email] || (options[:interactive] && ask("Email:", default: "admin@example.com")) + admin_password = options[:admin_password] || (options[:interactive] && ask("Password:", default: "test123")) options = [] options << "ADMIN_EMAIL=#{admin_email}" if admin_email @@ -30,12 +30,12 @@ def add_migrations def run_migrations if options[:skip_migrations] || - options[:auto_run_migrations] == false || # exclude nil - options[:interactive] && no?('Would you like to run the migrations now?') + options[:auto_run_migrations] == false || # exclude nil + options[:interactive] && no?("Would you like to run the migrations now?") - say_status :skip, 'Skipping rake db:migrate, don\'t forget to run it!', :yellow + say_status :skip, "Skipping rake db:migrate, don't forget to run it!", :yellow else - rake 'db:migrate' + rake "db:migrate" end end end diff --git a/lib/generators/solidus_auth_devise/install/install_generator.rb b/lib/generators/solidus_auth_devise/install/install_generator.rb index 2cc5aa2c..2459d8a1 100644 --- a/lib/generators/solidus_auth_devise/install/install_generator.rb +++ b/lib/generators/solidus_auth_devise/install/install_generator.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative '../../solidus/auth/install/install_generator' +require_relative "../../solidus/auth/install/install_generator" module SolidusAuthDevise module Generators @@ -11,7 +11,7 @@ class InstallGenerator < Rails::Generators::Base end def forward_to_spree_auth_install - generate 'solidus:auth:install', *ARGV + generate "solidus:auth:install", *ARGV end end end diff --git a/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb b/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb index ca28a1f9..965cd6a2 100644 --- a/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb +++ b/lib/patches/frontend/controllers/solidus_auth_devise/checkout_controller_patch.rb @@ -21,20 +21,20 @@ def update_registration else flash[:registration_error] = t(:email_is_invalid, scope: [:errors, :messages]) @user = Spree::User.new - render 'registration' + render "registration" end end private def order_params - params. - fetch(:order, {}). - permit(:email) + params + .fetch(:order, {}) + .permit(:email) end def skip_state_validation? - %w(registration update_registration).include?(params[:action]) + %w[registration update_registration].include?(params[:action]) end def check_authorization diff --git a/lib/solidus_auth_devise.rb b/lib/solidus_auth_devise.rb index 56f69a53..ef0b3c8d 100644 --- a/lib/solidus_auth_devise.rb +++ b/lib/solidus_auth_devise.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require 'solidus_core' -require 'solidus_support' -require 'deface' -require 'devise' -require 'devise-encryptable' -require 'cancan' +require "solidus_core" +require "solidus_support" +require "deface" +require "devise" +require "devise-encryptable" +require "cancan" -require 'solidus_auth_devise/configuration' -require 'solidus_auth_devise/version' -require 'solidus_auth_devise/engine' +require "solidus_auth_devise/configuration" +require "solidus_auth_devise/version" +require "solidus_auth_devise/engine" diff --git a/lib/solidus_auth_devise/configuration.rb b/lib/solidus_auth_devise/configuration.rb index bc548981..78478b2a 100644 --- a/lib/solidus_auth_devise/configuration.rb +++ b/lib/solidus_auth_devise/configuration.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spree/auth_configuration' +require "spree/auth_configuration" diff --git a/lib/solidus_auth_devise/engine.rb b/lib/solidus_auth_devise/engine.rb index f80cac75..db4e0968 100644 --- a/lib/solidus_auth_devise/engine.rb +++ b/lib/solidus_auth_devise/engine.rb @@ -1,3 +1,3 @@ # frozen_string_literal: true -require 'spree/auth/engine' +require "spree/auth/engine" diff --git a/lib/solidus_auth_devise/version.rb b/lib/solidus_auth_devise/version.rb index 724ca8d4..1b4d3c80 100644 --- a/lib/solidus_auth_devise/version.rb +++ b/lib/solidus_auth_devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusAuthDevise - VERSION = '2.5.9' + VERSION = "2.5.9" end diff --git a/lib/spree/auth/engine.rb b/lib/spree/auth/engine.rb index 3d4db4a3..ca546bf0 100644 --- a/lib/spree/auth/engine.rb +++ b/lib/spree/auth/engine.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'solidus_auth_devise' -require 'devise' -require 'devise-encryptable' -require 'spree/auth/version' +require "solidus_auth_devise" +require "devise" +require "devise-encryptable" +require "spree/auth/version" module Spree module Auth @@ -11,12 +11,12 @@ class Engine < Rails::Engine include SolidusSupport::EngineExtensions isolate_namespace Spree - engine_name 'solidus_auth' + engine_name "solidus_auth" Spree.user_class = "Spree::User" initializer "spree.auth.environment", before: :load_config_initializers do |_app| - require 'spree/auth_configuration' + require "spree/auth_configuration" Spree::Auth::Config = Spree::AuthConfiguration.new end @@ -47,7 +47,7 @@ def self.redirect_back_on_unauthorized? def self.prepare_backend Spree::Admin::BaseController.unauthorized_redirect = -> do if spree_current_user - flash[:error] = I18n.t('spree.authorization_failure') + flash[:error] = I18n.t("spree.authorization_failure") if Spree::Auth::Engine.redirect_back_on_unauthorized? redirect_back(fallback_location: spree.admin_unauthorized_path) @@ -66,11 +66,10 @@ def self.prepare_backend end end - def self.prepare_frontend Spree::BaseController.unauthorized_redirect = -> do if spree_current_user - flash[:error] = I18n.t('spree.authorization_failure') + flash[:error] = I18n.t("spree.authorization_failure") if Spree::Auth::Engine.redirect_back_on_unauthorized? redirect_back(fallback_location: spree.unauthorized_path) diff --git a/lib/spree/auth/version.rb b/lib/spree/auth/version.rb index 6f7dc900..bdb93137 100644 --- a/lib/spree/auth/version.rb +++ b/lib/spree/auth/version.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'solidus_auth_devise/version' +require "solidus_auth_devise/version" module Spree module Auth diff --git a/lib/tasks/auth.rake b/lib/tasks/auth.rake index a2c4576a..323b615d 100644 --- a/lib/tasks/auth.rake +++ b/lib/tasks/auth.rake @@ -4,7 +4,7 @@ namespace :spree_auth do namespace :admin do desc "Create admin username and password" task create: :environment do - require File.join(File.dirname(__FILE__), '..', '..', 'db', 'default', 'users.rb') + require File.join(File.dirname(__FILE__), "..", "..", "db", "default", "users.rb") puts "Done!" end end diff --git a/solidus_auth_devise.gemspec b/solidus_auth_devise.gemspec index 9cdb8912..09c8a717 100644 --- a/solidus_auth_devise.gemspec +++ b/solidus_auth_devise.gemspec @@ -1,41 +1,40 @@ # frozen_string_literal: true -require_relative 'lib/solidus_auth_devise/version' +require_relative "lib/solidus_auth_devise/version" Gem::Specification.new do |spec| - spec.name = 'solidus_auth_devise' + spec.name = "solidus_auth_devise" spec.version = SolidusAuthDevise::VERSION - spec.authors = ['Solidus Team'] - spec.email = 'contact@solidus.io' + spec.authors = ["Solidus Team"] + spec.email = "contact@solidus.io" - spec.summary = 'Provides authentication and authorization services for use with Solidus by using Devise and CanCan.' - spec.homepage = 'https://github.com/solidusio/solidus_auth_devise' - spec.license = 'BSD-3-Clause' + spec.summary = "Provides authentication and authorization services for use with Solidus by using Devise and CanCan." + spec.homepage = "https://github.com/solidusio/solidus_auth_devise" + spec.license = "BSD-3-Clause" - spec.metadata['homepage_uri'] = spec.homepage - spec.metadata['source_code_uri'] = 'https://github.com/solidusio/solidus_auth_devise' - spec.metadata['changelog_uri'] = 'https://github.com/solidusio/solidus_auth_devise/releases' + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = "https://github.com/solidusio/solidus_auth_devise" + spec.metadata["changelog_uri"] = "https://github.com/solidusio/solidus_auth_devise/releases" - spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4') + spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 4") # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") } spec.files = files.grep_v(%r{^(test|spec|features)/}) - spec.test_files = files.grep(%r{^(test|spec|features)/}) spec.bindir = "exe" spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency 'deface', '~> 1.0' - spec.add_dependency 'devise', '~> 4.1' - spec.add_dependency 'devise-encryptable', '0.2.0' - spec.add_dependency 'solidus_core', ['>= 3', '< 5'] - spec.add_dependency 'solidus_support', '~> 0.11' + spec.add_dependency "deface", "~> 1.0" + spec.add_dependency "devise", "~> 4.1" + spec.add_dependency "devise-encryptable", "0.2.0" + spec.add_dependency "solidus_core", [">= 3", "< 5"] + spec.add_dependency "solidus_support", "~> 0.11" - spec.add_development_dependency 'solidus_backend' - spec.add_development_dependency 'solidus_frontend' - spec.add_development_dependency 'solidus_dev_support', '~> 2.10' - spec.add_development_dependency 'rails-controller-testing' + spec.add_development_dependency "solidus_backend" + spec.add_development_dependency "solidus_frontend" + spec.add_development_dependency "solidus_dev_support", "~> 2.10" + spec.add_development_dependency "rails-controller-testing" end diff --git a/spec/controllers/spree/admin/base_controller_spec.rb b/spec/controllers/spree/admin/base_controller_spec.rb index 5b81942a..15d32a89 100644 --- a/spec/controllers/spree/admin/base_controller_spec.rb +++ b/spec/controllers/spree/admin/base_controller_spec.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Spree::Admin::BaseController, type: :controller do - describe '#unauthorized_redirect' do + describe "#unauthorized_redirect" do controller(described_class) do - def index; authorize!(:read, :something); end + def index + authorize!(:read, :something) + end end before do @@ -23,11 +25,11 @@ def index; authorize!(:read, :something); end end context "when http_referrer is present" do - before { request.env['HTTP_REFERER'] = '/redirect' } + before { request.env["HTTP_REFERER"] = "/redirect" } it "redirects back" do get :index - expect(response).to redirect_to('/redirect') + expect(response).to redirect_to("/redirect") end end end @@ -41,11 +43,11 @@ def index; authorize!(:read, :something); end end context "when http_referrer is present" do - before { request.env['HTTP_REFERER'] = '/redirect' } + before { request.env["HTTP_REFERER"] = "/redirect" } it "redirects back" do get :index - expect(response).to redirect_to('/redirect') + expect(response).to redirect_to("/redirect") end end end diff --git a/spec/controllers/spree/admin/user_passwords_controller_spec.rb b/spec/controllers/spree/admin/user_passwords_controller_spec.rb index 97aaf7d5..c54aeee5 100644 --- a/spec/controllers/spree/admin/user_passwords_controller_spec.rb +++ b/spec/controllers/spree/admin/user_passwords_controller_spec.rb @@ -1,14 +1,14 @@ # frozen_string_literal: true RSpec.describe Spree::Admin::UserPasswordsController, type: :controller do - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + before { @request.env["devise.mapping"] = Devise.mappings[:spree_user] } - describe '#create' do - it 'responds with success' do - post :create, params: { spree_user: { email: 'admin@example.com' } } + describe "#create" do + it "responds with success" do + post :create, params: {spree_user: {email: "admin@example.com"}} - expect(assigns[:spree_user].email).to eq('admin@example.com') - expect(response.code).to eq('200') + expect(assigns[:spree_user].email).to eq("admin@example.com") + expect(response.code).to eq("200") end end end diff --git a/spec/controllers/spree/admin/user_sessions_controller_spec.rb b/spec/controllers/spree/admin/user_sessions_controller_spec.rb index febfa3aa..52137579 100644 --- a/spec/controllers/spree/admin/user_sessions_controller_spec.rb +++ b/spec/controllers/spree/admin/user_sessions_controller_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true RSpec.describe Spree::Admin::UserSessionsController, type: :controller do - let(:user) { create(:user, password: 'secret') } + let(:user) { create(:user, password: "secret") } - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable + before { @request.env["devise.mapping"] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable it "redirects to the admin root after signing in with no stored location" do get :new @@ -11,8 +11,8 @@ post(:create, params: { spree_user: { email: user.email, - password: 'secret' - }, + password: "secret" + } }) expect(response).to redirect_to spree.admin_path diff --git a/spec/controllers/spree/base_controller_spec.rb b/spec/controllers/spree/base_controller_spec.rb index 9dc565cd..3a05c261 100644 --- a/spec/controllers/spree/base_controller_spec.rb +++ b/spec/controllers/spree/base_controller_spec.rb @@ -1,11 +1,13 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" RSpec.describe Spree::BaseController, type: :controller do - describe '#unauthorized_redirect' do + describe "#unauthorized_redirect" do controller(described_class) do - def index; authorize!(:read, :something); end + def index + authorize!(:read, :something) + end end before do @@ -23,11 +25,11 @@ def index; authorize!(:read, :something); end end context "when http_referrer is present" do - before { request.env['HTTP_REFERER'] = '/redirect' } + before { request.env["HTTP_REFERER"] = "/redirect" } it "redirects back" do get :index - expect(response).to redirect_to('/redirect') + expect(response).to redirect_to("/redirect") end end end @@ -41,11 +43,11 @@ def index; authorize!(:read, :something); end end context "when http_referrer is present" do - before { request.env['HTTP_REFERER'] = '/redirect' } + before { request.env["HTTP_REFERER"] = "/redirect" } it "redirects back" do get :index - expect(response).to redirect_to('/redirect') + expect(response).to redirect_to("/redirect") end end end diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index f831a07d..46f6f192 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -2,8 +2,8 @@ RSpec.describe Spree::CheckoutController, type: :controller do let(:order) { create(:order_with_line_items, email: nil, user: nil, guest_token: token) } - let(:user) { build(:user, spree_api_key: 'fake') } - let(:token) { 'some_token' } + let(:user) { build(:user, spree_api_key: "fake") } + let(:token) { "some_token" } let(:cookie_token) { token } before do @@ -12,132 +12,132 @@ allow(order).to receive(:confirmation_required?) { true } end - context '#edit' do - context 'when registration step enabled' do - context 'when authenticated as registered user' do + context "#edit" do + context "when registration step enabled" do + context "when authenticated as registered user" do before { allow(controller).to receive(:spree_current_user) { user } } - it 'proceeds to the first checkout step' do - get :edit, params: { state: 'address' } + it "proceeds to the first checkout step" do + get :edit, params: {state: "address"} expect(response).to render_template :edit end end - context 'when not authenticated as guest' do - it 'redirects to registration step' do - get :edit, params: { state: 'address' } + context "when not authenticated as guest" do + it "redirects to registration step" do + get :edit, params: {state: "address"} expect(response).to redirect_to spree.checkout_registration_path end end - context 'when authenticated as guest' do - before { order.email = 'guest@solidus.io' } + context "when authenticated as guest" do + before { order.email = "guest@solidus.io" } - it 'proceeds to the first checkout step' do - get :edit, params: { state: 'address' } + it "proceeds to the first checkout step" do + get :edit, params: {state: "address"} expect(response).to render_template :edit end - context 'when guest checkout not allowed' do + context "when guest checkout not allowed" do before do stub_spree_preferences(allow_guest_checkout: false) end - it 'redirects to registration step' do - get :edit, params: { state: 'address' } + it "redirects to registration step" do + get :edit, params: {state: "address"} expect(response).to redirect_to spree.checkout_registration_path end end end end - context 'when registration step disabled' do + context "when registration step disabled" do before do stub_spree_preferences(Spree::Auth::Config, registration_step: false) end - context 'when authenticated as registered' do + context "when authenticated as registered" do before { allow(controller).to receive(:spree_current_user) { user } } - it 'proceeds to the first checkout step' do - get :edit, params: { state: 'address' } + it "proceeds to the first checkout step" do + get :edit, params: {state: "address"} expect(response).to render_template :edit end end - context 'when authenticated as guest' do - it 'proceeds to the first checkout step' do - get :edit, params: { state: 'address' } + context "when authenticated as guest" do + it "proceeds to the first checkout step" do + get :edit, params: {state: "address"} expect(response).to render_template :edit end end end end - context '#update' do - context 'when in the confirm state' do + context "#update" do + context "when in the confirm state" do before do - order.update(email: 'spree@example.com', state: 'confirm') + order.update(email: "spree@example.com", state: "confirm") # So that the order can transition to complete successfully allow(order).to receive(:payment_required?) { false } end - context 'with a token' do - before { allow(order).to receive(:guest_token) { 'ABC' } } + context "with a token" do + before { allow(order).to receive(:guest_token) { "ABC" } } - it 'redirects to the tokenized order view' do - request.cookie_jar.signed[:guest_token] = 'ABC' - post :update, params: { state: 'confirm' } - expect(response).to redirect_to spree.token_order_path(order, 'ABC') - expect(flash.notice).to eq I18n.t('spree.order_processed_successfully') + it "redirects to the tokenized order view" do + request.cookie_jar.signed[:guest_token] = "ABC" + post :update, params: {state: "confirm"} + expect(response).to redirect_to spree.token_order_path(order, "ABC") + expect(flash.notice).to eq I18n.t("spree.order_processed_successfully") end end - context 'with a registered user' do + context "with a registered user" do before do allow(controller).to receive(:spree_current_user) { user } allow(order).to receive(:user) { user } allow(order).to receive(:guest_token) { nil } end - it 'redirects to the standard order view' do - post :update, params: { state: 'confirm' } + it "redirects to the standard order view" do + post :update, params: {state: "confirm"} expect(response).to redirect_to spree.order_path(order) end end end end - context '#registration' do - it 'does not check registration' do + context "#registration" do + it "does not check registration" do expect(controller).not_to receive(:check_registration) get :registration end - it 'checks if the user is authorized for :edit' do + it "checks if the user is authorized for :edit" do expect(controller).to receive(:authorize!).with(:edit, order, token) request.cookie_jar.signed[:guest_token] = token get :registration, params: {} end end - context '#update_registration' do - subject { put :update_registration, params: { order: { email: email } } } - let(:email) { 'foo@example.com' } + context "#update_registration" do + subject { put :update_registration, params: {order: {email: email}} } + let(:email) { "foo@example.com" } - it 'does not check registration' do + it "does not check registration" do expect(controller).not_to receive(:check_registration) subject end - it 'redirects to the checkout_path after saving' do + it "redirects to the checkout_path after saving" do subject expect(response).to redirect_to spree.checkout_path end # Regression test for https://github.com/solidusio/solidus/issues/1588 - context 'order in address state' do + context "order in address state" do let(:order) do create( :order_with_line_items, @@ -146,7 +146,7 @@ guest_token: token, bill_address: nil, ship_address: nil, - state: 'address' + state: "address" ) end @@ -161,30 +161,30 @@ end end - context 'invalid email' do - let(:email) { 'invalid' } + context "invalid email" do + let(:email) { "invalid" } - it 'renders the registration view' do + it "renders the registration view" do subject expect(flash[:registration_error]).to eq I18n.t(:email_is_invalid, scope: [:errors, :messages]) expect(response).to render_template :registration end end - context 'with wrong order token' do - let(:cookie_token) { 'lol_no_access' } + context "with wrong order token" do + let(:cookie_token) { "lol_no_access" } - it 'redirects to login' do - put :update_registration, params: { order: { email: 'foo@example.com' } } + it "redirects to login" do + put :update_registration, params: {order: {email: "foo@example.com"}} expect(response).to redirect_to(login_path) end end - context 'without order token' do + context "without order token" do let(:cookie_token) { nil } - it 'redirects to login' do - put :update_registration, params: { order: { email: 'foo@example.com' } } + it "redirects to login" do + put :update_registration, params: {order: {email: "foo@example.com"}} expect(response).to redirect_to(login_path) end end diff --git a/spec/controllers/spree/products_controller_spec.rb b/spec/controllers/spree/products_controller_spec.rb index 8596f3b0..f3ef921a 100644 --- a/spec/controllers/spree/products_controller_spec.rb +++ b/spec/controllers/spree/products_controller_spec.rb @@ -2,23 +2,23 @@ RSpec.describe Spree::ProductsController, type: :controller do let!(:product) { create(:product, available_on: 1.year.from_now) } - let!(:user) { build(:user, spree_api_key: 'fake') } + let!(:user) { build(:user, spree_api_key: "fake") } - it 'allows admins to view non-active products' do + it "allows admins to view non-active products" do allow(controller).to receive(:before_save_new_order) allow(controller).to receive(:spree_current_user) { user } allow(user).to receive(:has_spree_role?) { true } - get :show, params: { id: product.to_param } + get :show, params: {id: product.to_param} expect(response.status).to eq(200) end - it 'cannot view non-active products' do + it "cannot view non-active products" do allow(controller).to receive(:before_save_new_order) allow(controller).to receive(:spree_current_user) { user } allow(user).to receive(:has_spree_role?) { false } expect { - get :show, params: { id: product.to_param } + get :show, params: {id: product.to_param} }.to raise_error(ActiveRecord::RecordNotFound) end end diff --git a/spec/controllers/spree/user_passwords_controller_spec.rb b/spec/controllers/spree/user_passwords_controller_spec.rb index 2165a22c..9b2fe5b1 100644 --- a/spec/controllers/spree/user_passwords_controller_spec.rb +++ b/spec/controllers/spree/user_passwords_controller_spec.rb @@ -1,40 +1,40 @@ # frozen_string_literal: true RSpec.describe Spree::UserPasswordsController, type: :controller do - let(:token) { 'some_token' } + let(:token) { "some_token" } - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + before { @request.env["devise.mapping"] = Devise.mappings[:spree_user] } - describe 'GET edit' do - context 'when the user token has not been specified' do - it 'redirects to the new session path' do + describe "GET edit" do + context "when the user token has not been specified" do + it "redirects to the new session path" do get :edit expect(response).to redirect_to( - 'http://test.host/user/spree_user/sign_in' + "http://test.host/user/spree_user/sign_in" ) end - it 'flashes an error' do + it "flashes an error" do get :edit expect(flash[:alert]).to include( "You can't access this page without coming from a password reset " \ - 'email' + "email" ) end end - context 'when the user token has been specified' do - it 'does something' do - get :edit, params: { reset_password_token: token } - expect(response.code).to eq('200') + context "when the user token has been specified" do + it "does something" do + get :edit, params: {reset_password_token: token} + expect(response.code).to eq("200") end end end - context '#update' do - context 'when updating password with blank password' do - it 'shows error flash message, sets spree_user with token and re-displays password edit form' do - put :update, params: { spree_user: { password: '', password_confirmation: '', reset_password_token: token } } + context "#update" do + context "when updating password with blank password" do + it "shows error flash message, sets spree_user with token and re-displays password edit form" do + put :update, params: {spree_user: {password: "", password_confirmation: "", reset_password_token: token}} expect(assigns(:spree_user).is_a?(Spree::User)).to eq true expect(assigns(:spree_user).reset_password_token).to eq token expect(flash[:error]).to eq I18n.t(:cannot_be_blank, scope: [:devise, :user_passwords, :spree_user]) diff --git a/spec/controllers/spree/user_registrations_controller_spec.rb b/spec/controllers/spree/user_registrations_controller_spec.rb index 579ff9c2..5eddedb1 100644 --- a/spec/controllers/spree/user_registrations_controller_spec.rb +++ b/spec/controllers/spree/user_registrations_controller_spec.rb @@ -1,78 +1,77 @@ # frozen_string_literal: true RSpec.describe Spree::UserRegistrationsController, type: :controller do - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } + before { @request.env["devise.mapping"] = Devise.mappings[:spree_user] } - context '#create' do + context "#create" do before do allow(controller).to receive(:after_sign_up_path_for) do spree.root_path(thing: 7) end end - let(:password_confirmation) { 'foobar123' } + let(:password_confirmation) { "foobar123" } subject do post(:create, params: { spree_user: { - email: 'foobar@example.com', - password: 'foobar123', + email: "foobar@example.com", + password: "foobar123", password_confirmation: password_confirmation } - } - ) + }) end - context 'when user created successfuly' do - it 'saves the user' do + context "when user created successfuly" do + it "saves the user" do expect { subject }.to change { Spree::User.count }.from(0).to(1) end - it 'sets flash message' do + it "sets flash message" do subject - expect(flash[:notice]).to eq('Welcome! You have signed up successfully.') + expect(flash[:notice]).to eq("Welcome! You have signed up successfully.") end - it 'signs in user' do + it "signs in user" do expect(controller.warden).to receive(:set_user) subject end - it 'sets spree_user_signup session' do + it "sets spree_user_signup session" do subject expect(session[:spree_user_signup]).to be true end - it 'redirects to after_sign_up path' do + it "redirects to after_sign_up path" do subject expect(response).to redirect_to spree.root_path(thing: 7) end - context 'with a guest token present' do + context "with a guest token present" do before do - request.cookie_jar.signed[:guest_token] = 'ABC' + request.cookie_jar.signed[:guest_token] = "ABC" end - it 'assigns orders with the correct token and no user present' do - order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil) + it "assigns orders with the correct token and no user present" do + order = create(:order, guest_token: "ABC", user_id: nil, created_by_id: nil) subject - user = Spree::User.find_by(email: 'foobar@example.com') + user = Spree::User.find_by(email: "foobar@example.com") order.reload expect(order.user_id).to eq user.id expect(order.created_by_id).to eq user.id end - it 'does not assign orders with an existing user' do - order = create(:order, guest_token: 'ABC', user_id: 200) + it "does not assign orders with an existing user" do + order = create(:order, guest_token: "ABC", user_id: 200) subject expect(order.reload.user_id).to eq 200 end - it 'does not assign orders with a different token' do - order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil) + it "does not assign orders with a different token" do + order = create(:order, guest_token: "DEF", user_id: nil, created_by_id: nil) subject expect(order.reload.user_id).to be_nil @@ -80,15 +79,15 @@ end end - context 'when user not valid' do - let(:password_confirmation) { 'foobard123' } + context "when user not valid" do + let(:password_confirmation) { "foobard123" } - it 'resets password fields' do + it "resets password fields" do expect(controller).to receive(:clean_up_passwords) subject end - it 'renders new view' do + it "renders new view" do subject expect(:response).to render_template(:new) end diff --git a/spec/controllers/spree/user_sessions_controller_spec.rb b/spec/controllers/spree/user_sessions_controller_spec.rb index 84619372..0ddf3672 100644 --- a/spec/controllers/spree/user_sessions_controller_spec.rb +++ b/spec/controllers/spree/user_sessions_controller_spec.rb @@ -3,11 +3,11 @@ RSpec.describe Spree::UserSessionsController, type: :controller do let(:user) { create(:user) } - before { @request.env['devise.mapping'] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable + before { @request.env["devise.mapping"] = Devise.mappings[:spree_user] } # rubocop:disable RSpec/InstanceVariable context "#create" do let(:format) { :html } - let(:password) { 'secret' } + let(:password) { "secret" } subject do post(:create, params: { @@ -20,13 +20,13 @@ end context "when using correct login information" do - context 'with a guest token present' do + context "with a guest token present" do before do - request.cookie_jar.signed[:guest_token] = 'ABC' + request.cookie_jar.signed[:guest_token] = "ABC" end - it 'assigns orders with the correct token and no user present' do - order = create(:order, email: user.email, guest_token: 'ABC', user_id: nil, created_by_id: nil) + it "assigns orders with the correct token and no user present" do + order = create(:order, email: user.email, guest_token: "ABC", user_id: nil, created_by_id: nil) subject order.reload @@ -34,8 +34,8 @@ expect(order.created_by_id).to eq user.id end - it 'assigns orders with the correct token and no user or email present' do - order = create(:order, guest_token: 'ABC', user_id: nil, created_by_id: nil) + it "assigns orders with the correct token and no user or email present" do + order = create(:order, guest_token: "ABC", user_id: nil, created_by_id: nil) subject order.reload @@ -43,10 +43,10 @@ expect(order.created_by_id).to eq user.id end - it 'does not assign completed orders' do - order = create(:order, email: user.email, guest_token: 'ABC', - user_id: nil, created_by_id: nil, - completed_at: 1.minute.ago) + it "does not assign completed orders" do + order = create(:order, email: user.email, guest_token: "ABC", + user_id: nil, created_by_id: nil, + completed_at: 1.minute.ago) subject order.reload @@ -54,15 +54,15 @@ expect(order.created_by_id).to be_nil end - it 'does not assign orders with an existing user' do - order = create(:order, guest_token: 'ABC', user_id: 200) + it "does not assign orders with an existing user" do + order = create(:order, guest_token: "ABC", user_id: 200) subject expect(order.reload.user_id).to eq 200 end - it 'does not assign orders with a different token' do - order = create(:order, guest_token: 'DEF', user_id: nil, created_by_id: nil) + it "does not assign orders with a different token" do + order = create(:order, guest_token: "DEF", user_id: nil, created_by_id: nil) subject expect(order.reload.user_id).to be_nil @@ -90,13 +90,13 @@ end context "when using incorrect login information" do - let(:password) { 'wrong' } + let(:password) { "wrong" } context "when html format is requested" do it "renders new template again with errors" do subject expect(response).to render_template(:new) - expect(flash[:error]).to eq I18n.t(:'devise.failure.invalid') + expect(flash[:error]).to eq I18n.t(:"devise.failure.invalid") end end diff --git a/spec/controllers/spree/users_controller_spec.rb b/spec/controllers/spree/users_controller_spec.rb index c4ca9586..95403090 100644 --- a/spec/controllers/spree/users_controller_spec.rb +++ b/spec/controllers/spree/users_controller_spec.rb @@ -5,74 +5,74 @@ let(:user) { create(:user) } let(:role) { create(:role) } - context '#load_object' do - it 'redirects to signup path if user is not found' do - put :update, params: { user: { email: 'foobar@example.com' } } + context "#load_object" do + it "redirects to signup path if user is not found" do + put :update, params: {user: {email: "foobar@example.com"}} expect(response).to redirect_to spree.login_path end end - context '#create' do - it 'creates a new user' do - post :create, params: { user: { email: 'foobar@example.com', password: 'foobar123', password_confirmation: 'foobar123' } } + context "#create" do + it "creates a new user" do + post :create, params: {user: {email: "foobar@example.com", password: "foobar123", password_confirmation: "foobar123"}} expect(assigns[:user].new_record?).to be false end end - context '#update' do + context "#update" do before { sign_in(user) } - context 'when updating own account' do - context 'when user updated successfuly' do - before { put :update, params: { user: { email: 'mynew@email-address.com' } } } + context "when updating own account" do + context "when user updated successfuly" do + before { put :update, params: {user: {email: "mynew@email-address.com"}} } - it 'saves user' do - expect(assigns[:user].email).to eq 'mynew@email-address.com' + it "saves user" do + expect(assigns[:user].email).to eq "mynew@email-address.com" end - it 'updates spree_current_user' do - expect(subject.spree_current_user.email).to eq 'mynew@email-address.com' + it "updates spree_current_user" do + expect(subject.spree_current_user.email).to eq "mynew@email-address.com" end - it 'redirects to account url' do + it "redirects to account url" do expect(response).to redirect_to spree.account_url(only_path: true) end end - context 'when user not valid' do - before { put :update, params: { user: { email: '' } } } + context "when user not valid" do + before { put :update, params: {user: {email: ""}} } - it 'does not affect spree_current_user' do + it "does not affect spree_current_user" do expect(subject.spree_current_user.email).to eq user.email end end - context 'when updating password' do + context "when updating password" do before do stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: signout_after_change) - put :update, params: { user: { password: 'foobar123', password_confirmation: 'foobar123' } } + put :update, params: {user: {password: "foobar123", password_confirmation: "foobar123"}} end - context 'when signout after password change is enabled' do + context "when signout after password change is enabled" do let(:signout_after_change) { true } - it 'redirects to login url' do + it "redirects to login url" do expect(response).to redirect_to spree.login_url(only_path: true) end end - context 'when signout after password change is disabled' do + context "when signout after password change is disabled" do let(:signout_after_change) { false } - it 'redirects to account url' do + it "redirects to account url" do expect(response).to redirect_to spree.account_url(only_path: true) end end end end - it 'does not update roles' do - put :update, params: { user: { spree_role_ids: [role.id] } } + it "does not update roles" do + put :update, params: {user: {spree_role_ids: [role.id]}} expect(assigns[:user].spree_roles).to_not include role end end diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index a517d1cb..93c89d0f 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -1,59 +1,59 @@ # frozen_string_literal: true -RSpec.feature 'Accounts', type: :feature do - context 'editing' do - scenario 'can edit an admin user' do - user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password') +RSpec.feature "Accounts", type: :feature do + context "editing" do + scenario "can edit an admin user" do + user = create(:admin_user, email: "admin@person.com", password: "password", password_confirmation: "password") visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" - click_link 'My Account' - expect(page).to have_text 'admin@person.com' + click_link "My Account" + expect(page).to have_text "admin@person.com" end - scenario 'can edit a new user' do + scenario "can edit a new user" do stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false) visit spree.signup_path - fill_in 'Email', with: 'email@person.com' - fill_in 'Password', with: 'password' - fill_in 'Password Confirmation', with: 'password' - click_button 'Create' + fill_in "Email", with: "email@person.com" + fill_in "Password", with: "password" + fill_in "Password Confirmation", with: "password" + click_button "Create" - click_link 'My Account' - expect(page).to have_text 'email@person.com' - click_link 'Edit' + click_link "My Account" + expect(page).to have_text "email@person.com" + click_link "Edit" - fill_in 'Password', with: 'foobar' - fill_in 'Password Confirmation', with: 'foobar' - click_button 'Update' + fill_in "Password", with: "foobar" + fill_in "Password Confirmation", with: "foobar" + click_button "Update" - expect(page).to have_text 'email@person.com' - expect(page).to have_text 'Account updated' + expect(page).to have_text "email@person.com" + expect(page).to have_text "Account updated" end - scenario 'can edit an existing user account' do - stub_spree_preferences(Spree::Auth::Config ,signout_after_password_change: false) - user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret') + scenario "can edit an existing user account" do + stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false) + user = create(:user, email: "email@person.com", password: "secret", password_confirmation: "secret") visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" - click_link 'My Account' - expect(page).to have_text 'email@person.com' - click_link 'Edit' + click_link "My Account" + expect(page).to have_text "email@person.com" + click_link "Edit" - fill_in 'Password', with: 'foobar' - fill_in 'Password Confirmation', with: 'foobar' - click_button 'Update' + fill_in "Password", with: "foobar" + fill_in "Password Confirmation", with: "foobar" + click_button "Update" - expect(page).to have_text 'email@person.com' - expect(page).to have_text 'Account updated' + expect(page).to have_text "email@person.com" + expect(page).to have_text "Account updated" end end end diff --git a/spec/features/admin/password_reset_spec.rb b/spec/features/admin/password_reset_spec.rb index 4d44408f..9838cae0 100644 --- a/spec/features/admin/password_reset_spec.rb +++ b/spec/features/admin/password_reset_spec.rb @@ -1,77 +1,75 @@ # frozen_string_literal: true -RSpec.feature 'Admin - Reset Password', type: :feature do +RSpec.feature "Admin - Reset Password", type: :feature do let!(:store) { create(:store) } background do - ActionMailer::Base.default_url_options[:host] = 'http://example.com' + ActionMailer::Base.default_url_options[:host] = "http://example.com" end - context 'when an account with this email address exists' do - let!(:user) { create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret') } + context "when an account with this email address exists" do + let!(:user) { create(:user, email: "foobar@example.com", password: "secret", password_confirmation: "secret") } - scenario 'allows a user to supply an email for the password reset' do + scenario "allows a user to supply an email for the password reset" do visit spree.admin_login_path - click_link 'Forgot Password?' + click_link "Forgot Password?" fill_in_email - click_button 'Reset my password' - expect(page).to have_text 'you will receive an email with instructions' + click_button "Reset my password" + expect(page).to have_text "you will receive an email with instructions" end end # Revealing that an admin email address is not found allows an attacker to # find admin account email addresses by trying email addresses until this # error is not shown. - scenario 'does not reveal email addresses if they are not found' do + scenario "does not reveal email addresses if they are not found" do visit spree.admin_login_path - click_link 'Forgot Password?' + click_link "Forgot Password?" fill_in_email - click_button 'Reset my password' + click_button "Reset my password" expect(page).to_not have_text "Email not found" - expect(page).to have_text 'you will receive an email with instructions' + expect(page).to have_text "you will receive an email with instructions" end def fill_in_email - fill_in 'Email', with: 'foobar@example.com' + fill_in "Email", with: "foobar@example.com" end - context 'password management' do + context "password management" do let!(:admin) do create(:admin_user, - email: 'admin@example.com', - password: 'secret', - password_confirmation: 'secret' - ) + email: "admin@example.com", + password: "secret", + password_confirmation: "secret") end let!(:user) do create(:user, - email: 'user@example.com', - password: 'test123', - password_confirmation: 'test123' - ) + email: "user@example.com", + password: "test123", + password_confirmation: "test123") end before do visit spree.admin_login_path - fill_in 'Email', with: admin.email - fill_in 'Password', with: admin.password - click_button 'Login' + fill_in "Email", with: admin.email + fill_in "Password", with: admin.password + click_button "Login" visit spree.admin_users_path end - context 'if currently logged-in admin' do + context "if currently logged-in admin" do context "clicks on an user's page" do - it 'can reset its password' do + it "can reset its password" do within("#spree_user_#{user.id}") do click_link user.email end - click_button 'Reset password' + click_button "Reset password" expect(page).to have_content( - 'If an account with that email address exists, '\ - 'you will receive an email with instructions about '\ - 'how to reset your password in a few minutes.' + "If an account with that email address exists, " \ + "you will receive an email with instructions about " \ + "how to reset your password in a few minutes." ) end end diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index 1daeb3e8..6f8d565e 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.feature 'Admin products', type: :feature do - context 'as anonymous user' do +RSpec.feature "Admin products", type: :feature do + context "as anonymous user" do # Regression test for #1250 - scenario 'redirects to login page when attempting to access product listing' do + scenario "redirects to login page when attempting to access product listing" do expect { visit spree.admin_products_path }.not_to raise_error end end diff --git a/spec/features/admin/sign_in_spec.rb b/spec/features/admin/sign_in_spec.rb index fc1d70e8..500f949d 100644 --- a/spec/features/admin/sign_in_spec.rb +++ b/spec/features/admin/sign_in_spec.rb @@ -1,45 +1,45 @@ # frozen_string_literal: true -RSpec.feature 'Admin - Sign In', type: :feature do +RSpec.feature "Admin - Sign In", type: :feature do background do - @user = create(:admin_user, email: 'email@person.com') + @user = create(:admin_user, email: "email@person.com") visit spree.admin_login_path end - scenario 'asks user to sign in' do + scenario "asks user to sign in" do visit spree.admin_path - expect(page).not_to have_text 'Authorization Failure' + expect(page).not_to have_text "Authorization Failure" end - scenario 'lets a user sign in successfully' do - fill_in 'Email', with: @user.email - fill_in 'Password', with: 'secret' - click_button 'Login' + scenario "lets a user sign in successfully" do + fill_in "Email", with: @user.email + fill_in "Password", with: "secret" + click_button "Login" - expect(page).to have_text 'Logged in successfully' - expect(page).not_to have_text 'Login' - expect(page).to have_text 'Logout' - expect(current_path).to eq '/admin/orders' + expect(page).to have_text "Logged in successfully" + expect(page).not_to have_text "Login" + expect(page).to have_text "Logout" + expect(current_path).to eq "/admin/orders" end - scenario 'shows validation erros' do - fill_in 'Email', with: @user.email - fill_in 'Password', with: 'wrong_password' - click_button 'Login' + scenario "shows validation erros" do + fill_in "Email", with: @user.email + fill_in "Password", with: "wrong_password" + click_button "Login" - expect(page).to have_text 'Invalid email or password' - expect(page).to have_text 'Login' + expect(page).to have_text "Invalid email or password" + expect(page).to have_text "Login" end - scenario 'allows a user to access a restricted page after logging in' do - user = create(:admin_user, email: 'admin@person.com') + scenario "allows a user to access a restricted page after logging in" do + user = create(:admin_user, email: "admin@person.com") visit spree.admin_path - fill_in 'Email', with: user.email - fill_in 'Password', with: 'secret' - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: "secret" + click_button "Login" - expect(page).to have_text 'admin@person.com' - expect(current_path).to eq '/admin/orders' + expect(page).to have_text "admin@person.com" + expect(current_path).to eq "/admin/orders" end end diff --git a/spec/features/admin/sign_out_spec.rb b/spec/features/admin/sign_out_spec.rb index c8447ed8..ce6aaf8d 100644 --- a/spec/features/admin/sign_out_spec.rb +++ b/spec/features/admin/sign_out_spec.rb @@ -1,24 +1,24 @@ # frozen_string_literal: true -RSpec.feature 'Admin - Sign Out', type: :feature, js: true do +RSpec.feature "Admin - Sign Out", type: :feature, js: true do given!(:user) do - create :user, email: 'email@person.com' + create :user, email: "email@person.com" end background do visit spree.admin_login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: 'secret' + fill_in "Email", with: user.email + fill_in "Password", with: "secret" # Regression test for #1257 - check 'Remember me' - click_button 'Login' + check "Remember me" + click_button "Login" end - scenario 'allows a signed in user to logout' do + scenario "allows a signed in user to logout" do click_logout_link visit spree.admin_login_path - expect(page).to have_text 'Login' - expect(page).not_to have_text 'Logout' + expect(page).to have_text "Login" + expect(page).not_to have_text "Logout" end def click_logout_link @@ -26,17 +26,17 @@ def click_logout_link end def new_version? - Gem::Requirement.new('>= 4.2').satisfied_by?(Spree.solidus_gem_version) + Gem::Requirement.new(">= 4.2").satisfied_by?(Spree.solidus_gem_version) end def logout_new_version - find('details div', text: user.email, wait: 10).click - within('details') do - click_link 'Logout' + find("details div", text: user.email, wait: 10).click + within("details") do + click_link "Logout" end end def logout_old_version - click_link 'Logout' + click_link "Logout" end end diff --git a/spec/features/admin_permissions_spec.rb b/spec/features/admin_permissions_spec.rb index 2306d387..31f0ea78 100644 --- a/spec/features/admin_permissions_spec.rb +++ b/spec/features/admin_permissions_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -RSpec.feature 'Admin Permissions', type: :feature do - context 'orders' do +RSpec.feature "Admin Permissions", type: :feature do + context "orders" do background do - user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password') + user = create(:admin_user, email: "admin@person.com", password: "password", password_confirmation: "password") Spree::Ability.register_ability(AbilityDecorator) visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" end - context 'admin is restricted from accessing orders' do - scenario 'can not list orders' do + context "admin is restricted from accessing orders" do + scenario "can not list orders" do visit spree.admin_orders_path - expect(page).to have_text 'Authorization Failure' + expect(page).to have_text "Authorization Failure" end - scenario 'can not edit orders' do - create(:order, number: 'R123') - visit spree.edit_admin_order_path('R123') - expect(page).to have_text 'Authorization Failure' + scenario "can not edit orders" do + create(:order, number: "R123") + visit spree.edit_admin_order_path("R123") + expect(page).to have_text "Authorization Failure" end - scenario 'can not new orders' do + scenario "can not new orders" do visit spree.new_admin_order_path - expect(page).to have_text 'Authorization Failure' + expect(page).to have_text "Authorization Failure" end end context "admin is restricted from accessing an order's customer details" do given(:order) { create(:order_with_totals) } - scenario 'can not list customer details for an order' do + scenario "can not list customer details for an order" do visit spree.admin_order_customer_path(order) - expect(page).to have_text 'Authorization Failure' + expect(page).to have_text "Authorization Failure" end scenario "can not edit an order's customer details" do visit spree.edit_admin_order_customer_path(order) - expect(page).to have_text 'Authorization Failure' + expect(page).to have_text "Authorization Failure" end end end diff --git a/spec/features/change_email_spec.rb b/spec/features/change_email_spec.rb index c04ee5db..168cab27 100644 --- a/spec/features/change_email_spec.rb +++ b/spec/features/change_email_spec.rb @@ -1,27 +1,27 @@ # frozen_string_literal: true -RSpec.feature 'Change email', type: :feature do +RSpec.feature "Change email", type: :feature do background do stub_spree_preferences(Spree::Auth::Config, signout_after_password_change: false) user = create(:user) visit spree.root_path - click_link 'Login' + click_link "Login" - fill_in 'spree_user[email]', with: user.email - fill_in 'spree_user[password]', with: 'secret' - click_button 'Login' + fill_in "spree_user[email]", with: user.email + fill_in "spree_user[password]", with: "secret" + click_button "Login" visit spree.edit_account_path end - scenario 'work with correct password' do - fill_in 'user_email', with: 'tests@example.com' - fill_in 'user_password', with: 'password' - fill_in 'user_password_confirmation', with: 'password' - click_button 'Update' + scenario "work with correct password" do + fill_in "user_email", with: "tests@example.com" + fill_in "user_password", with: "password" + fill_in "user_password_confirmation", with: "password" + click_button "Update" - expect(page).to have_text 'Account updated' - expect(page).to have_text 'tests@example.com' + expect(page).to have_text "Account updated" + expect(page).to have_text "tests@example.com" end end diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index 2453ca22..db2e548d 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -RSpec.feature 'Checkout', :js, type: :feature do +RSpec.feature "Checkout", :js, type: :feature do given!(:store) { create(:store) } - given!(:country) { create(:country, name: 'United States', states_required: true) } - given!(:state) { create(:state, name: 'Maryland', country: country) } + given!(:country) { create(:country, name: "United States", states_required: true) } + given!(:state) { create(:state, name: "Maryland", country: country) } given!(:shipping_method) do shipping_method = create(:shipping_method) calculator = Spree::Calculator::Shipping::PerItem.create!(calculable: shipping_method, preferred_amount: 10) @@ -11,12 +11,12 @@ shipping_method.tap(&:save) end - given!(:zone) { create(:zone) } + given!(:zone) { create(:zone) } given!(:address) { create(:address, state: state, country: country) } - given!(:payment_method){ create :check_payment_method } + given!(:payment_method) { create :check_payment_method } background do - @product = create(:product, name: 'RoR Mug') + @product = create(:product, name: "RoR Mug") @product.master.stock_items.first.set_count_on_hand(1) # Bypass gateway error on checkout | ..or stub a gateway @@ -26,97 +26,97 @@ end # Regression test for https://github.com/solidusio/solidus/issues/1588 - scenario 'leaving and returning to address step' do + scenario "leaving and returning to address step" do stub_spree_preferences(Spree::Auth::Config, registration_step: true) - click_link 'RoR Mug' - click_button 'Add To Cart' - within('h1') { expect(page).to have_text 'Shopping Cart' } - click_button 'Checkout' + click_link "RoR Mug" + click_button "Add To Cart" + within("h1") { expect(page).to have_text "Shopping Cart" } + click_button "Checkout" - within '#guest_checkout' do - fill_in 'Email', with: 'test@example.com' + within "#guest_checkout" do + fill_in "Email", with: "test@example.com" end - click_on 'Continue' + click_on "Continue" - click_on 'Cart' + click_on "Cart" - click_on 'Checkout' + click_on "Checkout" expect(page).to have_content "Billing Address" end - context 'without payment being required' do - scenario 'allow a visitor to checkout as guest, without registration' do - click_link 'RoR Mug' - click_button 'Add To Cart' - within('h1') { expect(page).to have_text 'Shopping Cart' } - click_button 'Checkout' + context "without payment being required" do + scenario "allow a visitor to checkout as guest, without registration" do + click_link "RoR Mug" + click_button "Add To Cart" + within("h1") { expect(page).to have_text "Shopping Cart" } + click_button "Checkout" expect(page).to have_content(/Checkout as a Guest/i) - within('#guest_checkout') { fill_in 'Email', with: 'spree@test.com' } - click_button 'Continue' + within("#guest_checkout") { fill_in "Email", with: "spree@test.com" } + click_button "Continue" expect(page).to have_text(/Billing Address/i) expect(page).to have_text(/Shipping Address/i) fill_addresses_fields_with(address) - click_button 'Save and Continue' + click_button "Save and Continue" - expect(page).to have_content 'UPS Ground' + expect(page).to have_content "UPS Ground" - click_button 'Save and Continue' + click_button "Save and Continue" expect(page).to have_content(/Payment Information/i) - click_button 'Save and Continue' - click_button 'Place Order' + click_button "Save and Continue" + click_button "Place Order" - expect(page).to have_text 'Your order has been processed successfully' + expect(page).to have_text "Your order has been processed successfully" end - scenario 'associate an uncompleted guest order with user after logging in' do - user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password') - click_link 'RoR Mug' - click_button 'Add To Cart' + scenario "associate an uncompleted guest order with user after logging in" do + user = create(:user, email: "email@person.com", password: "password", password_confirmation: "password") + click_link "RoR Mug" + click_button "Add To Cart" visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' - click_link 'Cart' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" + click_link "Cart" - expect(page).to have_text 'RoR Mug' - within('h1') { expect(page).to have_text 'Shopping Cart' } + expect(page).to have_text "RoR Mug" + within("h1") { expect(page).to have_text "Shopping Cart" } - click_button 'Checkout' + click_button "Checkout" fill_addresses_fields_with(address) - click_button 'Save and Continue' + click_button "Save and Continue" - expect(page).to have_content 'UPS Ground' + expect(page).to have_content "UPS Ground" - click_button 'Save and Continue' + click_button "Save and Continue" expect(page).to have_content(/Payment Information/i) - click_button 'Save and Continue' - click_button 'Place Order' + click_button "Save and Continue" + click_button "Place Order" - expect(page).to have_text 'Your order has been processed successfully' + expect(page).to have_text "Your order has been processed successfully" expect(Spree::Order.first.user).to eq user end # Regression test for #890 - scenario 'associate an incomplete guest order with user after successful password reset' do - create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password') - click_link 'RoR Mug' - click_button 'Add To Cart' + scenario "associate an incomplete guest order with user after successful password reset" do + create(:user, email: "email@person.com", password: "password", password_confirmation: "password") + click_link "RoR Mug" + click_button "Add To Cart" visit spree.login_path - click_link 'Forgot Password?' - fill_in 'spree_user_email', with: 'email@person.com' - click_button 'Reset my password' + click_link "Forgot Password?" + fill_in "spree_user_email", with: "email@person.com" + click_button "Reset my password" # Need to do this now because the token stored in the DB is the encrypted version # The 'plain-text' version is sent in the email and there's one way to get that! @@ -125,50 +125,50 @@ token = token_url_regex.match(reset_password_email.body.to_s)[1] visit spree.edit_spree_user_password_path(reset_password_token: token) - fill_in 'Password', with: 'password' - fill_in 'Password Confirmation', with: 'password' - click_button 'Update' + fill_in "Password", with: "password" + fill_in "Password Confirmation", with: "password" + click_button "Update" - click_link 'Cart' - click_button 'Checkout' + click_link "Cart" + click_button "Checkout" fill_addresses_fields_with(address) - click_button 'Save and Continue' + click_button "Save and Continue" - expect(page).not_to have_text 'Email is invalid' + expect(page).not_to have_text "Email is invalid" end - scenario 'allow a user to register during checkout' do - click_link 'RoR Mug' - click_button 'Add To Cart' - click_button 'Checkout' + scenario "allow a user to register during checkout" do + click_link "RoR Mug" + click_button "Add To Cart" + click_button "Checkout" - expect(page).to have_text 'Registration' + expect(page).to have_text "Registration" - click_link 'Create a new account' + click_link "Create a new account" - fill_in 'Email', with: 'email@person.com' - fill_in 'Password', with: 'spree123' - fill_in 'Password Confirmation', with: 'spree123' - click_button 'Create' + fill_in "Email", with: "email@person.com" + fill_in "Password", with: "spree123" + fill_in "Password Confirmation", with: "spree123" + click_button "Create" - expect(page).to have_text 'You have signed up successfully.' + expect(page).to have_text "You have signed up successfully." fill_addresses_fields_with(address) - click_button 'Save and Continue' + click_button "Save and Continue" - expect(page).to have_content 'UPS Ground' + expect(page).to have_content "UPS Ground" - click_button 'Save and Continue' + click_button "Save and Continue" expect(page).to have_content(/Payment Information/i) - click_button 'Save and Continue' - click_button 'Place Order' + click_button "Save and Continue" + click_button "Place Order" - expect(page).to have_text 'Your order has been processed successfully' - expect(Spree::Order.first.user).to eq Spree::User.find_by(email: 'email@person.com') + expect(page).to have_text "Your order has been processed successfully" + expect(Spree::Order.first.user).to eq Spree::User.find_by(email: "email@person.com") end end end diff --git a/spec/features/confirmation_spec.rb b/spec/features/confirmation_spec.rb index f50df67c..90f7b583 100644 --- a/spec/features/confirmation_spec.rb +++ b/spec/features/confirmation_spec.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require 'spec_helper' +require "spec_helper" -RSpec.feature 'Confirmation' do +RSpec.feature "Confirmation" do before do allow(Spree::UserMailer).to receive(:confirmation_instructions) .and_return(double(deliver: true)) @@ -11,18 +11,18 @@ let!(:store) { create(:store) } background do - ActionMailer::Base.default_url_options[:host] = 'http://example.com' + ActionMailer::Base.default_url_options[:host] = "http://example.com" end - scenario 'create a new user', js: true, confirmable: false do + scenario "create a new user", js: true, confirmable: false do visit spree.signup_path - fill_in 'Email', with: 'email@person.com' - fill_in 'Password', with: 'password' - fill_in 'Password Confirmation', with: 'password' - click_button 'Create' + fill_in "Email", with: "email@person.com" + fill_in "Password", with: "password" + fill_in "Password Confirmation", with: "password" + click_button "Create" - expect(page).to have_text 'You have signed up successfully.' + expect(page).to have_text "You have signed up successfully." expect(Spree::User.last.confirmed?).to be(false) end end diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb index 70dd4f80..ee42ffc8 100644 --- a/spec/features/order_spec.rb +++ b/spec/features/order_spec.rb @@ -1,59 +1,59 @@ # frozen_string_literal: true -RSpec.feature 'Orders', :js, type: :feature do - scenario 'allow a user to view their cart at any time' do +RSpec.feature "Orders", :js, type: :feature do + scenario "allow a user to view their cart at any time" do visit spree.cart_path - expect(page).to have_text 'Your cart is empty' + expect(page).to have_text "Your cart is empty" end # regression test for spree/spree#1687 - scenario 'merge incomplete orders from different sessions' do + scenario "merge incomplete orders from different sessions" do create(:store) - create(:product, name: 'RoR Mug') - create(:product, name: 'RoR Shirt') + create(:product, name: "RoR Mug") + create(:product, name: "RoR Shirt") - user = create(:user, email: 'email@person.com', password: 'password', password_confirmation: 'password') + user = create(:user, email: "email@person.com", password: "password", password_confirmation: "password") - using_session('first') do + using_session("first") do visit spree.root_path - click_link 'RoR Mug' - click_button 'Add To Cart' + click_link "RoR Mug" + click_button "Add To Cart" visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" - click_link 'Cart' - expect(page).to have_text 'RoR Mug' + click_link "Cart" + expect(page).to have_text "RoR Mug" end - using_session('second') do + using_session("second") do visit spree.root_path - click_link 'RoR Shirt' - click_button 'Add To Cart' + click_link "RoR Shirt" + click_button "Add To Cart" visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" # Order should have been merged with first session - click_link 'Cart' - expect(page).to have_text 'RoR Mug' - expect(page).to have_text 'RoR Shirt' + click_link "Cart" + expect(page).to have_text "RoR Mug" + expect(page).to have_text "RoR Shirt" end - using_session('first') do + using_session("first") do visit spree.root_path - click_link 'Cart' + click_link "Cart" # Order should have been merged with second session - expect(page).to have_text 'RoR Mug' - expect(page).to have_text 'RoR Shirt' + expect(page).to have_text "RoR Mug" + expect(page).to have_text "RoR Shirt" end end end diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb index 70ee7a8d..02417380 100644 --- a/spec/features/password_reset_spec.rb +++ b/spec/features/password_reset_spec.rb @@ -1,37 +1,37 @@ # frozen_string_literal: true -RSpec.feature 'Reset Password', type: :feature do +RSpec.feature "Reset Password", type: :feature do let!(:store) { create(:store) } background do - ActionMailer::Base.default_url_options[:host] = 'http://example.com' + ActionMailer::Base.default_url_options[:host] = "http://example.com" end - context 'when an account with this email address exists' do - let!(:user) { create(:user, email: 'foobar@example.com', password: 'secret', password_confirmation: 'secret') } + context "when an account with this email address exists" do + let!(:user) { create(:user, email: "foobar@example.com", password: "secret", password_confirmation: "secret") } - scenario 'allows a user to supply an email for the password reset' do + scenario "allows a user to supply an email for the password reset" do visit spree.login_path - click_link 'Forgot Password?' + click_link "Forgot Password?" fill_in_email - click_button 'Reset my password' - expect(page).to have_text 'you will receive an email with instructions' + click_button "Reset my password" + expect(page).to have_text "you will receive an email with instructions" end end # Test that we are extending the functionality from # https://github.com/solidusio/solidus_auth_devise/pull/155 # to the non-admin login - scenario 'does not reveal email addresses if they are not found' do + scenario "does not reveal email addresses if they are not found" do visit spree.login_path - click_link 'Forgot Password?' + click_link "Forgot Password?" fill_in_email - click_button 'Reset my password' + click_button "Reset my password" expect(page).to_not have_text "Email not found" - expect(page).to have_text 'you will receive an email with instructions' + expect(page).to have_text "you will receive an email with instructions" end def fill_in_email - fill_in 'Email', with: 'foobar@example.com' + fill_in "Email", with: "foobar@example.com" end end diff --git a/spec/features/sign_in_spec.rb b/spec/features/sign_in_spec.rb index 006cf5ba..90d8d292 100644 --- a/spec/features/sign_in_spec.rb +++ b/spec/features/sign_in_spec.rb @@ -1,46 +1,46 @@ # frozen_string_literal: true -RSpec.feature 'Sign In', type: :feature do +RSpec.feature "Sign In", type: :feature do background do - @user = create(:user, email: 'email@person.com', password: 'secret', password_confirmation: 'secret') + @user = create(:user, email: "email@person.com", password: "secret", password_confirmation: "secret") visit spree.login_path end - scenario 'ask user to sign in' do + scenario "ask user to sign in" do visit spree.admin_path - expect(page).not_to have_text 'Authorization Failure' + expect(page).not_to have_text "Authorization Failure" end - scenario 'let a user sign in successfully' do - fill_in 'Email', with: @user.email - fill_in 'Password', with: @user.password - click_button 'Login' + scenario "let a user sign in successfully" do + fill_in "Email", with: @user.email + fill_in "Password", with: @user.password + click_button "Login" - expect(page).to have_text 'Logged in successfully' - expect(page).not_to have_text 'Login' - expect(page).to have_text 'Logout' - expect(current_path).to eq '/' + expect(page).to have_text "Logged in successfully" + expect(page).not_to have_text "Login" + expect(page).to have_text "Logout" + expect(current_path).to eq "/" end - scenario 'show validation erros' do - fill_in 'Email', with: @user.email - fill_in 'Password', with: 'wrong_password' - click_button 'Login' + scenario "show validation erros" do + fill_in "Email", with: @user.email + fill_in "Password", with: "wrong_password" + click_button "Login" - expect(page).to have_text 'Invalid email or password' - expect(page).to have_text 'Login' + expect(page).to have_text "Invalid email or password" + expect(page).to have_text "Login" end - scenario 'allow a user to access a restricted page after logging in' do - user = create(:admin_user, email: 'admin@person.com', password: 'password', password_confirmation: 'password') + scenario "allow a user to access a restricted page after logging in" do + user = create(:admin_user, email: "admin@person.com", password: "password", password_confirmation: "password") visit spree.admin_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password - click_button 'Login' + fill_in "Email", with: user.email + fill_in "Password", with: user.password + click_button "Login" - expect(page).to have_text 'admin@person.com' - expect(current_path).to eq '/admin/orders' + expect(page).to have_text "admin@person.com" + expect(current_path).to eq "/admin/orders" end it "should store the user previous location" do diff --git a/spec/features/sign_out_spec.rb b/spec/features/sign_out_spec.rb index a61f5b20..326e9edb 100644 --- a/spec/features/sign_out_spec.rb +++ b/spec/features/sign_out_spec.rb @@ -1,26 +1,26 @@ # frozen_string_literal: true -RSpec.feature 'Sign Out', type: :feature, js: true do +RSpec.feature "Sign Out", type: :feature, js: true do given!(:user) do - create(:user, - email: 'email@person.com', - password: 'secret', - password_confirmation: 'secret') + create(:user, + email: "email@person.com", + password: "secret", + password_confirmation: "secret") end background do visit spree.login_path - fill_in 'Email', with: user.email - fill_in 'Password', with: user.password + fill_in "Email", with: user.email + fill_in "Password", with: user.password # Regression test for #1257 - check 'Remember me' - click_button 'Login' + check "Remember me" + click_button "Login" end - scenario 'allow a signed in user to logout' do - click_link 'Logout' + scenario "allow a signed in user to logout" do + click_link "Logout" visit spree.root_path - expect(page).to have_text 'LOGIN' - expect(page).not_to have_text 'LOGOUT' + expect(page).to have_text "LOGIN" + expect(page).not_to have_text "LOGOUT" end end diff --git a/spec/features/sign_up_spec.rb b/spec/features/sign_up_spec.rb index 98a40dc7..356632f5 100644 --- a/spec/features/sign_up_spec.rb +++ b/spec/features/sign_up_spec.rb @@ -1,30 +1,30 @@ # frozen_string_literal: true -RSpec.feature 'Sign Up', type: :feature do - context 'with valid data' do - scenario 'create a new user' do +RSpec.feature "Sign Up", type: :feature do + context "with valid data" do + scenario "create a new user" do visit spree.signup_path - fill_in 'Email', with: 'email@person.com' - fill_in 'Password', with: 'password' - fill_in 'Password Confirmation', with: 'password' - click_button 'Create' + fill_in "Email", with: "email@person.com" + fill_in "Password", with: "password" + fill_in "Password Confirmation", with: "password" + click_button "Create" - expect(page).to have_text 'You have signed up successfully.' + expect(page).to have_text "You have signed up successfully." expect(Spree::User.count).to eq(1) end end - context 'with invalid data' do - scenario 'does not create a new user' do + context "with invalid data" do + scenario "does not create a new user" do visit spree.signup_path - fill_in 'Email', with: 'email@person.com' - fill_in 'Password', with: 'password' - fill_in 'Password Confirmation', with: '' - click_button 'Create' + fill_in "Email", with: "email@person.com" + fill_in "Password", with: "password" + fill_in "Password Confirmation", with: "" + click_button "Create" - expect(page).to have_css '#errorExplanation' + expect(page).to have_css "#errorExplanation" expect(Spree::User.count).to eq(0) end end diff --git a/spec/mailers/user_mailer_spec.rb b/spec/mailers/user_mailer_spec.rb index a5ae4904..626bbdbd 100644 --- a/spec/mailers/user_mailer_spec.rb +++ b/spec/mailers/user_mailer_spec.rb @@ -6,40 +6,40 @@ before do user = create(:user) - Spree::UserMailer.reset_password_instructions(user, 'token goes here').deliver_now + Spree::UserMailer.reset_password_instructions(user, "token goes here").deliver_now @message = ActionMailer::Base.deliveries.last end - describe '#reset_password_instructions' do - describe 'message contents' do + describe "#reset_password_instructions" do + describe "message contents" do before do - described_class.reset_password_instructions(user, 'token goes here').deliver_now + described_class.reset_password_instructions(user, "token goes here").deliver_now @message = ActionMailer::Base.deliveries.last end - context 'subject includes' do - it 'translated devise instructions' do + context "subject includes" do + it "translated devise instructions" do expect(@message.subject).to include( I18n.t(:subject, scope: [:devise, :mailer, :reset_password_instructions]) ) end - it 'Spree site name' do + it "Spree site name" do expect(@message.subject).to include store.name end end - context 'body includes' do - it 'password reset url' do + context "body includes" do + it "password reset url" do expect(@message.body.raw_source).to include "http://#{store.url}/user/spree_user/password/edit" end end end - describe 'legacy support for User object' do - it 'sends an email' do + describe "legacy support for User object" do + it "sends an email" do expect { - described_class.reset_password_instructions(user, 'token goes here').deliver_now + described_class.reset_password_instructions(user, "token goes here").deliver_now }.to change(ActionMailer::Base.deliveries, :size).by(1) end end diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index b8030b3e..7ca125ef 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -3,11 +3,11 @@ RSpec.describe Spree::Order, type: :model do let(:order) { described_class.new } - context '#associate_user!' do - let(:user) { build_stubbed(:user, email: 'spree@example.com') } + context "#associate_user!" do + let(:user) { build_stubbed(:user, email: "spree@example.com") } before { allow(order).to receive(:save!) { true } } - it 'associates the order with the specified user' do + it "associates the order with the specified user" do order.associate_user! user expect(order.user).to eq user end @@ -17,7 +17,7 @@ expect(order.email).to eq user.email end - it 'destroys any previous association with a guest user' do + it "destroys any previous association with a guest user" do guest_user = build_stubbed(:user) order.user = guest_user order.associate_user! user diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 11a1b25b..1583bea3 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true RSpec.describe Spree::User, type: :model do - before(:all) { Spree::Role.create name: 'admin' } + before(:all) { Spree::Role.create name: "admin" } - it '#admin?' do + it "#admin?" do expect(create(:admin_user).admin?).to be true expect(create(:user).admin?).to be false end @@ -11,7 +11,7 @@ context "recoverable" do let(:user) { create(:user) } - it 'generates the reset password token' do + it "generates the reset password token" do expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, {}).and_return(double(deliver: true)) expect { user.send_reset_password_instructions }.to change(user, :reset_password_token).to be_present end @@ -49,11 +49,11 @@ end end - describe '#destroy' do + describe "#destroy" do let(:user) { create(:user) } - context 'with same email address as previously deleted account' do - it 'allows users to register later' do + context "with same email address as previously deleted account" do + it "allows users to register later" do user1 = build(:user) user1.save @@ -68,10 +68,10 @@ end end - describe '#destroy' do + describe "#destroy" do let(:user) { create(:user) } - it 'removes the record from the database' do + it "removes the record from the database" do user.destroy if defined?(Spree::ParanoiaDeprecations) @@ -82,10 +82,10 @@ end end - describe '#really_destroy!', if: defined?(Spree::ParanoiaDeprecations) do + describe "#really_destroy!", if: defined?(Spree::ParanoiaDeprecations) do let(:user) { create(:user) } - it 'removes the record from the database' do + it "removes the record from the database" do user.really_destroy! expect(Spree::User.with_deleted.exists?(id: user.id)).to eql false end diff --git a/spec/requests/spree/frontend/user_update_spec.rb b/spec/requests/spree/frontend/user_update_spec.rb index f569199e..75e0c01f 100644 --- a/spec/requests/spree/frontend/user_update_spec.rb +++ b/spec/requests/spree/frontend/user_update_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -RSpec.feature 'User update', type: :request do - context 'CSRF protection' do +RSpec.feature "User update", type: :request do + context "CSRF protection" do %i[exception reset_session null_session].each do |strategy| # Completely clean the configuration of forgery protection for the # controller and reset it after the expectations. However, besides `:with`, @@ -25,17 +25,17 @@ end it "is not possible to take account over with the #{strategy} forgery protection strategy" do - user = create(:user, email: 'legit@mail.com', password: 'password') + user = create(:user, email: "legit@mail.com", password: "password") - post '/login', params: "spree_user[email]=legit@mail.com&spree_user[password]=password" + post "/login", params: "spree_user[email]=legit@mail.com&spree_user[password]=password" begin - put '/users/123456', params: 'user[email]=hacked@example.com' + put "/users/123456", params: "user[email]=hacked@example.com" rescue # testing that the account is not compromised regardless of any raised # exception end - expect(user.reload.email).to eq('legit@mail.com') + expect(user.reload.email).to eq("legit@mail.com") end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index aabfc06f..7837e78c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,20 @@ # frozen_string_literal: true # Configure Rails Environment -ENV['RAILS_ENV'] = 'test' +ENV["RAILS_ENV"] = "test" -require 'rails-controller-testing' +require "rails-controller-testing" # Run Coverage report -require 'solidus_dev_support/rspec/coverage' +require "solidus_dev_support/rspec/coverage" # Create the dummy app if it's still missing. dummy_env = "#{__dir__}/dummy/config/environment.rb" -system 'bin/rake extension:test_app' unless File.exist? dummy_env +system "bin/rake extension:test_app" unless File.exist? dummy_env require dummy_env # Requires factories and other useful helpers defined in spree_core. -require 'solidus_dev_support/rspec/feature_helper' +require "solidus_dev_support/rspec/feature_helper" # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. @@ -27,7 +27,7 @@ config.infer_spec_type_from_file_location! config.use_transactional_fixtures = false - if Spree.solidus_gem_version < Gem::Version.new('2.11') + if Spree.solidus_gem_version < Gem::Version.new("2.11") config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system end end diff --git a/spec/support/authentication_helpers.rb b/spec/support/authentication_helpers.rb index 5366f130..7abe7e87 100644 --- a/spec/support/authentication_helpers.rb +++ b/spec/support/authentication_helpers.rb @@ -2,10 +2,10 @@ module AuthenticationHelpers def sign_in_as!(user) - visit '/login' - fill_in 'Email', with: user.email - fill_in 'Password', with: 'secret' - click_button 'Login' + visit "/login" + fill_in "Email", with: user.email + fill_in "Password", with: "secret" + click_button "Login" end end diff --git a/spec/support/confirm_helpers.rb b/spec/support/confirm_helpers.rb index cfdf85c4..7d4c3b6d 100644 --- a/spec/support/confirm_helpers.rb +++ b/spec/support/confirm_helpers.rb @@ -9,7 +9,7 @@ example.run ensure Spree.send(:remove_const, :User) - Spree.const_set('User', old_user) + Spree.const_set(:User, old_user) end else example.run @@ -21,7 +21,7 @@ stub_spree_preferences(Spree::Auth::Config, confirmable: example.metadata[:confirmable]) Spree.send(:remove_const, :User) - load File.expand_path('../../../app/models/spree/user.rb', __FILE__) + load File.expand_path("../../../app/models/spree/user.rb", __FILE__) end end end diff --git a/spec/support/features/fill_addresses_fields.rb b/spec/support/features/fill_addresses_fields.rb index 8beb82a7..f1c79787 100644 --- a/spec/support/features/fill_addresses_fields.rb +++ b/spec/support/features/fill_addresses_fields.rb @@ -17,10 +17,10 @@ def fill_addresses_fields_with(address) fields.each do |field| fill_in "order_bill_address_attributes_#{field}", with: address.send(field).to_s end - select 'United States', from: "order_bill_address_attributes_country_id" + select "United States", from: "order_bill_address_attributes_country_id" select address.state.name.to_s, from: "order_bill_address_attributes_state_id" - check 'order_use_billing' + check "order_use_billing" end end diff --git a/spec/support/spree.rb b/spec/support/spree.rb index 79579c78..23110f46 100644 --- a/spec/support/spree.rb +++ b/spec/support/spree.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'spree/testing_support/url_helpers' -require 'spree/testing_support/controller_requests' -require 'spree/testing_support/authorization_helpers' -require 'spree/testing_support/capybara_ext' +require "spree/testing_support/url_helpers" +require "spree/testing_support/controller_requests" +require "spree/testing_support/authorization_helpers" +require "spree/testing_support/capybara_ext" RSpec.configure do |config| config.include Spree::TestingSupport::UrlHelpers From 888feee51a9598af90e7533c95d7a71e3a083726 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 15 May 2025 16:19:02 +0200 Subject: [PATCH 27/49] Ignore syntax fixing commit We don't need this in git blame. --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .git-blame-ignore-revs diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 00000000..1aca1b41 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,2 @@ +# Ignore standardrb --fix commit +eaba0e4370a03d10a6064466a9197c330bb92c64 From b4f178af090c18d70033247734f1ef12c9973d28 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 31 Jul 2025 18:06:46 -0600 Subject: [PATCH 28/49] Pin state_machines to 0.6.0 See https://github.com/solidusio/solidus/pull/6286 for rationale --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index ac76ebf0..22dbb571 100644 --- a/Gemfile +++ b/Gemfile @@ -51,3 +51,6 @@ gemspec # We use `send` instead of calling `eval_gemfile` to work around an issue with # how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658. send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local" + +# Pin state_machines +gem "state_machines", "= 0.6.0" From 4c9e49e8602b55bda10477bc65aef5e372decd21 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 1 Aug 2025 10:13:15 -0600 Subject: [PATCH 29/49] Feature specs: Navigate via links rather than visits We want to test the site like a real user, not like someone constantly changing the URL bar in a browser. Let's have the specs click links. --- spec/features/checkout_spec.rb | 4 ++-- spec/features/order_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index db2e548d..db481e90 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -80,7 +80,7 @@ click_link "RoR Mug" click_button "Add To Cart" - visit spree.login_path + click_link "Login" fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" @@ -113,7 +113,7 @@ click_link "RoR Mug" click_button "Add To Cart" - visit spree.login_path + click_link "Login" click_link "Forgot Password?" fill_in "spree_user_email", with: "email@person.com" click_button "Reset my password" diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb index ee42ffc8..4b2c0b2b 100644 --- a/spec/features/order_spec.rb +++ b/spec/features/order_spec.rb @@ -20,7 +20,7 @@ click_link "RoR Mug" click_button "Add To Cart" - visit spree.login_path + click_link "Login" fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" @@ -35,7 +35,7 @@ click_link "RoR Shirt" click_button "Add To Cart" - visit spree.login_path + click_link "Login" fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" From fa0b6c22d9e60bf5480174647767b742f164a5ae Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 1 Aug 2025 12:23:19 -0600 Subject: [PATCH 30/49] Checkout spec: Wait for mail delivery This spec was flaky before, because it did not wait for the page to have any changes. --- spec/features/checkout_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index db481e90..67142382 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -117,6 +117,7 @@ click_link "Forgot Password?" fill_in "spree_user_email", with: "email@person.com" click_button "Reset my password" + expect(page).to have_content("you will receive an email with instructions") # Need to do this now because the token stored in the DB is the encrypted version # The 'plain-text' version is sent in the email and there's one way to get that! From 778cc592e116a22cf79911fd2918ea4e97f9eb7a Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 22:02:16 +0100 Subject: [PATCH 31/49] Add rspec binstub Useful and common to have a bin/rspec --- bin/rspec | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 bin/rspec diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000..93e191c2 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") From 2d8c1cc18a347bc0ef541d9b803528003c838935 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 22:02:43 +0100 Subject: [PATCH 32/49] fix(order_spec): Expect to be logged in Before accessing the cart we need to expect to be logged in. --- spec/features/order_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb index 4b2c0b2b..fca0fd56 100644 --- a/spec/features/order_spec.rb +++ b/spec/features/order_spec.rb @@ -24,6 +24,7 @@ fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" click_link "Cart" expect(page).to have_text "RoR Mug" From ae21f74e3776636729e351000712d7f61b7ba308 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 22:07:05 +0100 Subject: [PATCH 33/49] chore: Fix linting --- app/models/spree/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/spree/user.rb b/app/models/spree/user.rb index 9c53e602..3ab29c11 100644 --- a/app/models/spree/user.rb +++ b/app/models/spree/user.rb @@ -15,6 +15,7 @@ class User < Spree::Base include Spree::ParanoiaDeprecations include Discard::Model + self.discard_column = :deleted_at end From 9247cb6e3e3782ab8bd9f89ef28ca606ee73dc78 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 22:42:39 +0100 Subject: [PATCH 34/49] CI: Run tests on GH actions We want to get rid of circle-ci. Extension by extension. --- .circleci/config.yml | 73 -------------------------------------- .github/workflows/test.yml | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 73 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index eb47bec3..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,73 +0,0 @@ -version: 2.1 - -orbs: - # Required for feature specs. - browser-tools: circleci/browser-tools@1.1 - - # Always take the latest version of the orb, this allows us to - # run specs against Solidus supported versions only without the need - # to change this configuration every time a Solidus version is released - # or goes EOL. - solidusio_extensions: solidusio/extensions@volatile - -jobs: - run-specs: - parameters: - solidus: - type: string - default: main - db: - type: string - default: "postgres" - ruby: - type: string - default: "3.2" - executor: - name: solidusio_extensions/<< parameters.db >> - ruby_version: << parameters.ruby >> - steps: - - checkout - - browser-tools/install-chrome - - solidusio_extensions/run-tests-solidus-<< parameters.solidus >> - - lint-code: - executor: - name: solidusio_extensions/sqlite - ruby_version: "3.1" - steps: - - solidusio_extensions/lint-code - -workflows: - "Run specs on supported Solidus versions": - jobs: - - run-specs: - name: &name "run-specs-solidus-<< matrix.solidus >>-ruby-<< matrix.ruby >>-db-<< matrix.db >>" - matrix: - parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] } - - run-specs: - name: *name - matrix: - parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] } - - run-specs: - name: *name - matrix: - parameters: { solidus: ["older"], ruby: ["3.0"], db: ["sqlite"] } - - lint-code - - "Weekly run specs against main": - triggers: - - schedule: - cron: "0 0 * * 4" # every Thursday - filters: - branches: - only: - - main - jobs: - - run-specs: - name: *name - matrix: - parameters: { solidus: ["main"], ruby: ["3.2"], db: ["postgres"] } - - run-specs: - name: *name - matrix: - parameters: { solidus: ["current"], ruby: ["3.1"], db: ["mysql"] } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..626f1b62 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,62 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + schedule: + - cron: "0 0 * * 4" # every Thursday + +concurrency: + group: test-${{ github.ref_name }} + cancel-in-progress: ${{ github.ref_name != 'main' }} + +permissions: + contents: read + +jobs: + rspec: + name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} + runs-on: ubuntu-24.04 + strategy: + fail-fast: false + matrix: + rails-version: + - "7.2" + - "8.0" + ruby-version: + - "3.1" + - "3.4" + solidus-branch: + - "v4.4" + - "v4.5" + - "v4.6" + database: + - "postgresql" + - "mysql" + - "sqlite" + exclude: + - solidus-branch: "v4.5" + ruby-version: "3.1" + - solidus-branch: "v4.6" + ruby-version: "3.1" + - solidus-branch: "v4.4" + rails-version: "8.0" + env: + TEST_RESULTS_PATH: coverage/coverage.xml + steps: + - uses: actions/checkout@v4 + - name: Run extension tests + uses: solidusio/test-solidus-extension@main + with: + database: ${{ matrix.database }} + rails-version: ${{ matrix.rails-version }} + ruby-version: ${{ matrix.ruby-version }} + solidus-branch: ${{ matrix.solidus-branch }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 + continue-on-error: true + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ env.TEST_RESULTS_PATH }} From 14b9b7ba16fb962ea9e585e650b9196bd4aeed11 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 23:17:40 +0100 Subject: [PATCH 35/49] test: Harden feature specs We need to wait for the page to load before clicking links or making assumptions about its content. --- spec/features/account_spec.rb | 3 +++ spec/features/admin/sign_out_spec.rb | 1 + spec/features/admin_permissions_spec.rb | 1 + spec/features/change_email_spec.rb | 1 + spec/features/checkout_spec.rb | 4 ++++ spec/features/order_spec.rb | 1 + spec/features/sign_in_spec.rb | 1 + spec/features/sign_out_spec.rb | 1 + spec/support/features/fill_addresses_fields.rb | 2 ++ 9 files changed, 15 insertions(+) diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index 93c89d0f..c47d650c 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -9,6 +9,7 @@ fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" click_link "My Account" expect(page).to have_text "admin@person.com" @@ -22,6 +23,7 @@ fill_in "Password", with: "password" fill_in "Password Confirmation", with: "password" click_button "Create" + expect(page).to have_text "You have signed up successfully" click_link "My Account" expect(page).to have_text "email@person.com" @@ -43,6 +45,7 @@ fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" click_link "My Account" expect(page).to have_text "email@person.com" diff --git a/spec/features/admin/sign_out_spec.rb b/spec/features/admin/sign_out_spec.rb index ce6aaf8d..f50832bf 100644 --- a/spec/features/admin/sign_out_spec.rb +++ b/spec/features/admin/sign_out_spec.rb @@ -12,6 +12,7 @@ # Regression test for #1257 check "Remember me" click_button "Login" + expect(page).to have_text "Logged in successfully" end scenario "allows a signed in user to logout" do diff --git a/spec/features/admin_permissions_spec.rb b/spec/features/admin_permissions_spec.rb index 31f0ea78..2a1f1495 100644 --- a/spec/features/admin_permissions_spec.rb +++ b/spec/features/admin_permissions_spec.rb @@ -10,6 +10,7 @@ fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" end context "admin is restricted from accessing orders" do diff --git a/spec/features/change_email_spec.rb b/spec/features/change_email_spec.rb index 168cab27..5c2c4d03 100644 --- a/spec/features/change_email_spec.rb +++ b/spec/features/change_email_spec.rb @@ -11,6 +11,7 @@ fill_in "spree_user[email]", with: user.email fill_in "spree_user[password]", with: "secret" click_button "Login" + expect(page).to have_text "Logged in successfully" visit spree.edit_account_path end diff --git a/spec/features/checkout_spec.rb b/spec/features/checkout_spec.rb index 67142382..f309a18a 100644 --- a/spec/features/checkout_spec.rb +++ b/spec/features/checkout_spec.rb @@ -79,11 +79,13 @@ user = create(:user, email: "email@person.com", password: "password", password_confirmation: "password") click_link "RoR Mug" click_button "Add To Cart" + within("h1") { expect(page).to have_text "Shopping Cart" } click_link "Login" fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" click_link "Cart" expect(page).to have_text "RoR Mug" @@ -112,6 +114,7 @@ create(:user, email: "email@person.com", password: "password", password_confirmation: "password") click_link "RoR Mug" click_button "Add To Cart" + within("h1") { expect(page).to have_text "Shopping Cart" } click_link "Login" click_link "Forgot Password?" @@ -142,6 +145,7 @@ scenario "allow a user to register during checkout" do click_link "RoR Mug" click_button "Add To Cart" + within("h1") { expect(page).to have_text "Shopping Cart" } click_button "Checkout" expect(page).to have_text "Registration" diff --git a/spec/features/order_spec.rb b/spec/features/order_spec.rb index fca0fd56..2fc932e1 100644 --- a/spec/features/order_spec.rb +++ b/spec/features/order_spec.rb @@ -40,6 +40,7 @@ fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Login" + expect(page).to have_text "Logged in successfully" # Order should have been merged with first session click_link "Cart" diff --git a/spec/features/sign_in_spec.rb b/spec/features/sign_in_spec.rb index 90d8d292..be00d392 100644 --- a/spec/features/sign_in_spec.rb +++ b/spec/features/sign_in_spec.rb @@ -48,6 +48,7 @@ fill_in "Email", with: @user.email fill_in "Password", with: @user.password click_button "Login" + expect(page).to have_text "Logged in successfully" expect(current_path).to eq "/account" end end diff --git a/spec/features/sign_out_spec.rb b/spec/features/sign_out_spec.rb index 326e9edb..25aa368b 100644 --- a/spec/features/sign_out_spec.rb +++ b/spec/features/sign_out_spec.rb @@ -15,6 +15,7 @@ # Regression test for #1257 check "Remember me" click_button "Login" + expect(page).to have_text "Logged in successfully" end scenario "allow a signed in user to logout" do diff --git a/spec/support/features/fill_addresses_fields.rb b/spec/support/features/fill_addresses_fields.rb index f1c79787..a155fd01 100644 --- a/spec/support/features/fill_addresses_fields.rb +++ b/spec/support/features/fill_addresses_fields.rb @@ -14,6 +14,8 @@ def fill_addresses_fields_with(address) %w[firstname lastname] end + expect(page).to have_text "Billing Address" + fields.each do |field| fill_in "order_bill_address_attributes_#{field}", with: address.send(field).to_s end From 2ec4a45240e9590172a6da5b70a4e3a3509cf01b Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 23:32:32 +0100 Subject: [PATCH 36/49] CI: Run feature tests with Firefox Chrome is a buggy piece of... --- .github/workflows/test.yml | 1 + spec/spec_helper.rb | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 626f1b62..8f471185 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,6 +45,7 @@ jobs: rails-version: "8.0" env: TEST_RESULTS_PATH: coverage/coverage.xml + CAPYBARA_JAVASCRIPT_DRIVER: selenium_headless steps: - uses: actions/checkout@v4 - name: Run extension tests diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 7837e78c..d7b411a4 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,12 @@ # Requires factories and other useful helpers defined in spree_core. require "solidus_dev_support/rspec/feature_helper" +Capybara::Screenshot.register_driver(:selenium_headless) do |driver, path| + driver.browser.save_screenshot(path) +end + +Capybara.javascript_driver = :selenium_headless + # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f } From 046cbcfd8339396c1d2b78360ee47386bc557e19 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 23:42:10 +0100 Subject: [PATCH 37/49] chore: Update Test badge on README We use GH actions now --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0739fbaf..4f6f54ec 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Solidus Auth Devise -[![CircleCI](https://circleci.com/gh/solidusio/solidus_auth_devise.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_auth_devise) +[![Test](https://github.com/solidusio/solidus_auth_devise/actions/workflows/test.yml/badge.svg)](https://github.com/solidusio/solidus_auth_devise/actions/workflows/test.yml) [![codecov](https://codecov.io/gh/solidusio/solidus_auth_devise/branch/main/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_auth_devise) Provides authentication services for Solidus, using the Devise gem. From 9042939bcb5a90bd4abe2a3bcc8fb73adbb786dc Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 23:54:31 +0100 Subject: [PATCH 38/49] test: Fix admin signout spec We need to create a admin user --- spec/features/admin/sign_out_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/admin/sign_out_spec.rb b/spec/features/admin/sign_out_spec.rb index f50832bf..85ae29fc 100644 --- a/spec/features/admin/sign_out_spec.rb +++ b/spec/features/admin/sign_out_spec.rb @@ -2,7 +2,7 @@ RSpec.feature "Admin - Sign Out", type: :feature, js: true do given!(:user) do - create :user, email: "email@person.com" + create :admin_user, email: "email@person.com" end background do From 3c2f23557a314ec57783ba24debd4285505fa3f6 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 31 Jul 2025 16:05:10 -0600 Subject: [PATCH 39/49] Use ActiveRecord::Migration instead of SolidusSupport::Migration `SolidusSupport::Migration[4.2]` is deprecated in favor of `ActiveRecord::Migration[4.2]`. This cleans up the test logs of many other gems, because solidus_auth_devise is used in many extension test suites. --- db/migrate/20101026184949_create_users.rb | 2 +- db/migrate/20101026184950_rename_columns_for_devise.rb | 2 +- db/migrate/20101214150824_convert_user_remember_field.rb | 2 +- .../20120203010234_add_reset_password_sent_at_to_spree_users.rb | 2 +- db/migrate/20120605211305_make_users_email_index_unique.rb | 2 +- db/migrate/20140904000425_add_deleted_at_to_users.rb | 2 +- db/migrate/20141002154641_add_confirmable_to_users.rb | 2 +- ...90125170630_add_reset_password_token_index_to_spree_users.rb | 2 +- .../20200417153503_add_unconfirmed_email_to_spree_users.rb | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/db/migrate/20101026184949_create_users.rb b/db/migrate/20101026184949_create_users.rb index c5d1809a..e0622974 100644 --- a/db/migrate/20101026184949_create_users.rb +++ b/db/migrate/20101026184949_create_users.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class CreateUsers < SolidusSupport::Migration[4.2] +class CreateUsers < ActiveRecord::Migration[4.2] def up unless table_exists?("spree_users") create_table "spree_users", force: true do |t| diff --git a/db/migrate/20101026184950_rename_columns_for_devise.rb b/db/migrate/20101026184950_rename_columns_for_devise.rb index 5b9dbb33..a7c74e84 100644 --- a/db/migrate/20101026184950_rename_columns_for_devise.rb +++ b/db/migrate/20101026184950_rename_columns_for_devise.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class RenameColumnsForDevise < SolidusSupport::Migration[4.2] +class RenameColumnsForDevise < ActiveRecord::Migration[4.2] def up return if column_exists?(:spree_users, :password_salt) diff --git a/db/migrate/20101214150824_convert_user_remember_field.rb b/db/migrate/20101214150824_convert_user_remember_field.rb index ba354b67..25fb2502 100644 --- a/db/migrate/20101214150824_convert_user_remember_field.rb +++ b/db/migrate/20101214150824_convert_user_remember_field.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ConvertUserRememberField < SolidusSupport::Migration[4.2] +class ConvertUserRememberField < ActiveRecord::Migration[4.2] def up remove_column :spree_users, :remember_created_at add_column :spree_users, :remember_created_at, :datetime diff --git a/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb b/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb index a45df829..988e483a 100644 --- a/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb +++ b/db/migrate/20120203010234_add_reset_password_sent_at_to_spree_users.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddResetPasswordSentAtToSpreeUsers < SolidusSupport::Migration[4.2] +class AddResetPasswordSentAtToSpreeUsers < ActiveRecord::Migration[4.2] def change Spree::User.reset_column_information unless Spree::User.column_names.include?("reset_password_sent_at") diff --git a/db/migrate/20120605211305_make_users_email_index_unique.rb b/db/migrate/20120605211305_make_users_email_index_unique.rb index 89080ae8..f521eed0 100644 --- a/db/migrate/20120605211305_make_users_email_index_unique.rb +++ b/db/migrate/20120605211305_make_users_email_index_unique.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class MakeUsersEmailIndexUnique < SolidusSupport::Migration[4.2] +class MakeUsersEmailIndexUnique < ActiveRecord::Migration[4.2] def up add_index "spree_users", ["email"], name: "email_idx_unique", unique: true end diff --git a/db/migrate/20140904000425_add_deleted_at_to_users.rb b/db/migrate/20140904000425_add_deleted_at_to_users.rb index 824ddb6e..b98ec13b 100644 --- a/db/migrate/20140904000425_add_deleted_at_to_users.rb +++ b/db/migrate/20140904000425_add_deleted_at_to_users.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddDeletedAtToUsers < SolidusSupport::Migration[4.2] +class AddDeletedAtToUsers < ActiveRecord::Migration[4.2] def change add_column :spree_users, :deleted_at, :datetime add_index :spree_users, :deleted_at diff --git a/db/migrate/20141002154641_add_confirmable_to_users.rb b/db/migrate/20141002154641_add_confirmable_to_users.rb index 6e932b85..c319f5ca 100644 --- a/db/migrate/20141002154641_add_confirmable_to_users.rb +++ b/db/migrate/20141002154641_add_confirmable_to_users.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddConfirmableToUsers < SolidusSupport::Migration[4.2] +class AddConfirmableToUsers < ActiveRecord::Migration[4.2] def change add_column :spree_users, :confirmation_token, :string add_column :spree_users, :confirmed_at, :datetime diff --git a/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb b/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb index e6e69919..ced11714 100644 --- a/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb +++ b/db/migrate/20190125170630_add_reset_password_token_index_to_spree_users.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class AddResetPasswordTokenIndexToSpreeUsers < SolidusSupport::Migration[4.2] +class AddResetPasswordTokenIndexToSpreeUsers < ActiveRecord::Migration[4.2] # We're not using the standard Rails index name because somebody could have #  already added that index to the table. By using a custom name we ensure # that the index can effectively be added and removed via migrations/rollbacks diff --git a/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb b/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb index c1c69786..083fe8d5 100644 --- a/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb +++ b/db/migrate/20200417153503_add_unconfirmed_email_to_spree_users.rb @@ -1,4 +1,4 @@ -class AddUnconfirmedEmailToSpreeUsers < SolidusSupport::Migration[5.1] +class AddUnconfirmedEmailToSpreeUsers < ActiveRecord::Migration[5.1] def change unless column_exists?(:spree_users, :unconfirmed_email) add_column :spree_users, :unconfirmed_email, :string From 0801c7d191a4878dbeaffe0b551040019911c2bb Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sun, 4 Jan 2026 15:48:17 +0100 Subject: [PATCH 40/49] CI: Setup database services We need this to test the various database adapters, as compoiste actions do not support starting services. Ignoring mysql/mariadb builds for Rails 8.0 because of https://github.com/rails/rails/issues/53673, which has not been backported to Rails 8.0 yet. --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f471185..0e720ea1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,29 @@ jobs: rspec: name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} runs-on: ubuntu-24.04 + services: + postgres: + image: postgres:16 + env: + POSTGRES_HOST_AUTH_METHOD: trust + options: >- + --health-cmd="pg_isready" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + ports: + - 5432:5432 + mysql: + image: mysql:8 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: "yes" + options: >- + --health-cmd="mysqladmin ping" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + ports: + - 3306:3306 strategy: fail-fast: false matrix: @@ -43,6 +66,8 @@ jobs: ruby-version: "3.1" - solidus-branch: "v4.4" rails-version: "8.0" + - database: "mysql" # https://github.com/rails/rails/issues/53673 + rails-version: "8.0" env: TEST_RESULTS_PATH: coverage/coverage.xml CAPYBARA_JAVASCRIPT_DRIVER: selenium_headless From 5932e0c3ab080b13c643f885b283c0b944c6c803 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 5 Jan 2026 10:34:59 +0100 Subject: [PATCH 41/49] fix(Gemfile): Make sure we install latest patch level of Rails Without this we are not sure that the latest patch level gets installed by bundler. --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 22dbb571..b6ae6ad6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,8 +7,8 @@ branch = ENV.fetch("SOLIDUS_BRANCH", "main") gem "solidus", github: "solidusio/solidus", branch: branch gem "solidus_backend", github: "solidusio/solidus", branch: branch -rails_requirement_string = ENV.fetch("RAILS_VERSION", "~> 7.0") -gem "rails", rails_requirement_string +rails_requirement_string = ENV.fetch("RAILS_VERSION", "7.0") +gem "rails", "~> #{rails_requirement_string}" # The solidus_frontend gem has been pulled out since v3.2 if branch >= "v3.2" From b0e101ace62a4eb396773be1cc1fb13d8e773a60 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Mon, 5 Jan 2026 10:36:18 +0100 Subject: [PATCH 42/49] CI: Test Rails 8.0 and mysql again Now that we make sure bundler installs latest Rails patch levels we can hopefully test MySQL with Rails 8.0 again. --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e720ea1..dab0950b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,8 +66,6 @@ jobs: ruby-version: "3.1" - solidus-branch: "v4.4" rails-version: "8.0" - - database: "mysql" # https://github.com/rails/rails/issues/53673 - rails-version: "8.0" env: TEST_RESULTS_PATH: coverage/coverage.xml CAPYBARA_JAVASCRIPT_DRIVER: selenium_headless From fea426a0e1643f3cefeb8e674b9781846069bfc5 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sun, 4 Jan 2026 21:40:10 +0100 Subject: [PATCH 43/49] CI: Use Solidus' reusable GH workflow for testing Instead of setting up all services and the matrix in this extension we use the new reusable workflow that handles this for us. Needs https://github.com/solidusio/test-solidus-extension/pull/3 --- .github/workflows/test.yml | 70 ++------------------------------------ 1 file changed, 2 insertions(+), 68 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dab0950b..61d087d6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,71 +16,5 @@ permissions: contents: read jobs: - rspec: - name: Solidus ${{ matrix.solidus-branch }}, Rails ${{ matrix.rails-version }} and Ruby ${{ matrix.ruby-version }} on ${{ matrix.database }} - runs-on: ubuntu-24.04 - services: - postgres: - image: postgres:16 - env: - POSTGRES_HOST_AUTH_METHOD: trust - options: >- - --health-cmd="pg_isready" - --health-interval=10s - --health-timeout=5s - --health-retries=5 - ports: - - 5432:5432 - mysql: - image: mysql:8 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: "yes" - options: >- - --health-cmd="mysqladmin ping" - --health-interval=10s - --health-timeout=5s - --health-retries=5 - ports: - - 3306:3306 - strategy: - fail-fast: false - matrix: - rails-version: - - "7.2" - - "8.0" - ruby-version: - - "3.1" - - "3.4" - solidus-branch: - - "v4.4" - - "v4.5" - - "v4.6" - database: - - "postgresql" - - "mysql" - - "sqlite" - exclude: - - solidus-branch: "v4.5" - ruby-version: "3.1" - - solidus-branch: "v4.6" - ruby-version: "3.1" - - solidus-branch: "v4.4" - rails-version: "8.0" - env: - TEST_RESULTS_PATH: coverage/coverage.xml - CAPYBARA_JAVASCRIPT_DRIVER: selenium_headless - steps: - - uses: actions/checkout@v4 - - name: Run extension tests - uses: solidusio/test-solidus-extension@main - with: - database: ${{ matrix.database }} - rails-version: ${{ matrix.rails-version }} - ruby-version: ${{ matrix.ruby-version }} - solidus-branch: ${{ matrix.solidus-branch }} - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v5 - continue-on-error: true - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ${{ env.TEST_RESULTS_PATH }} + Test: + uses: solidusio/test-solidus-extension/.github/workflows/test.yml@v1 From 3696346159d079fd69a832e1ca4410bbf46ed50c Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 21:42:46 +0100 Subject: [PATCH 44/49] Allow Ruby 4.0 --- solidus_auth_devise.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidus_auth_devise.gemspec b/solidus_auth_devise.gemspec index 09c8a717..926c7ab9 100644 --- a/solidus_auth_devise.gemspec +++ b/solidus_auth_devise.gemspec @@ -16,7 +16,7 @@ Gem::Specification.new do |spec| spec.metadata["source_code_uri"] = "https://github.com/solidusio/solidus_auth_devise" spec.metadata["changelog_uri"] = "https://github.com/solidusio/solidus_auth_devise/releases" - spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 4") + spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 5") # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. From f4816a1c47b810daccbf3f0ab38288c8b8c768c3 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 2 Jan 2026 21:42:57 +0100 Subject: [PATCH 45/49] CI: Test latest Ruby versions --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61d087d6..0c96e40c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,3 +18,5 @@ permissions: jobs: Test: uses: solidusio/test-solidus-extension/.github/workflows/test.yml@v1 + with: + ruby_versions: "['3.4', '4.0']" From 7c66bec432a9b64dbaadb05a9e89c835feb3e4b0 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Sat, 3 Jan 2026 00:25:51 +0100 Subject: [PATCH 46/49] chore: Add benchmark gem locally Not part of Ruby 4.0 anymore. Necessary for github_changelog_generator --- Gemfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gemfile b/Gemfile index b6ae6ad6..3bc89949 100644 --- a/Gemfile +++ b/Gemfile @@ -54,3 +54,8 @@ send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local" # Pin state_machines gem "state_machines", "= 0.6.0" + +if RUBY_VERSION >= "4.0" + # Necessary for github_changelog_generator + gem "benchmark", "~> 0.5.0" +end From 8d9387ae8a84bbc73756c177303021ad5f2eb8f4 Mon Sep 17 00:00:00 2001 From: Jared Norman Date: Tue, 20 Jan 2026 16:05:06 -0800 Subject: [PATCH 47/49] Relax Devise version constraint Version 5.0 might actually be coming and the RC contains Rails 8 (lazy loaded routes) fixes. --- solidus_auth_devise.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solidus_auth_devise.gemspec b/solidus_auth_devise.gemspec index 926c7ab9..17c61029 100644 --- a/solidus_auth_devise.gemspec +++ b/solidus_auth_devise.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.require_paths = ["lib"] spec.add_dependency "deface", "~> 1.0" - spec.add_dependency "devise", "~> 4.1" + spec.add_dependency "devise", ">= 4.1" spec.add_dependency "devise-encryptable", "0.2.0" spec.add_dependency "solidus_core", [">= 3", "< 5"] spec.add_dependency "solidus_support", "~> 0.11" From 7aaf780021444266e28ab1f4f07c94495c17ab41 Mon Sep 17 00:00:00 2001 From: Ben Akroyd Date: Tue, 7 Apr 2026 14:25:21 -0400 Subject: [PATCH 48/49] fix: update mailer mock to use deliver_now for Devise 5 compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Devise 5 changed send_devise_notification to call deliver_now instead of deliver. The test double only stubbed deliver, causing a failure. This is a test-only change — real ActionMailer objects respond to both methods. --- spec/models/user_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 1583bea3..54a6e203 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -12,7 +12,7 @@ let(:user) { create(:user) } it "generates the reset password token" do - expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, {}).and_return(double(deliver: true)) + expect(Spree::UserMailer).to receive(:reset_password_instructions).with(user, anything, {}).and_return(double(deliver_now: true)) expect { user.send_reset_password_instructions }.to change(user, :reset_password_token).to be_present end From 2359b8094a45b71348a04f5f5e0c0f73cbee9125 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Wed, 8 Apr 2026 18:22:06 +0200 Subject: [PATCH 49/49] Bump SolidusAuthDevise to 2.6.0 --- lib/solidus_auth_devise/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solidus_auth_devise/version.rb b/lib/solidus_auth_devise/version.rb index 1b4d3c80..f09769a3 100644 --- a/lib/solidus_auth_devise/version.rb +++ b/lib/solidus_auth_devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SolidusAuthDevise - VERSION = "2.5.9" + VERSION = "2.6.0" end