Skip to content

Commit

Permalink
fix rubocop error
Browse files Browse the repository at this point in the history
  • Loading branch information
APPLE4869 committed Mar 16, 2022
1 parent c3eac51 commit bf78806
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def mock_connection(indexes = [], foreign_keys = [], table_comment = nil)
table_comment: table_comment)
end

def mock_class(table_name, primary_key, columns, indexes = [], foreign_keys = [], table_comment = nil)
def mock_class(table_name, primary_key, columns, connection = mock_connection)
options = {
connection: mock_connection(indexes, foreign_keys, table_comment),
connection: connection,
table_exists?: true,
table_name: table_name,
primary_key: primary_key,
Expand Down Expand Up @@ -218,7 +218,7 @@ def mock_column(name, type, options = {})
end

let :klass do
mock_class(:users, primary_key, columns, indexes, foreign_keys, table_comment)
mock_class(:users, primary_key, columns, mock_connection(indexes, foreign_keys, table_comment))
end

let :indexes do
Expand Down Expand Up @@ -405,7 +405,7 @@ def mock_column(name, type, options = {})
end

let :klass do
mock_class(:posts, primary_key, columns, indexes, foreign_keys).tap do |mock_klass|
mock_class(:posts, primary_key, columns, mock_connection(indexes, foreign_keys)).tap do |mock_klass|
allow(mock_klass).to receive(:translation_class).and_return(translation_klass)
end
end
Expand Down Expand Up @@ -2664,14 +2664,14 @@ def annotate_one_file(options = {})
mock_column(:id, :integer),
mock_column(:foreign_thing_id, :integer)
],
[],
[
mock_foreign_key('fk_rails_cf2568e89e',
'foreign_thing_id',
'foreign_things',
'id',
on_delete: :cascade)
])
mock_connection([],
[
mock_foreign_key('fk_rails_cf2568e89e',
'foreign_thing_id',
'foreign_things',
'id',
on_delete: :cascade)
]))
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', show_foreign_keys: true)
annotate_one_file
end
Expand All @@ -2683,14 +2683,16 @@ def annotate_one_file(options = {})
mock_column(:id, :integer),
mock_column(:foreign_thing_id, :integer)
],
[],
[
mock_foreign_key('fk_rails_cf2568e89e',
'foreign_thing_id',
'foreign_things',
'id',
on_delete: :restrict)
])
mock_connection(
[],
[
mock_foreign_key('fk_rails_cf2568e89e',
'foreign_thing_id',
'foreign_things',
'id',
on_delete: :restrict)
]
))
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', show_foreign_keys: true)
annotate_one_file
expect(File.read(@model_file_name)).to eq("#{@schema_info}#{@file_content}")
Expand Down

0 comments on commit bf78806

Please sign in to comment.