Skip to content

Commit 7b0ba36

Browse files
committed
Change position of test cases
1 parent fc204d7 commit 7b0ba36

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -318,45 +318,6 @@ def mock_column(name, type, options = {})
318318
expect(AnnotateModels.get_schema_info(klass, 'Schema Info')).to eql(expected_result)
319319
end
320320

321-
it 'should get foreign key info' do
322-
klass = mock_class(:users,
323-
:id,
324-
[
325-
mock_column(:id, :integer),
326-
mock_column(:foreign_thing_id, :integer)
327-
],
328-
[],
329-
[
330-
mock_foreign_key('fk_rails_cf2568e89e',
331-
'foreign_thing_id',
332-
'foreign_things'),
333-
mock_foreign_key('custom_fk_name',
334-
'other_thing_id',
335-
'other_things'),
336-
mock_foreign_key('fk_rails_a70234b26c',
337-
'third_thing_id',
338-
'third_things')
339-
])
340-
341-
expected_result = <<~EOS
342-
# Schema Info
343-
#
344-
# Table name: users
345-
#
346-
# id :integer not null, primary key
347-
# foreign_thing_id :integer not null
348-
#
349-
# Foreign Keys
350-
#
351-
# custom_fk_name (other_thing_id => other_things.id)
352-
# fk_rails_... (foreign_thing_id => foreign_things.id)
353-
# fk_rails_... (third_thing_id => third_things.id)
354-
#
355-
EOS
356-
357-
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_foreign_keys: true)).to eql(expected_result)
358-
end
359-
360321
it 'should get indexes keys' do
361322
klass = mock_class(:users,
362323
:id,
@@ -562,6 +523,45 @@ def mock_column(name, type, options = {})
562523
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_indexes: true)).to eql(expected_result)
563524
end
564525

526+
it 'should get foreign key info' do
527+
klass = mock_class(:users,
528+
:id,
529+
[
530+
mock_column(:id, :integer),
531+
mock_column(:foreign_thing_id, :integer)
532+
],
533+
[],
534+
[
535+
mock_foreign_key('fk_rails_cf2568e89e',
536+
'foreign_thing_id',
537+
'foreign_things'),
538+
mock_foreign_key('custom_fk_name',
539+
'other_thing_id',
540+
'other_things'),
541+
mock_foreign_key('fk_rails_a70234b26c',
542+
'third_thing_id',
543+
'third_things')
544+
])
545+
546+
expected_result = <<~EOS
547+
# Schema Info
548+
#
549+
# Table name: users
550+
#
551+
# id :integer not null, primary key
552+
# foreign_thing_id :integer not null
553+
#
554+
# Foreign Keys
555+
#
556+
# custom_fk_name (other_thing_id => other_things.id)
557+
# fk_rails_... (foreign_thing_id => foreign_things.id)
558+
# fk_rails_... (third_thing_id => third_things.id)
559+
#
560+
EOS
561+
562+
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_foreign_keys: true)).to eql(expected_result)
563+
end
564+
565565
it 'should get foreign key info if on_delete/on_update options present' do
566566
klass = mock_class(:users,
567567
:id,

0 commit comments

Comments
 (0)