From 26d280a6333e0c2145ee0c61322d3e78590b6892 Mon Sep 17 00:00:00 2001 From: Larry Gebhardt Date: Wed, 1 Nov 2023 10:21:06 -0400 Subject: [PATCH] Fix tests for V0.11 and Rails 7.1 (#1420) * Cleanup table definitions for Rails 7.1 * Test helper move require 'rails/test_help' * Test helper add `config.hosts` * Update test matrix to add rails 7.1 and remove ruby 2.6 Note: ruby 2.7 is also EOL, but I'm choosing to continue testing 2.7 for now --- .github/workflows/ruby.yml | 4 +--- test/fixtures/active_record.rb | 10 +++++----- test/test_helper.rb | 5 ++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7534b022..858c6129 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -42,8 +42,8 @@ jobs: - '3.1' - '3.0' - '2.7' - - '2.6' rails: + - '7.1' - '7.0' - '6.1' - '6.0' @@ -60,8 +60,6 @@ jobs: rails: '5.1' - ruby: '3.0' rails: '6.0' - - ruby: '2.6' - rails: '7.0' env: RAILS_VERSION: ${{ matrix.rails }} DATABASE_URL: ${{ matrix.database_url }} diff --git a/test/fixtures/active_record.rb b/test/fixtures/active_record.rb index 950a012b..c08aa896 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 @@ -311,8 +311,8 @@ create_table :things, force: true do |t| t.string :name - t.references :user - t.references :box + t.belongs_to :user + t.belongs_to :box t.timestamps null: false end @@ -324,8 +324,8 @@ create_table :related_things, force: true do |t| t.string :name - t.references :from, references: :thing - t.references :to, references: :thing + t.belongs_to :from + t.belongs_to :to t.timestamps null: false end diff --git a/test/test_helper.rb b/test/test_helper.rb index 940d0755..60c2fbed 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -23,7 +23,6 @@ ENV['DATABASE_URL'] ||= "sqlite3:test_db" require 'active_record/railtie' -require 'rails/test_help' require 'minitest/mock' require 'jsonapi-resources' require 'pry' @@ -65,8 +64,12 @@ class TestApp < Rails::Application if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2 config.active_record.sqlite3.represent_boolean_as_integer = true end + + config.hosts << "www.example.com" end +require 'rails/test_help' + DatabaseCleaner.allow_remote_database_url = true DatabaseCleaner.strategy = :transaction