From 7cd5bbbf72cc24b5ce99334c735139f2b991ffc9 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 11 Jan 2024 13:42:54 +0100 Subject: [PATCH 1/4] Test with Rails 7.1 --- .github/workflows/ci.yml | 4 ++++ Gemfile | 3 ++- spec/controllers/admin/users_controller_spec.rb | 8 ++++---- spec/dummy/config/application.rb | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7eaf155..167cccb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,9 @@ jobs: - "3.1" - "3.2" - "3.3" + rails: + - "7.0" + - "7.1" database: - mysql - postgresql @@ -25,6 +28,7 @@ jobs: DB_PASSWORD: password DB_HOST: "127.0.0.1" RAILS_ENV: test + RAILS_VERSION: ${{ matrix.rails }} ALCHEMY_BRANCH: ${{ matrix.alchemy_branch }} services: postgres: diff --git a/Gemfile b/Gemfile index 4a77824..fac0d4a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,8 @@ source "https://rubygems.org" alchemy_branch = ENV.fetch("ALCHEMY_BRANCH", "main") gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: alchemy_branch -gem "rails", "~> 7.0.0" +rails_version = ENV.fetch("RAILS_VERSION", "7.1") +gem "rails", "~> #{rails_version}.0" gem "listen", "~> 3.8" gem "puma", "~> 6.0" diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 1436193..24aa22f 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -122,7 +122,7 @@ module Alchemy } expect(user) .to receive(:update_without_password) - .with(params_hash).and_return(true) + .with(ActionController::Parameters.new(params_hash).permit!).and_return(true) post :update, params: {id: user.id, user: params_hash, format: :js} end @@ -135,7 +135,7 @@ module Alchemy "password" => "newpassword", "password_confirmation" => "newpassword" } - expect(user).to receive(:update).with(params_hash) + expect(user).to receive(:update).with(ActionController::Parameters.new(params_hash).permit!) post :update, params: {id: user.id, user: params_hash, format: :js} end @@ -177,7 +177,7 @@ module Alchemy it "updates the user including role" do expect(user) .to receive(:update_without_password) - .with({"alchemy_roles" => ["Administrator"]}) + .with(ActionController::Parameters.new({"alchemy_roles" => ["Administrator"]}).permit!) post :update, params: {id: user.id, user: {alchemy_roles: ["Administrator"]}, format: :js} end end @@ -191,7 +191,7 @@ module Alchemy end it "updates user without role" do - expect(user).to receive(:update_without_password).with({}) + expect(user).to receive(:update_without_password).with(ActionController::Parameters.new.permit!) post :update, params: {id: user.id, user: {alchemy_roles: ["Administrator"]}, format: :js} end end diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 9ade7bb..f937a93 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -23,7 +23,7 @@ module Dummy class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults ENV.fetch("RAILS_VERSION", "7.1").to_f # Configuration for the application, engines, and railties goes here. # From d9316d3192926cd3a4b91ebad4a0563013c9a7b0 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 11 Jan 2024 13:43:41 +0100 Subject: [PATCH 2/4] Ignore sqlite files --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 340fefd..6bd5aa3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ log/*.log pkg/ spec/dummy/config/initializers/devise.rb spec/dummy/db/*.sqlite3 -spec/dummy/db/*.sqlite3-journal +spec/dummy/db/*.sqlite3-* spec/dummy/log/*.log spec/dummy/tmp/ spec/dummy/.sass-cache From d5d9a8249db695b69a14d70162090434ce6fbd7f Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 11 Jan 2024 14:44:10 +0100 Subject: [PATCH 3/4] Do not eager load in tests Fixes an issue with turbo-rails and Rails 7.1 --- spec/dummy/config/environments/test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index e57c036..04f8d01 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -14,7 +14,7 @@ # Eager loading loads your whole application. When running a single test locally, # this probably isn't necessary. It's a good idea to do in a continuous integration # system, or in some way before deploying your code. - config.eager_load = ENV["CI"].present? + config.eager_load = false # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true From ba7c00e8a43348666b0ef9ef813d55618170cd1b Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 11 Jan 2024 14:58:57 +0100 Subject: [PATCH 4/4] Update rspec-rails --- alchemy-devise.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alchemy-devise.gemspec b/alchemy-devise.gemspec index 9e732e9..5fe6692 100644 --- a/alchemy-devise.gemspec +++ b/alchemy-devise.gemspec @@ -22,7 +22,7 @@ Gem::Specification.new do |s| s.add_development_dependency "factory_bot_rails" s.add_development_dependency "rails-controller-testing" s.add_development_dependency "rspec-activemodel-mocks", "~> 1.0" - s.add_development_dependency "rspec-rails", "~> 6.0.1" + s.add_development_dependency "rspec-rails", "~> 6.0" s.add_development_dependency "simplecov" s.post_install_message = <<~MSG