@@ -555,31 +555,37 @@ def test_schema_dumping_with_defferable_initially_immediate
555
555
end
556
556
557
557
def test_does_not_create_foreign_keys_when_bypassed_by_config
558
- connection = ActiveRecord ::Base . establish_connection (
559
- {
560
- adapter : "sqlite3" ,
561
- database : "test/db/test.sqlite3" ,
562
- foreign_keys : false ,
563
- }
564
- ) . connection
565
-
566
- connection . create_table "rockets" , force : true do |t |
567
- t . string :name
568
- end
569
- connection . create_table "astronauts" , force : true do |t |
570
- t . string :name
571
- t . references :rocket
572
- end
558
+ if current_adapter? ( :SQLite3Adapter ) && !ActiveRecord ::Base . connection . supports_concurrent_connections?
559
+ skip ( "Can't reopen in-memory database" )
560
+ else
561
+ begin
562
+ connection = ActiveRecord ::Base . establish_connection (
563
+ {
564
+ adapter : "sqlite3" ,
565
+ database : "test/db/test.sqlite3" ,
566
+ foreign_keys : false ,
567
+ }
568
+ ) . connection
569
+
570
+ connection . create_table "rockets" , force : true do |t |
571
+ t . string :name
572
+ end
573
+ connection . create_table "astronauts" , force : true do |t |
574
+ t . string :name
575
+ t . references :rocket
576
+ end
573
577
574
- connection . add_foreign_key :astronauts , :rockets
578
+ connection . add_foreign_key :astronauts , :rockets
575
579
576
- foreign_keys = connection . foreign_keys ( "astronauts" )
577
- assert_equal 0 , foreign_keys . size
578
- ensure
579
- connection . drop_table "astronauts" , if_exists : true rescue nil
580
- connection . drop_table "rockets" , if_exists : true rescue nil
580
+ foreign_keys = connection . foreign_keys ( "astronauts" )
581
+ assert_equal 0 , foreign_keys . size
582
+ ensure
583
+ connection . drop_table "astronauts" , if_exists : true rescue nil
584
+ connection . drop_table "rockets" , if_exists : true rescue nil
581
585
582
- ActiveRecord ::Base . establish_connection ( :arunit )
586
+ ActiveRecord ::Base . establish_connection ( :arunit )
587
+ end
588
+ end
583
589
end
584
590
585
591
def test_schema_dumping
0 commit comments