Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI against Rails 8.0 #864

Merged
merged 3 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
ruby:
- 3.3
env:
- AR_VERSION: '8.0'
RUBYOPT: --enable-frozen-string-literal
- AR_VERSION: '7.2'
RUBYOPT: --enable-frozen-string-literal
- AR_VERSION: '7.1'
Expand All @@ -46,6 +48,9 @@ jobs:
- AR_VERSION: 6.1
RUBYOPT: --enable-frozen-string-literal
include:
- ruby: 3.2
env:
AR_VERSION: '8.0'
- ruby: 3.2
env:
AR_VERSION: '7.2'
Expand Down
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ version = ENV['AR_VERSION'].to_f
mysql2_version = '0.3.0'
mysql2_version = '0.4.0' if version >= 4.2
mysql2_version = '0.5.0' if version >= 6.1
mysql2_version = '0.5.6' if version >= 8.0
sqlite3_version = '1.3.0'
sqlite3_version = '1.4.0' if version >= 6.0
sqlite3_version = '2.2.0' if version >= 8.0
pg_version = '0.9'
pg_version = '1.1' if version >= 6.1
pg_version = '1.5' if version >= 8.0

group :development, :test do
gem 'rubocop'
Expand Down
3 changes: 3 additions & 0 deletions gemfiles/8.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

gem 'activerecord', '~> 8.0.0'
4 changes: 3 additions & 1 deletion test/models/author.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

class Author < ActiveRecord::Base
if ENV['AR_VERSION'].to_f >= 7.1
if ENV['AR_VERSION'].to_f >= 8.0
has_many :composite_books, foreign_key: [:id, :author_id], inverse_of: :author
elsif ENV['AR_VERSION'].to_f >= 7.1
has_many :composite_books, query_constraints: [:id, :author_id], inverse_of: :author
end
end
8 changes: 6 additions & 2 deletions test/models/book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

class Book < ActiveRecord::Base
belongs_to :topic, inverse_of: :books
if ENV['AR_VERSION'].to_f <= 7.0
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
belongs_to :tag, foreign_key: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
else
belongs_to :tag, query_constraints: [:tag_id, :parent_id] unless ENV["SKIP_COMPOSITE_PK"]
end
has_many :chapters, inverse_of: :book
has_many :discounts, as: :discountable
has_many :end_notes, inverse_of: :book
enum status: [:draft, :published] if ENV['AR_VERSION'].to_f >= 4.1
if ENV['AR_VERSION'].to_f >= 8.0
enum :status, [:draft, :published]
elsif ENV['AR_VERSION'].to_f >= 4.1
enum status: [:draft, :published]
end
end
2 changes: 1 addition & 1 deletion test/models/composite_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class CompositeBook < ActiveRecord::Base
self.primary_key = %i[id author_id]
belongs_to :author
if ENV['AR_VERSION'].to_f <= 7.0
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
unless ENV["SKIP_COMPOSITE_PK"]
has_many :composite_chapters, inverse_of: :composite_book,
foreign_key: [:id, :author_id]
Expand Down
5 changes: 4 additions & 1 deletion test/models/composite_chapter.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true

class CompositeChapter < ActiveRecord::Base
if ENV['AR_VERSION'].to_f >= 7.1
if ENV['AR_VERSION'].to_f >= 8.0
belongs_to :composite_book, inverse_of: :composite_chapters,
foreign_key: [:composite_book_id, :author_id]
elsif ENV['AR_VERSION'].to_f >= 7.1
belongs_to :composite_book, inverse_of: :composite_chapters,
query_constraints: [:composite_book_id, :author_id]
end
Expand Down
2 changes: 1 addition & 1 deletion test/models/customer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Customer < ActiveRecord::Base
unless ENV["SKIP_COMPOSITE_PK"]
if ENV['AR_VERSION'].to_f <= 7.0
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
has_many :orders,
inverse_of: :customer,
primary_key: %i(account_id id),
Expand Down
2 changes: 1 addition & 1 deletion test/models/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class Order < ActiveRecord::Base
unless ENV["SKIP_COMPOSITE_PK"]
if ENV['AR_VERSION'].to_f <= 7.0
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
belongs_to :customer,
inverse_of: :orders,
primary_key: %i(account_id id),
Expand Down
2 changes: 1 addition & 1 deletion test/models/tag_alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TagAlias < ActiveRecord::Base
unless ENV["SKIP_COMPOSITE_PK"]
if ENV['AR_VERSION'].to_f <= 7.0
if ENV['AR_VERSION'].to_f <= 7.0 || ENV['AR_VERSION'].to_f >= 8.0
belongs_to :tag, foreign_key: [:tag_id, :parent_id], required: true
else
belongs_to :tag, query_constraints: [:tag_id, :parent_id], required: true
Expand Down