@@ -357,45 +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 complete foreign key info' 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_cf2568e89e' ,
370
- 'foreign_thing_id' ,
371
- 'foreign_things' ) ,
372
- mock_foreign_key ( 'custom_fk_name' ,
373
- 'other_thing_id' ,
374
- 'other_things' ) ,
375
- mock_foreign_key ( 'fk_rails_a70234b26c' ,
376
- 'third_thing_id' ,
377
- 'third_things' )
378
- ] )
379
-
380
- expected_result = <<~EOS
381
- # Schema Info
382
- #
383
- # Table name: users
384
- #
385
- # id :integer not null, primary key
386
- # foreign_thing_id :integer not null
387
- #
388
- # Foreign Keys
389
- #
390
- # custom_fk_name (other_thing_id => other_things.id)
391
- # fk_rails_a70234b26c (third_thing_id => third_things.id)
392
- # fk_rails_cf2568e89e (foreign_thing_id => foreign_things.id)
393
- #
394
- EOS
395
-
396
- expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_foreign_keys : true , show_complete_foreign_keys : true ) ) . to eql ( expected_result )
397
- end
398
-
399
360
it 'should get foreign key info if on_delete/on_update options present' do
400
361
klass = mock_class ( :users ,
401
362
:id ,
@@ -635,6 +596,45 @@ def mock_column(name, type, options = {})
635
596
expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_indexes : true ) ) . to eql ( expected_result )
636
597
end
637
598
599
+ it 'should get complete foreign key info' do
600
+ klass = mock_class ( :users ,
601
+ :id ,
602
+ [
603
+ mock_column ( :id , :integer ) ,
604
+ mock_column ( :foreign_thing_id , :integer )
605
+ ] ,
606
+ [ ] ,
607
+ [
608
+ mock_foreign_key ( 'fk_rails_cf2568e89e' ,
609
+ 'foreign_thing_id' ,
610
+ 'foreign_things' ) ,
611
+ mock_foreign_key ( 'custom_fk_name' ,
612
+ 'other_thing_id' ,
613
+ 'other_things' ) ,
614
+ mock_foreign_key ( 'fk_rails_a70234b26c' ,
615
+ 'third_thing_id' ,
616
+ 'third_things' )
617
+ ] )
618
+
619
+ expected_result = <<~EOS
620
+ # Schema Info
621
+ #
622
+ # Table name: users
623
+ #
624
+ # id :integer not null, primary key
625
+ # foreign_thing_id :integer not null
626
+ #
627
+ # Foreign Keys
628
+ #
629
+ # custom_fk_name (other_thing_id => other_things.id)
630
+ # fk_rails_a70234b26c (third_thing_id => third_things.id)
631
+ # fk_rails_cf2568e89e (foreign_thing_id => foreign_things.id)
632
+ #
633
+ EOS
634
+
635
+ expect ( AnnotateModels . get_schema_info ( klass , 'Schema Info' , show_foreign_keys : true , show_complete_foreign_keys : true ) ) . to eql ( expected_result )
636
+ end
637
+
638
638
it 'should get schema info as RDoc' do
639
639
klass = mock_class ( :users ,
640
640
:id ,
0 commit comments