Skip to content

Commit

Permalink
Support ruby 3.2 rails 7.1 (#810)
Browse files Browse the repository at this point in the history
Add Ruby 3.2 and Rails 7.1 to CI and make it work where it didn't work
  • Loading branch information
willnet committed Oct 11, 2023
1 parent 3c146ab commit 27b6906
Show file tree
Hide file tree
Showing 31 changed files with 77 additions and 36 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@ jobs:
strategy:
matrix:
database: [ mysql, postgresql, sqlite3 ]
gemfile: [ '7.0.1', '6.1.3.1', '6.0.3.6', '5.2.5', '5.1.7', '4.2.11.3' ]
ruby: [ '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
gemfile: [ '7.1.0', '7.0.1', '6.1.3.1', '6.0.3.6', '5.2.5', '5.1.7', '4.2.11.3' ]
ruby: [ '3.2', '3.1', '3.0', '2.7', '2.6', '2.5', '2.4' ]
exclude:
- ruby: '3.2'
gemfile: '6.1.3.1'
- ruby: '3.2'
gemfile: '6.0.3.6'
- ruby: '3.2'
gemfile: '5.2.5'
- ruby: '3.2'
gemfile: '5.1.7'
- ruby: '3.2'
gemfile: '4.2.11.3'
- ruby: '3.1'
gemfile: '6.0.3.6'
- ruby: '3.1'
Expand All @@ -33,10 +43,16 @@ jobs:
gemfile: '5.1.7'
- ruby: '2.7'
gemfile: '4.2.11.3'
- ruby: '2.6'
gemfile: '7.1.0'
- ruby: '2.6'
gemfile: '7.0.1'
- ruby: '2.5'
gemfile: '7.1.0'
- ruby: '2.5'
gemfile: '7.0.1'
- ruby: '2.4'
gemfile: '7.1.0'
- ruby: '2.4'
gemfile: '7.0.1'
- ruby: '2.4'
Expand All @@ -47,7 +63,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.ruby }} ${{ matrix.database }} rails-${{ matrix.gemfile }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: sudo apt-get update
- run: sudo apt-get install libpq-dev postgresql-client -y
if: matrix.database == 'postgresql'
Expand Down
23 changes: 23 additions & 0 deletions gemfiles/rails_7.1.0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sqlite3", "~> 1.4", platforms: [:ruby, :rbx]
gem "activemodel", "7.1.0"
gem "activerecord", "7.1.0"

group :mysql do
gem "mysql2", platforms: [:ruby, :rbx]
end

group :postgres, :postgresql do
gem "pg", "~> 1.1", platforms: [:ruby, :rbx]
end

platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter", "~> 1"
gem "activerecord-jdbcmysql-adapter", "~> 1"
gem "activerecord-jdbcpostgresql-adapter", "~> 1"
end

gemspec path: "../"
4 changes: 2 additions & 2 deletions globalize.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.required_ruby_version = '>= 2.4.6'

s.add_dependency 'activerecord', '>= 4.2', '< 7.1'
s.add_dependency 'activemodel', '>= 4.2', '< 7.1'
s.add_dependency 'activerecord', '>= 4.2', '< 7.2'
s.add_dependency 'activemodel', '>= 4.2', '< 7.2'
s.add_dependency 'request_store', '~> 1.0'

s.add_development_dependency 'appraisal'
Expand Down
2 changes: 1 addition & 1 deletion issue_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'logger'

# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)

# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
Expand Down
2 changes: 1 addition & 1 deletion test/create_row_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def call(name, start, finish, message_id, values)
end
end

class CreateRowTest < MiniTest::Spec
class CreateRowTest < Minitest::Spec
before(:each) do
ActiveSupport::Notifications.subscribe('sql.active_record', ActiveRecord::Updater.new)
ActiveRecord::Updater.query_count = 0
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/accessors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class AccessorsTest < MiniTest::Spec
class AccessorsTest < Minitest::Spec
describe '*_translations reader' do
it 'is defined for translated attributes' do
assert User.new.respond_to?(:name_translations)
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/attributes_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class AttributesTest < MiniTest::Spec
class AttributesTest < Minitest::Spec

describe 'translated attribute reader' do
it 'is defined for translated attributes' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/bad_configuration_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class BadConfigurationTest < MiniTest::Spec
class BadConfigurationTest < Minitest::Spec
describe 'finders on data with bad configuration' do
it 'works with find_by' do
bad_configuration = BadConfiguration.create(:name => "foo")
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/cache_key_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require File.expand_path('../../test_helper', __FILE__)
require 'active_support/testing/time_helpers'

class CacheKeyTest < MiniTest::Spec
class CacheKeyTest < Minitest::Spec
include ActiveSupport::Testing::TimeHelpers

describe '#cache_key' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/destroy_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class DestroyTest < MiniTest::Spec
class DestroyTest < Minitest::Spec
describe '.destroy_all' do
before do
@posts = [Post.create(:title => 'title'), Post.create(:title => 'title')]
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/dirty_tracking_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)

class DirtyTrackingTest < MiniTest::Spec
class DirtyTrackingTest < Minitest::Spec

describe '#changed' do
it 'includes translated attributes in list of changed attribute keys' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/dont_modify_immutable_relation_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class DontModifyImmutableRelationTest < MiniTest::Spec
class DontModifyImmutableRelationTest < Minitest::Spec
describe 'going through has_many :through relation and where.not condition' do
it "does not raises ActiveRecord::ImmutableRelation" do
# This should not raise ActiveRecord::ImmutableRelation
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/dup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class DupTest < MiniTest::Spec
class DupTest < Minitest::Spec

