From 0c8c4b550135edb6f720f9dea21831d588b6601d Mon Sep 17 00:00:00 2001 From: Pascal Zumkehr Date: Thu, 28 Nov 2024 20:57:47 +0100 Subject: [PATCH] Add support for rails 8 --- .github/workflows/build.yml | 4 +++ Gemfile.lock | 65 +++++++++++++++++++------------------ lib/validates_by_schema.rb | 7 +--- spec/ci/rails70.gemfile | 2 ++ spec/ci/rails71.gemfile | 2 ++ spec/ci/rails72.gemfile | 10 ++++++ validates_by_schema.gemspec | 4 +-- 7 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 spec/ci/rails72.gemfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1630b5c..b8c92d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,8 +19,12 @@ jobs: - mysql gemfile: - Gemfile + - spec/ci/rails72.gemfile - spec/ci/rails71.gemfile - spec/ci/rails70.gemfile + exclude: + - gemfile: Gemfile + - ruby-version: "3.1" services: postgresql: diff --git a/Gemfile.lock b/Gemfile.lock index 75189af..c7c6cbb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,36 +2,36 @@ PATH remote: . specs: validates_by_schema (0.5.2) - activerecord (>= 6.0.0) + activerecord (>= 7.0.0) GEM remote: https://rubygems.org/ specs: - actionpack (7.2.1.2) - actionview (= 7.2.1.2) - activesupport (= 7.2.1.2) + actionpack (8.0.0) + actionview (= 8.0.0) + activesupport (= 8.0.0) nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4, < 3.2) + rack (>= 2.2.4) rack-session (>= 1.0.1) rack-test (>= 0.6.3) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actionview (7.2.1.2) - activesupport (= 7.2.1.2) + actionview (8.0.0) + activesupport (= 8.0.0) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activemodel (7.2.1.2) - activesupport (= 7.2.1.2) - activerecord (7.2.1.2) - activemodel (= 7.2.1.2) - activesupport (= 7.2.1.2) + activemodel (8.0.0) + activesupport (= 8.0.0) + activerecord (8.0.0) + activemodel (= 8.0.0) + activesupport (= 8.0.0) timeout (>= 0.4.0) - activesupport (7.2.1.2) + activesupport (8.0.0) base64 + benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) @@ -41,7 +41,9 @@ GEM minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) base64 (0.2.0) + benchmark (0.4.0) bigdecimal (3.1.8) builder (3.3.0) concurrent-ruby (1.3.4) @@ -61,14 +63,14 @@ GEM loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mini_portile2 (2.8.7) - minitest (5.25.1) + mini_portile2 (2.8.8) + minitest (5.25.2) mysql2 (0.5.6) nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) pg (1.5.9) - psych (5.1.2) + psych (5.2.0) stringio racc (1.8.1) rack (3.1.8) @@ -76,9 +78,8 @@ GEM rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.1.0) + rackup (2.2.1) rack (>= 3) - webrick (~> 1.8) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -86,18 +87,18 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.2.1.2) - actionpack (= 7.2.1.2) - activesupport (= 7.2.1.2) + railties (8.0.0) + actionpack (= 8.0.0) + activesupport (= 8.0.0) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) zeitwerk (~> 2.6) rake (13.2.1) - rdoc (6.7.0) + rdoc (6.8.1) psych (>= 4.0.0) - reline (0.5.10) + reline (0.5.12) io-console (~> 0.5) rspec-core (3.13.2) rspec-support (~> 3.13.0) @@ -107,7 +108,7 @@ GEM rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-rails (7.0.1) + rspec-rails (7.1.0) actionpack (>= 7.0) activesupport (>= 7.0) railties (>= 7.0) @@ -116,7 +117,7 @@ GEM rspec-mocks (~> 3.13) rspec-support (~> 3.13) rspec-support (3.13.1) - securerandom (0.3.1) + securerandom (0.3.2) shoulda-matchers (6.4.0) activesupport (>= 5.2.0) simplecov (0.22.0) @@ -126,16 +127,16 @@ GEM simplecov-html (0.13.1) simplecov-lcov (0.8.0) simplecov_json_formatter (0.1.4) - sqlite3 (1.7.3) + sqlite3 (2.3.1) mini_portile2 (~> 2.8.0) - stringio (3.1.1) + stringio (3.1.2) thor (1.3.2) - timeout (0.4.1) + timeout (0.4.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + uri (1.0.2) useragent (0.16.10) - webrick (1.8.2) - zeitwerk (2.6.18) + zeitwerk (2.7.1) PLATFORMS ruby @@ -148,7 +149,7 @@ DEPENDENCIES shoulda-matchers simplecov simplecov-lcov - sqlite3 (< 2.0) + sqlite3 validates_by_schema! BUNDLED WITH diff --git a/lib/validates_by_schema.rb b/lib/validates_by_schema.rb index 2f28239..48c61bd 100644 --- a/lib/validates_by_schema.rb +++ b/lib/validates_by_schema.rb @@ -40,12 +40,7 @@ def define_schema_validations end def fetch_unique_indexes - if connection.schema_cache.respond_to?(:indexes) - connection.schema_cache.indexes(table_name).select(&:unique) - else - # Rails < 6.0 - connection.indexes(table_name).select(&:unique) - end + connection.schema_cache.indexes(table_name).select(&:unique) end def customized_schema_validatable_columns diff --git a/spec/ci/rails70.gemfile b/spec/ci/rails70.gemfile index 90bb59f..2edf6b7 100644 --- a/spec/ci/rails70.gemfile +++ b/spec/ci/rails70.gemfile @@ -2,6 +2,8 @@ source 'https://rubygems.org' gemspec path: '../..' +gem 'sqlite3', '< 2.0' + gem 'simplecov', require: false gem 'simplecov-lcov', require: false diff --git a/spec/ci/rails71.gemfile b/spec/ci/rails71.gemfile index 39082f1..e08deeb 100644 --- a/spec/ci/rails71.gemfile +++ b/spec/ci/rails71.gemfile @@ -2,6 +2,8 @@ source 'https://rubygems.org' gemspec path: '../..' +gem 'sqlite3', '< 2.0' + gem 'simplecov', require: false gem 'simplecov-lcov', require: false diff --git a/spec/ci/rails72.gemfile b/spec/ci/rails72.gemfile new file mode 100644 index 0000000..4a9c998 --- /dev/null +++ b/spec/ci/rails72.gemfile @@ -0,0 +1,10 @@ +source 'https://rubygems.org' + +gemspec path: '../..' + +gem 'sqlite3', '< 2.0' + +gem 'simplecov', require: false +gem 'simplecov-lcov', require: false + +gem 'activerecord', '~> 7.2.0' diff --git a/validates_by_schema.gemspec b/validates_by_schema.gemspec index 11bcea9..12e298e 100644 --- a/validates_by_schema.gemspec +++ b/validates_by_schema.gemspec @@ -24,12 +24,12 @@ Gem::Specification.new do |s| s.test_files = Dir['spec/**/*'] s.require_paths = ['lib'] - s.add_dependency 'activerecord', '>= 6.0.0' + s.add_dependency 'activerecord', '>= 7.0.0' s.add_development_dependency 'mysql2' s.add_development_dependency 'pg' s.add_development_dependency 'rake' s.add_development_dependency 'rspec-rails' s.add_development_dependency 'shoulda-matchers' - s.add_development_dependency 'sqlite3', '< 2.0' # for the moment + s.add_development_dependency 'sqlite3' end