From 768a67b1ad16dd6fe23742fba6cabc503793ad38 Mon Sep 17 00:00:00 2001 From: Sergio Cambra Date: Wed, 8 Jan 2025 18:23:07 +0100 Subject: [PATCH] fix tableless and tests in rails 7.2 --- .github/workflows/ci.yml | 4 ++-- lib/active_scaffold/tableless.rb | 10 +++------- test/model_stub.rb | 2 ++ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f08240b0..1b692e9dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,7 +89,7 @@ jobs: fail-fast: false matrix: ruby: [ "3.3", "3.2", "3.1" ] - rails: [ "7.1", "7.0", "6.1" ] # TODO test 7.2 + rails: [ "7.2" "7.1", "7.0", "6.1" ] include: - ruby: jruby-9.4 rails: '6.1' @@ -98,7 +98,7 @@ jobs: - ruby: '3.0' rails: '7.0' - ruby: '3.3' - rails: '7.1' + rails: '7.2' coverage: true timeout-minutes: 60 env: diff --git a/lib/active_scaffold/tableless.rb b/lib/active_scaffold/tableless.rb index 5395bf5db..dd9f7607b 100644 --- a/lib/active_scaffold/tableless.rb +++ b/lib/active_scaffold/tableless.rb @@ -1,11 +1,4 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/ApplicationRecord - class AssociationScope < ActiveRecord::Associations::AssociationScope - INSTANCE = create - def self.scope(association, connection) - INSTANCE.scope association, connection - end - end - class Connection < ActiveRecord::ConnectionAdapters::AbstractAdapter attr_reader :klass @@ -150,8 +143,11 @@ def exec_queries class Relation < ::ActiveRecord::Relation include RelationExtension + + delegate :connection_pool, to: :model end class << self + delegate :schema_cache, to: :connection def find(*ids) ids.length == 1 ? all.find(*ids[0]) : super # rubocop:disable Rails/RedundantActiveRecordAllMethod end diff --git a/test/model_stub.rb b/test/model_stub.rb index 00b166bab..d0c89239f 100644 --- a/test/model_stub.rb +++ b/test/model_stub.rb @@ -12,6 +12,8 @@ class ModelStub < ActiveRecord::Base @@nested_scope_calls = [] cattr_accessor :nested_scope_calls + def self.schema_loaded? = true + def self.a_is_defined @@nested_scope_calls << :a_is_defined self