describe 'duped translated model' do
it 'stores translations of new record' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/fallbacks_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)

class FallbacksTest < MiniTest::Spec
class FallbacksTest < Minitest::Spec
before(:each) do
@previous_backend = I18n.backend
I18n.pretend_fallbacks
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/first_or_create_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class FirstOrCreateTest < MiniTest::Spec
class FirstOrCreateTest < Minitest::Spec
describe '.first_or_create' do
it 'returns first record with matching translated attribute if match found' do
post = Post.create(:title => 'test_title')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class InitializingModelViaHasManyThroughRelationTest < MiniTest::Spec
class InitializingModelViaHasManyThroughRelationTest < Minitest::Spec
describe 'initializing model via has_many through' do
it "does not raise error undefined local variable or method `translations_table_name'" do
Author.new.comments_without_translations.new
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/interpolation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class InterpolationTest < MiniTest::Spec
class InterpolationTest < Minitest::Spec
describe 'translated attribute reader' do
it "interpolates arguments into translation" do
user = User.new(:name => 'John %{surname}')
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/joins_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class JoinsTest < MiniTest::Spec
class JoinsTest < Minitest::Spec

describe 'pluck on translations table' do

Expand Down
2 changes: 1 addition & 1 deletion test/globalize/locale_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class LocaleTest < MiniTest::Spec
class LocaleTest < Minitest::Spec

describe Globalize do
it 'has locale accessors' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/migration_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)

class MigrationTest < MiniTest::Spec
class MigrationTest < Minitest::Spec
include Globalize::ActiveRecord::Exceptions

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/model_named_locale_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class ModelNamedLocaleTest < MiniTest::Spec
class ModelNamedLocaleTest < Minitest::Spec
describe 'translated attribute reader on model named "Locale"' do
it "returns the correct translation" do
Locale.create :name => "French"
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/order_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class OrderTest < MiniTest::Spec
class OrderTest < Minitest::Spec
describe 'order with fallbacks' do
before(:each) do
@previous_backend = I18n.backend
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/set_translations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class AttributesTest < MiniTest::Spec
class AttributesTest < Minitest::Spec

describe '#set_translations' do
it 'sets multiple translations at once' do
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/translated_attributes_query_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require File.expand_path('../../test_helper', __FILE__)

class TranslatedAttributesQueryTest < MiniTest::Spec
class TranslatedAttributesQueryTest < Minitest::Spec
def self.it_supports_translated_conditions(method)
it 'finds records with matching attribute value in translations table' do
post = Post.create(:title => 'title 1')
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/translation_class_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)

class TranslationClassTest < MiniTest::Spec
class TranslationClassTest < Minitest::Spec
describe '.translation_class' do
it 'returns the Translation class' do
assert_equal Post::Translation, Post.translation_class
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/translation_for_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../../test_helper', __FILE__)

class TranslationForTest < MiniTest::Spec
class TranslationForTest < Minitest::Spec
describe '#translation_for' do
it 'returns translation for locale passed in as an argument' do
post = Post.create(:title => 'title', :content => 'content', :locale => :en)
Expand Down
2 changes: 1 addition & 1 deletion test/globalize/validations_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.expand_path('../../test_helper', __FILE__)

class ValidationsTest < MiniTest::Spec
class ValidationsTest < Minitest::Spec
after(:each) do
Validatee.reset_callbacks(:validate)
end
Expand Down
2 changes: 1 addition & 1 deletion test/globalize_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require File.expand_path('../test_helper', __FILE__)

class GlobalizeTest < MiniTest::Spec
class GlobalizeTest < Minitest::Spec

describe 'translated record' do

Expand Down
6 changes: 3 additions & 3 deletions test/i18n/missing_translations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TestLogger < String
def warn(msg) self.concat msg; end
end

class LogMissingTranslationsTest < MiniTest::Spec
class LogMissingTranslationsTest < Minitest::Spec
before(:each) do
@locale, @key, @options = :en, :foo, {}
@exception = I18n::MissingTranslationData.new(@locale, @key, @options)
Expand All @@ -24,11 +24,11 @@ class LogMissingTranslationsTest < MiniTest::Spec

it "still returns the exception message for MissingTranslationData exceptions" do
result = I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
assert_match(/translation missing: en(\W+)foo/, result)
assert_match(/[tT]ranslation missing: en(\W+)foo/, result)
end

it "logs the missing translation to I18n.missing_translations_logger" do
I18n.send(:missing_translations_log_handler, @exception, @locale, @key, @options)
assert_match(/translation missing: en(\W+)foo/, @logger)
assert_match(/[tT]ranslation missing: en(\W+)foo/, @logger)
end
end
6 changes: 4 additions & 2 deletions test/support/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ def native_array_support?
postgres?
end

# PostgreSQL and MySql doen't support table names longer than 63 chars
# PostgreSQL and MySQL doesn't support table names longer than 63 chars
# rails 7.1 enforce limit on table names with all databases
# ref: https://github.com/rails/rails/pull/45136
def long_table_name_support?
sqlite?
sqlite? && Gem::Version.new(::ActiveRecord.gem_version) < Gem::Version.new('7.1.0')
end

def cleaning_strategy(strategy, &block)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
require 'database_cleaner'
DatabaseCleaner.strategy = :transaction

class MiniTest::Spec
class Minitest::Spec
before :each do
DatabaseCleaner.start
I18n.locale = I18n.default_locale = :en
Expand Down

0 comments on commit 27b6906

Please sign in to comment.