From cb8548696dddbce0f48856fa5349dc0fc33507e3 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 10:42:58 +0200 Subject: [PATCH 1/8] Add require logger --- test/test_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index c1faea37..b9d2e571 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,4 @@ +require "logger" require 'simplecov' require 'database_cleaner' From dad2c7e82302ac4a62ff9f12abfdd2377cc20479 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 10:56:55 +0200 Subject: [PATCH 2/8] Add 3.3 ruby version --- .github/workflows/ruby.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index aeb9b1ae..807a3c0e 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -31,6 +31,7 @@ jobs: - '3.0' - 3.1 - 3.2 + - 3.3 rails: - 7.0.4 - 6.1.7 @@ -41,6 +42,12 @@ jobs: - postgresql://postgres:password@localhost:5432/test - sqlite3:test_db exclude: + - ruby: 3.3 + rails: 6.0.6 + - ruby: 3.3 + rails: 5.2.8.1 + - ruby: 3.3 + rails: 5.1.7 - ruby: 3.2 rails: 6.0.6 - ruby: 3.2 From 372eeb1e066475099af8f625301b19cd777ec29a Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 11:07:26 +0200 Subject: [PATCH 3/8] Add 3.4 ruby version --- .github/workflows/ruby.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 807a3c0e..d95f80b5 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -32,6 +32,7 @@ jobs: - 3.1 - 3.2 - 3.3 + - 3.4 rails: - 7.0.4 - 6.1.7 @@ -42,6 +43,12 @@ jobs: - postgresql://postgres:password@localhost:5432/test - sqlite3:test_db exclude: + - ruby: 3.4 + rails: 6.0.6 + - ruby: 3.4 + rails: 5.2.8.1 + - ruby: 3.4 + rails: 5.1.7 - ruby: 3.3 rails: 6.0.6 - ruby: 3.3 From d12060ab739dba83887fe02dcbb7695777fce18e Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 15:10:16 +0200 Subject: [PATCH 4/8] Require Rails modules after init Rails app To fix error: /Users/user/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-7.1.5.1/lib/rails.rb:51:in `configuration': undefined method `config' for nil (NoMethodError) 'application.config' --- test/test_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index b9d2e571..d1103539 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -24,8 +24,6 @@ ENV['DATABASE_URL'] ||= "sqlite3:test_db" require 'active_record/railtie' -require 'rails/test_help' -require 'minitest/mock' require 'jsonapi-resources' require 'pry' @@ -68,6 +66,9 @@ class TestApp < Rails::Application end end +require 'rails/test_help' +require 'minitest/mock' + DatabaseCleaner.allow_remote_database_url = true DatabaseCleaner.strategy = :transaction From 4f1dcc6c3aad0f4c26daa1d4fcf4df770f923510 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 14:53:00 +0200 Subject: [PATCH 5/8] Replace lenght with limit to be compatible with Rails >= 7.1 --- test/fixtures/active_record.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/active_record.rb b/test/fixtures/active_record.rb index f8959317..edbd4227 100644 --- a/test/fixtures/active_record.rb +++ b/test/fixtures/active_record.rb @@ -52,7 +52,7 @@ end create_table :posts, force: true do |t| - t.string :title, length: 255 + t.string :title, limit: 255 t.text :body t.integer :author_id t.integer :parent_post_id From 850a12f5c13371a00409719fc004aaa83f5b3781 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 15:16:50 +0200 Subject: [PATCH 6/8] Exclude 3.4 Ruby version for 7.0 or lower Rails version --- .github/workflows/ruby.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index d95f80b5..5883f49f 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -43,6 +43,10 @@ jobs: - postgresql://postgres:password@localhost:5432/test - sqlite3:test_db exclude: + - ruby: 3.4 + rails: 7.0.4 + - ruby: 3.4 + rails: 6.1.7 - ruby: 3.4 rails: 6.0.6 - ruby: 3.4 From cea3d1da7e548f858616373b0e6b65a81cc2cbe2 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 15:20:01 +0200 Subject: [PATCH 7/8] Add 7.1.5.1 Rails version for tests coverage --- .github/workflows/ruby.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5883f49f..741946fc 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -34,6 +34,7 @@ jobs: - 3.3 - 3.4 rails: + - 7.1.5.1 - 7.0.4 - 6.1.7 - 6.0.6 From 12f9bdcefe125e9b4ae59c20e032400e9f9323c2 Mon Sep 17 00:00:00 2001 From: Jasonlgrd Date: Thu, 19 Jun 2025 15:41:12 +0200 Subject: [PATCH 8/8] Remove `references` option it's deprecated since Rails 7.1 --- test/fixtures/active_record.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/active_record.rb b/test/fixtures/active_record.rb index edbd4227..c8c0683c 100644 --- a/test/fixtures/active_record.rb +++ b/test/fixtures/active_record.rb @@ -324,11 +324,11 @@ create_table :related_things, force: true do |t| t.string :name - t.references :from, references: :thing - t.references :to, references: :thing t.timestamps null: false end + add_reference :related_things, :from, foreign_key: { to_table: :things } + add_reference :related_things, :to, foreign_key: { to_table: :things } create_table :questions, force: true do |t| t.string :text