From a5c0082f033084ee47a7ba917d1b503577cbb8b5 Mon Sep 17 00:00:00 2001 From: Alex Tan Date: Sat, 31 Aug 2024 02:47:51 +0800 Subject: [PATCH] Primary key support only on 7.1 --- .../compilers/active_record_columns_spec.rb | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/spec/tapioca/dsl/compilers/active_record_columns_spec.rb b/spec/tapioca/dsl/compilers/active_record_columns_spec.rb index 24380db98..f85050962 100644 --- a/spec/tapioca/dsl/compilers/active_record_columns_spec.rb +++ b/spec/tapioca/dsl/compilers/active_record_columns_spec.rb @@ -240,28 +240,30 @@ def body?; end end it "handles composite primary keys" do - add_ruby_file("schema.rb", <<~RUBY) - ActiveRecord::Migration.suppress_messages do - ActiveRecord::Schema.define do - create_table :posts, primary_key: [:a, :b] do |t| - t.string :a, null: false - t.integer :b, null: false + if rails_version(">= 7.1") + add_ruby_file("schema.rb", <<~RUBY) + ActiveRecord::Migration.suppress_messages do + ActiveRecord::Schema.define do + create_table :posts, primary_key: [:a, :b] do |t| + t.string :a, null: false + t.integer :b, null: false + end end end - end - RUBY + RUBY - add_ruby_file("post.rb", <<~RUBY) - class Post < ActiveRecord::Base - end - RUBY + add_ruby_file("post.rb", <<~RUBY) + class Post < ActiveRecord::Base + end + RUBY - expected = indented(<<~RBI, 4) - sig { returns([::String, ::Integer]) } - def id; end - RBI + expected = indented(<<~RBI, 4) + sig { returns([::String, ::Integer]) } + def id; end + RBI - assert_includes(rbi_for(:Post), expected) + assert_includes(rbi_for(:Post), expected) + end end it "uses ActiveModel::Type::Value types when inheriting from EncryptedAttributeType" do