File tree Expand file tree Collapse file tree 6 files changed +41
-12
lines changed
Expand file tree Collapse file tree 6 files changed +41
-12
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ source "https://rubygems.org"
33gemspec
44
55gem "bundler" , ">= 1.5"
6- gem "database_cleaner"
76gem "pg"
87gem "pry"
98gem "rake"
Original file line number Diff line number Diff line change 55RSpec . configure do |config |
66 config . around ( :each ) do |example |
77 Dir . chdir ( "spec/dummy" ) do
8+ DatabaseReset . call
9+
810 example . run
11+
12+ DatabaseReset . call
913 end
1014 end
1115
2428 config . after ( :suite ) do
2529 Dir . chdir ( "spec/dummy" ) do
2630 ActiveRecord ::Base . connection . disconnect!
31+ DatabaseReset . call
2732 system [
2833 "git add -A" ,
2934 "git reset --hard HEAD 1>/dev/null" ,
Original file line number Diff line number Diff line change @@ -12,10 +12,6 @@ class Application < Rails::Application
1212 config . eager_load = false
1313 config . active_support . deprecation = :stderr
1414
15- config . load_defaults 7.0
16-
17- if Rails . version >= "8.0"
18- config . active_support . to_time_preserves_timezone = :zone
19- end
15+ config . load_defaults 7.2
2016 end
2117end
Original file line number Diff line number Diff line change 155155 expect ( output . scan ( "create_trigger :test_public_trigger" ) . size ) . to eq ( 1 )
156156 expect ( output . scan ( "create_function :test_schema_func" ) . size ) . to eq ( 1 )
157157 expect ( output . scan ( "create_trigger :test_schema_trigger" ) . size ) . to eq ( 1 )
158-
158+ ensure
159159 connection . schema_search_path = "public"
160160 end
161161
Original file line number Diff line number Diff line change 11ENV [ "RAILS_ENV" ] = "test"
2- require "database_cleaner"
32
43require File . expand_path ( "../dummy/config/environment" , __FILE__ )
54Dir [ "spec/support/**/*.rb" ] . sort . each { |file | load file }
1110 config . order = "random"
1211 config . disable_monkey_patching!
1312
14- DatabaseCleaner . strategy = :transaction
13+ config . define_derived_metadata ( file_path : %r{spec/(fx|features)/} ) do |metadata |
14+ metadata [ :db ] = true
15+ end
16+
17+ config . before ( :suite ) do
18+ DatabaseReset . call
19+ end
1520
1621 config . around ( :each , db : true ) do |example |
17- ActiveRecord :: Base . connection . execute ( "SET search_path TO DEFAULT;" )
22+ DatabaseReset . call
1823
19- DatabaseCleaner . start
2024 example . run
21- DatabaseCleaner . clean
25+
26+ DatabaseReset . call
2227 end
2328
2429 unless defined? ( silence_stream )
Original file line number Diff line number Diff line change 1+ module DatabaseReset
2+ def self . call
3+ connection = ActiveRecord ::Base . connection
4+ connection . execute ( "SET search_path TO DEFAULT;" )
5+
6+ connection . execute <<~SQL
7+ DO $$
8+ DECLARE
9+ schema_name TEXT;
10+ BEGIN
11+ FOR schema_name IN
12+ SELECT nspname FROM pg_namespace
13+ WHERE nspname NOT LIKE 'pg_%'
14+ AND nspname != 'information_schema'
15+ LOOP
16+ EXECUTE format('DROP SCHEMA IF EXISTS %I CASCADE', schema_name);
17+ END LOOP;
18+ END $$;
19+ SQL
20+
21+ connection . execute ( "CREATE SCHEMA public;" )
22+ connection . schema_search_path = "public"
23+ end
24+ end
You can’t perform that action at this time.
0 commit comments