Skip to content

Commit bf78806

Browse files
committed
fix rubocop error
1 parent c3eac51 commit bf78806

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

spec/lib/annotate/annotate_models_spec.rb

+22-20
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def mock_connection(indexes = [], foreign_keys = [], table_comment = nil)
4949
table_comment: table_comment)
5050
end
5151

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)
5353
options = {
54-
connection: mock_connection(indexes, foreign_keys, table_comment),
54+
connection: connection,
5555
table_exists?: true,
5656
table_name: table_name,
5757
primary_key: primary_key,
@@ -218,7 +218,7 @@ def mock_column(name, type, options = {})
218218
end
219219

220220
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))
222222
end
223223

224224
let :indexes do
@@ -405,7 +405,7 @@ def mock_column(name, type, options = {})
405405
end
406406

407407
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|
409409
allow(mock_klass).to receive(:translation_class).and_return(translation_klass)
410410
end
411411
end
@@ -2664,14 +2664,14 @@ def annotate_one_file(options = {})
26642664
mock_column(:id, :integer),
26652665
mock_column(:foreign_thing_id, :integer)
26662666
],
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+
]))
26752675
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', show_foreign_keys: true)
26762676
annotate_one_file
26772677
end
@@ -2683,14 +2683,16 @@ def annotate_one_file(options = {})
26832683
mock_column(:id, :integer),
26842684
mock_column(:foreign_thing_id, :integer)
26852685
],
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+
))
26942696
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', show_foreign_keys: true)
26952697
annotate_one_file
26962698
expect(File.read(@model_file_name)).to eq("#{@schema_info}#{@file_content}")

0 commit comments

Comments
 (0)