Skip to content

Commit fc204d7

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

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -357,40 +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 foreign key info if on_delete/on_update options present' 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_02e851e3b7',
370-
'foreign_thing_id',
371-
'foreign_things',
372-
'id',
373-
on_delete: 'on_delete_value',
374-
on_update: 'on_update_value')
375-
])
376-
377-
expected_result = <<~EOS
378-
# Schema Info
379-
#
380-
# Table name: users
381-
#
382-
# id :integer not null, primary key
383-
# foreign_thing_id :integer not null
384-
#
385-
# Foreign Keys
386-
#
387-
# fk_rails_... (foreign_thing_id => foreign_things.id) ON DELETE => on_delete_value ON UPDATE => on_update_value
388-
#
389-
EOS
390-
391-
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_foreign_keys: true)).to eql(expected_result)
392-
end
393-
394360
it 'should get indexes keys' do
395361
klass = mock_class(:users,
396362
:id,
@@ -596,6 +562,40 @@ def mock_column(name, type, options = {})
596562
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_indexes: true)).to eql(expected_result)
597563
end
598564

565+
it 'should get foreign key info if on_delete/on_update options present' do
566+
klass = mock_class(:users,
567+
:id,
568+
[
569+
mock_column(:id, :integer),
570+
mock_column(:foreign_thing_id, :integer)
571+
],
572+
[],
573+
[
574+
mock_foreign_key('fk_rails_02e851e3b7',
575+
'foreign_thing_id',
576+
'foreign_things',
577+
'id',
578+
on_delete: 'on_delete_value',
579+
on_update: 'on_update_value')
580+
])
581+
582+
expected_result = <<~EOS
583+
# Schema Info
584+
#
585+
# Table name: users
586+
#
587+
# id :integer not null, primary key
588+
# foreign_thing_id :integer not null
589+
#
590+
# Foreign Keys
591+
#
592+
# fk_rails_... (foreign_thing_id => foreign_things.id) ON DELETE => on_delete_value ON UPDATE => on_update_value
593+
#
594+
EOS
595+
596+
expect(AnnotateModels.get_schema_info(klass, 'Schema Info', show_foreign_keys: true)).to eql(expected_result)
597+
end
598+
599599
it 'should get complete foreign key info' do
600600
klass = mock_class(:users,
601601
:id,

0 commit comments

Comments
 (0)