Skip to content

Commit 26d280a

Browse files
authored
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
1 parent 81e4ecf commit 26d280a

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

.github/workflows/ruby.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ jobs:
4242
- '3.1'
4343
- '3.0'
4444
- '2.7'
45-
- '2.6'
4645
rails:
46+
- '7.1'
4747
- '7.0'
4848
- '6.1'
4949
- '6.0'
@@ -60,8 +60,6 @@ jobs:
6060
rails: '5.1'
6161
- ruby: '3.0'
6262
rails: '6.0'
63-
- ruby: '2.6'
64-
rails: '7.0'
6563
env:
6664
RAILS_VERSION: ${{ matrix.rails }}
6765
DATABASE_URL: ${{ matrix.database_url }}

test/fixtures/active_record.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
end
5353

5454
create_table :posts, force: true do |t|
55-
t.string :title, length: 255
55+
t.string :title, limit: 255
5656
t.text :body
5757
t.integer :author_id
5858
t.integer :parent_post_id
@@ -311,8 +311,8 @@
311311

312312
create_table :things, force: true do |t|
313313
t.string :name
314-
t.references :user
315-
t.references :box
314+
t.belongs_to :user
315+
t.belongs_to :box
316316

317317
t.timestamps null: false
318318
end
@@ -324,8 +324,8 @@
324324

325325
create_table :related_things, force: true do |t|
326326
t.string :name
327-
t.references :from, references: :thing
328-
t.references :to, references: :thing
327+
t.belongs_to :from
328+
t.belongs_to :to
329329

330330
t.timestamps null: false
331331
end

test/test_helper.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
ENV['DATABASE_URL'] ||= "sqlite3:test_db"
2424

2525
require 'active_record/railtie'
26-
require 'rails/test_help'
2726
require 'minitest/mock'
2827
require 'jsonapi-resources'
2928
require 'pry'
@@ -65,8 +64,12 @@ class TestApp < Rails::Application
6564
if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR == 2
6665
config.active_record.sqlite3.represent_boolean_as_integer = true
6766
end
67+
68+
config.hosts << "www.example.com"
6869
end
6970

71+
require 'rails/test_help'
72+
7073
DatabaseCleaner.allow_remote_database_url = true
7174
DatabaseCleaner.strategy = :transaction
7275

0 commit comments

Comments
 (0)