Skip to content

Commit 66b2c25

Browse files
committed
Change position of test cases
1 parent bff7b46 commit 66b2c25

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
@@ -357,45 +357,6 @@ def mock_column(name, type, options = {})
357357
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_foreign_keys: true)).to eql(expected_result)
358358
end
359359

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-
399360
it 'should get foreign key info if on_delete/on_update options present' do
400361
klass = mock_class(:users,
401362
:id,
@@ -635,6 +596,45 @@ def mock_column(name, type, options = {})
635596
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_indexes: true)).to eql(expected_result)
636597
end
637598

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+
638638
it 'should get schema info as RDoc' do
639639
klass = mock_class(:users,
640640
:id,

0 commit comments

Comments
 (0)