@@ -357,40 +357,6 @@ def mock_column(name, type, options = {})
357
357
expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_foreign_keys : true ) ) . to eql ( expected_result )
358
358
end
359
359
360
- it 'should get foreign key info if on_delete/on_update options present' do
361
- klass = mock_class ( :users ,
362
- :id ,
363
- [
364
- mock_column ( :id , :integer ) ,
365
- mock_column ( :foreign_thing_id , :integer )
366
- ] ,
367
- [ ] ,
368
- [
369
- mock_foreign_key ( 'fk_rails_02e851e3b7' ,
370
- 'foreign_thing_id' ,
371
- 'foreign_things' ,
372
- 'id' ,
373
- on_delete : 'on_delete_value' ,
374
- on_update : 'on_update_value' )
375
- ] )
376
-
377
- expected_result = <<~EOS
378
- # Schema Info
379
- #
380
- # Table name: users
381
- #
382
- # id :integer not null, primary key
383
- # foreign_thing_id :integer not null
384
- #
385
- # Foreign Keys
386
- #
387
- # fk_rails_... (foreign_thing_id => foreign_things.id) ON DELETE => on_delete_value ON UPDATE => on_update_value
388
- #
389
- EOS
390
-
391
- expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_foreign_keys : true ) ) . to eql ( expected_result )
392
- end
393
-
394
360
it 'should get indexes keys' do
395
361
klass = mock_class ( :users ,
396
362
:id ,
@@ -596,6 +562,40 @@ def mock_column(name, type, options = {})
596
562
expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_indexes : true ) ) . to eql ( expected_result )
597
563
end
598
564
565
+ it 'should get foreign key info if on_delete/on_update options present' do
566
+ klass = mock_class ( :users ,
567
+ :id ,
568
+ [
569
+ mock_column ( :id , :integer ) ,
570
+ mock_column ( :foreign_thing_id , :integer )
571
+ ] ,
572
+ [ ] ,
573
+ [
574
+ mock_foreign_key ( 'fk_rails_02e851e3b7' ,
575
+ 'foreign_thing_id' ,
576
+ 'foreign_things' ,
577
+ 'id' ,
578
+ on_delete : 'on_delete_value' ,
579
+ on_update : 'on_update_value' )
580
+ ] )
581
+
582
+ expected_result = <<~EOS
583
+ # Schema Info
584
+ #
585
+ # Table name: users
586
+ #
587
+ # id :integer not null, primary key
588
+ # foreign_thing_id :integer not null
589
+ #
590
+ # Foreign Keys
591
+ #
592
+ # fk_rails_... (foreign_thing_id => foreign_things.id) ON DELETE => on_delete_value ON UPDATE => on_update_value
593
+ #
594
+ EOS
595
+
596
+ expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_foreign_keys : true ) ) . to eql ( expected_result )
597
+ end
598
+
599
599
it 'should get complete foreign key info' do
600
600
klass = mock_class ( :users ,
601
601
:id ,
0 commit comments