diff --git a/lib/orthoses/active_record/relation_test.rb b/lib/orthoses/active_record/relation_test.rb index a0da007..d5dba8f 100644 --- a/lib/orthoses/active_record/relation_test.rb +++ b/lib/orthoses/active_record/relation_test.rb @@ -34,7 +34,7 @@ def test_relation(t) expect = <<~RBS class RelationTest::User::ActiveRecord_Relation < ::ActiveRecord::Relation include RelationTest::User::GeneratedRelationMethods - include _ActiveRecord_Relation[RelationTest::User, untyped] + include _ActiveRecord_Relation[RelationTest::User, ::Integer] include Enumerable[RelationTest::User] end RBS @@ -45,7 +45,7 @@ class RelationTest::User::ActiveRecord_Relation < ::ActiveRecord::Relation expect = <<~RBS class RelationTest::User::ActiveRecord_Associations_CollectionProxy < ::ActiveRecord::Associations::CollectionProxy - include _ActiveRecord_Relation[RelationTest::User, untyped] + include _ActiveRecord_Relation[RelationTest::User, ::Integer] end RBS actual = store["RelationTest::User::ActiveRecord_Associations_CollectionProxy"].to_rbs @@ -55,7 +55,7 @@ class RelationTest::User::ActiveRecord_Associations_CollectionProxy < ::ActiveRe expect = <<~RBS class RelationTest::User < ::ActiveRecord::Base - extend _ActiveRecord_Relation_ClassMethods[RelationTest::User, RelationTest::User::ActiveRecord_Relation, untyped] + extend _ActiveRecord_Relation_ClassMethods[RelationTest::User, RelationTest::User::ActiveRecord_Relation, ::Integer] end RBS actual = store["RelationTest::User"].to_rbs diff --git a/lib/orthoses/active_storage/attached/model_test.rb b/lib/orthoses/active_storage/attached/model_test.rb index 0c071b1..5c3b635 100644 --- a/lib/orthoses/active_storage/attached/model_test.rb +++ b/lib/orthoses/active_storage/attached/model_test.rb @@ -5,10 +5,17 @@ require "active_storage/attached" require "active_storage/reflection" + ActiveRecord::Base.include(ActiveStorage::Attached::Model) ActiveRecord::Base.include(ActiveStorage::Reflection::ActiveRecordExtensions) ActiveRecord::Reflection.singleton_class.prepend(ActiveStorage::Reflection::ReflectionExtension) +if ActiveRecord.version >= Gem::Version.new("7.2") + class ::ActiveStorage::Blob + def self.validate_service_configuration(*); end + end +end + module ModelTest LOADER = ->(){ class User < ActiveRecord::Base diff --git a/test/fake_schema.rb b/test/fake_schema.rb index 98069fe..0889e25 100644 --- a/test/fake_schema.rb +++ b/test/fake_schema.rb @@ -1,3 +1,24 @@ +FakeColumn = Struct.new(:type, :name, :null, keyword_init: true) +def FakeColumn.columns_hash + { + "id" => FakeColumn.new( + name: :id, + null: false, + type: :integer, + ), + "name" => FakeColumn.new( + name: :name, + null: false, + type: :string, + ), + "confirmed" => FakeColumn.new( + name: :confirmed, + null: true, + type: :boolean, + ), + } +end + module ::ActiveRecord module AttributeMethods::PrimaryKey::ClassMethods def get_primary_key(base_name) @@ -6,29 +27,26 @@ def get_primary_key(base_name) end module ModelSchema::ClassMethods - FakeColumn = Struct.new(:type, :name, :null, keyword_init: true) - def load_schema end def columns_hash - { - id: FakeColumn.new( - name: :id, - null: false, - type: :integer, - ), - name: FakeColumn.new( - name: :name, - null: false, - type: :string, - ), - confirmed: FakeColumn.new( - name: :confirmed, - null: true, - type: :boolean, - ), - } + FakeColumn.columns_hash + end + + def attribute_types + FakeColumn.columns_hash + end + end +end + +# for rails v7.2 +module ActiveModel + module AttributeRegistration + module ClassMethods + def attribute_types + FakeColumn.columns_hash + end end end -end \ No newline at end of file +end