Skip to content

Commit

Permalink
Fix tests for V0.11 and Rails 7.1 (#1420)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lgebhardt authored Nov 1, 2023
1 parent 81e4ecf commit 26d280a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ jobs:
- '3.1'
- '3.0'
- '2.7'
- '2.6'
rails:
- '7.1'
- '7.0'
- '6.1'
- '6.0'
Expand All @@ -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 }}
Expand Down
10 changes: 5 additions & 5 deletions test/fixtures/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 26d280a

Please sign in to comment.