@@ -49,9 +49,9 @@ def mock_connection(indexes = [], foreign_keys = [], table_comment = nil)
49
49
table_comment : table_comment )
50
50
end
51
51
52
- def mock_class ( table_name , primary_key , columns , indexes = [ ] , foreign_keys = [ ] , table_comment = nil )
52
+ def mock_class ( table_name , primary_key , columns , connection = mock_connection )
53
53
options = {
54
- connection : mock_connection ( indexes , foreign_keys , table_comment ) ,
54
+ connection : connection ,
55
55
table_exists? : true ,
56
56
table_name : table_name ,
57
57
primary_key : primary_key ,
@@ -218,7 +218,7 @@ def mock_column(name, type, options = {})
218
218
end
219
219
220
220
let :klass do
221
- mock_class ( :users , primary_key , columns , indexes , foreign_keys , table_comment )
221
+ mock_class ( :users , primary_key , columns , mock_connection ( indexes , foreign_keys , table_comment ) )
222
222
end
223
223
224
224
let :indexes do
@@ -405,7 +405,7 @@ def mock_column(name, type, options = {})
405
405
end
406
406
407
407
let :klass do
408
- mock_class ( :posts , primary_key , columns , indexes , foreign_keys ) . tap do |mock_klass |
408
+ mock_class ( :posts , primary_key , columns , mock_connection ( indexes , foreign_keys ) ) . tap do |mock_klass |
409
409
allow ( mock_klass ) . to receive ( :translation_class ) . and_return ( translation_klass )
410
410
end
411
411
end
@@ -2664,14 +2664,14 @@ def annotate_one_file(options = {})
2664
2664
mock_column ( :id , :integer ) ,
2665
2665
mock_column ( :foreign_thing_id , :integer )
2666
2666
] ,
2667
- [ ] ,
2668
- [
2669
- mock_foreign_key ( 'fk_rails_cf2568e89e' ,
2670
- 'foreign_thing_id' ,
2671
- 'foreign_things' ,
2672
- 'id' ,
2673
- on_delete : :cascade )
2674
- ] )
2667
+ mock_connection ( [ ] ,
2668
+ [
2669
+ mock_foreign_key ( 'fk_rails_cf2568e89e' ,
2670
+ 'foreign_thing_id' ,
2671
+ 'foreign_things' ,
2672
+ 'id' ,
2673
+ on_delete : :cascade )
2674
+ ] ) )
2675
2675
@schema_info = AnnotateModels . get_schema_info ( klass , '== Schema Info' , show_foreign_keys : true )
2676
2676
annotate_one_file
2677
2677
end
@@ -2683,14 +2683,16 @@ def annotate_one_file(options = {})
2683
2683
mock_column ( :id , :integer ) ,
2684
2684
mock_column ( :foreign_thing_id , :integer )
2685
2685
] ,
2686
- [ ] ,
2687
- [
2688
- mock_foreign_key ( 'fk_rails_cf2568e89e' ,
2689
- 'foreign_thing_id' ,
2690
- 'foreign_things' ,
2691
- 'id' ,
2692
- on_delete : :restrict )
2693
- ] )
2686
+ mock_connection (
2687
+ [ ] ,
2688
+ [
2689
+ mock_foreign_key ( 'fk_rails_cf2568e89e' ,
2690
+ 'foreign_thing_id' ,
2691
+ 'foreign_things' ,
2692
+ 'id' ,
2693
+ on_delete : :restrict )
2694
+ ]
2695
+ ) )
2694
2696
@schema_info = AnnotateModels . get_schema_info ( klass , '== Schema Info' , show_foreign_keys : true )
2695
2697
annotate_one_file
2696
2698
expect ( File . read ( @model_file_name ) ) . to eq ( "#{ @schema_info } #{ @file_content } " )
0 commit comments