diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34131270..edbf81d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,12 +30,9 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["2.7", "3.0", "3.1", "3.2"] - rails: ["6.1", "7.0"] + ruby: ["3.1", "3.2", "3.3"] + rails: ["6.1", "7.0", "7.1", "main"] continue-on-error: [false] - exclude: - - ruby: "3.2" - rails: "6.1" runs-on: ubuntu-latest diff --git a/Gemfile b/Gemfile index 5c270e1f..0f391c00 100644 --- a/Gemfile +++ b/Gemfile @@ -3,14 +3,13 @@ source "https://rubygems.org" # Specify your gem's dependencies in scenic.gemspec gemspec -rails_version = ENV.fetch("RAILS_VERSION", "6.1") +rails_version = ENV.fetch("RAILS_VERSION", "7.1") -rails_constraint = if rails_version == "master" +rails_constraint = if rails_version == "main" {github: "rails/rails"} else "~> #{rails_version}.0" end -gem "rails", rails_constraint -gem "sprockets", "< 4.0.0" -gem "pg", "~> 1.1" +gem "activerecord", rails_constraint +gem "railties", rails_constraint diff --git a/scenic.gemspec b/scenic.gemspec index edafe043..b440a214 100644 --- a/scenic.gemspec +++ b/scenic.gemspec @@ -22,15 +22,15 @@ Gem::Specification.new do |spec| spec.add_development_dependency "database_cleaner" spec.add_development_dependency "rake" spec.add_development_dependency "rspec", ">= 3.3" - spec.add_development_dependency "pg", "~> 0.19" - spec.add_development_dependency "pry" + spec.add_development_dependency "pg", "~> 1.1" spec.add_development_dependency "ammeter", ">= 1.1.3" spec.add_development_dependency "yard" spec.add_development_dependency "redcarpet" spec.add_development_dependency "standard" + spec.add_development_dependency "sprockets", "< 4.0.0" spec.add_dependency "activerecord", ">= 4.0.0" spec.add_dependency "railties", ">= 4.0.0" - spec.required_ruby_version = ">= 2.3.0" + spec.required_ruby_version = ">= 3.1" end diff --git a/spec/scenic/schema_dumper_spec.rb b/spec/scenic/schema_dumper_spec.rb index 02378110..0a5ead8f 100644 --- a/spec/scenic/schema_dumper_spec.rb +++ b/spec/scenic/schema_dumper_spec.rb @@ -58,7 +58,7 @@ class SearchInAHaystack < ActiveRecord::Base context "with views in non public schemas" do it "dumps a create_view including namespace for a view in the database" do view_definition = "SELECT 'needle'::text AS haystack" - Search.connection.execute "CREATE SCHEMA scenic; SET search_path TO scenic, public" + Search.connection.execute "CREATE SCHEMA IF NOT EXISTS scenic; SET search_path TO scenic, public" Search.connection.create_view :"scenic.searches", sql_definition: view_definition stream = StringIO.new @@ -139,7 +139,7 @@ class SearchInAHaystack < ActiveRecord::Base it "dumps a create_view for a view in the database" do view_definition = "SELECT 'needle'::text AS haystack" Search.connection.execute( - "CREATE SCHEMA scenic; SET search_path TO scenic, public" + "CREATE SCHEMA IF NOT EXISTS scenic; SET search_path TO scenic, public" ) Search.connection.create_view 'scenic."search in a haystack"', sql_definition: view_definition @@ -151,7 +151,13 @@ class SearchInAHaystack < ActiveRecord::Base expect(output).to include 'create_view "scenic.\"search in a haystack\"",' expect(output).to include view_definition - Search.connection.drop_view :'scenic."search in a haystack"' + # Rails 7.1 will add a create_schema statement automatically, which breaks + # the load if the schema already exists. + if Rails.gem_version < Gem::Version.new("7.1") + Search.connection.execute 'DROP VIEW IF EXISTS scenic."search in a haystack" CASCADE;' + else + Search.connection.execute "DROP SCHEMA IF EXISTS scenic CASCADE;" + end silence_stream($stdout) { eval(output) } # standard:disable Security/Eval diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b3dfc3a9..7b3fc3dd 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,8 +13,6 @@ DatabaseCleaner.strategy = :transaction config.around(:each, db: true) do |example| - ActiveRecord::SchemaMigration.create_table - DatabaseCleaner.start example.run DatabaseCleaner.clean