Skip to content

Commit a6cd153

Browse files
committed
Change position of test cases
1 parent 4a70ffd commit a6cd153

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -767,49 +767,6 @@ def mock_column(name, type, options = {})
767767
end
768768
end
769769

770-
context 'when option "show_foreign_keys" is true' do
771-
context 'when foreign_keys have option "on_delete" and "on_update"' do
772-
it 'should get schema info as Markdown with foreign keys' do
773-
klass = mock_class(:users,
774-
:id,
775-
[
776-
mock_column(:id, :integer),
777-
mock_column(:foreign_thing_id, :integer)
778-
],
779-
[],
780-
[
781-
mock_foreign_key('fk_rails_02e851e3b7',
782-
'foreign_thing_id',
783-
'foreign_things',
784-
'id',
785-
on_delete: 'on_delete_value',
786-
on_update: 'on_update_value')
787-
])
788-
789-
expected_result = <<~EOS
790-
# == Schema Information
791-
#
792-
# Table name: `users`
793-
#
794-
# ### Columns
795-
#
796-
# Name | Type | Attributes
797-
# ----------------------- | ------------------ | ---------------------------
798-
# **`id`** | `integer` | `not null, primary key`
799-
# **`foreign_thing_id`** | `integer` | `not null`
800-
#
801-
# ### Foreign Keys
802-
#
803-
# * `fk_rails_...` (_ON DELETE => on_delete_value ON UPDATE => on_update_value_):
804-
# * **`foreign_thing_id => foreign_things.id`**
805-
#
806-
EOS
807-
808-
expect(AnnotateModels.get_schema_info(klass, AnnotateModels::PREFIX, format_markdown: true, show_foreign_keys: true)).to eql(expected_result)
809-
end
810-
end
811-
end
812-
813770
context 'when option "show_indexes" is true' do
814771
context 'when indexes are normal' do
815772
it 'should get schema info as Markdown with indexes' do
@@ -1011,6 +968,49 @@ def mock_column(name, type, options = {})
1011968
end
1012969
end
1013970
end
971+
972+
context 'when option "show_foreign_keys" is true' do
973+
context 'when foreign_keys have option "on_delete" and "on_update"' do
974+
it 'should get schema info as Markdown with foreign keys' do
975+
klass = mock_class(:users,
976+
:id,
977+
[
978+
mock_column(:id, :integer),
979+
mock_column(:foreign_thing_id, :integer)
980+
],
981+
[],
982+
[
983+
mock_foreign_key('fk_rails_02e851e3b7',
984+
'foreign_thing_id',
985+
'foreign_things',
986+
'id',
987+
on_delete: 'on_delete_value',
988+
on_update: 'on_update_value')
989+
])
990+
991+
expected_result = <<~EOS
992+
# == Schema Information
993+
#
994+
# Table name: `users`
995+
#
996+
# ### Columns
997+
#
998+
# Name | Type | Attributes
999+
# ----------------------- | ------------------ | ---------------------------
1000+
# **`id`** | `integer` | `not null, primary key`
1001+
# **`foreign_thing_id`** | `integer` | `not null`
1002+
#
1003+
# ### Foreign Keys
1004+
#
1005+
# * `fk_rails_...` (_ON DELETE => on_delete_value ON UPDATE => on_update_value_):
1006+
# * **`foreign_thing_id => foreign_things.id`**
1007+
#
1008+
EOS
1009+
1010+
expect(AnnotateModels.get_schema_info(klass, AnnotateModels::PREFIX, format_markdown: true, show_foreign_keys: true)).to eql(expected_result)
1011+
end
1012+
end
1013+
end
10141014
end
10151015
end
10161016
end

0 commit comments

Comments
 (0)