Skip to content

Commit 536b6f8

Browse files
committed
Move test cases when the primary key is an array (using composite_primary_keys)
1 parent d9618a0 commit 536b6f8

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,37 @@ def mock_column(name, type, options = {})
427427
end
428428
end
429429
end
430+
431+
context 'when the primary key is an array (using composite_primary_keys)' do
432+
let :primary_key do
433+
[:a_id, :b_id]
434+
end
435+
436+
let :columns do
437+
[
438+
mock_column(:a_id, :integer),
439+
mock_column(:b_id, :integer),
440+
mock_column(:name, :string, limit: 50)
441+
]
442+
end
443+
444+
let :expected_result do
445+
<<~EOS
446+
# Schema Info
447+
#
448+
# Table name: users
449+
#
450+
# a_id :integer not null, primary key
451+
# b_id :integer not null, primary key
452+
# name :string(50) not null
453+
#
454+
EOS
455+
end
456+
457+
it 'returns schema info' do
458+
is_expected.to eq(expected_result)
459+
end
460+
end
430461
end
431462
end
432463
end
@@ -830,45 +861,6 @@ def mock_column(name, type, options = {})
830861
end
831862
end
832863

833-
context 'when header is "Schema Info"' do
834-
let :header do
835-
'Schema Info'
836-
end
837-
838-
context 'when the primary key is specified' do
839-
context 'when the primary key is an array (using composite_primary_keys)' do
840-
let :primary_key do
841-
[:a_id, :b_id]
842-
end
843-
844-
let :columns do
845-
[
846-
mock_column(:a_id, :integer),
847-
mock_column(:b_id, :integer),
848-
mock_column(:name, :string, limit: 50)
849-
]
850-
end
851-
852-
let :expected_result do
853-
<<~EOS
854-
# Schema Info
855-
#
856-
# Table name: users
857-
#
858-
# a_id :integer not null, primary key
859-
# b_id :integer not null, primary key
860-
# name :string(50) not null
861-
#
862-
EOS
863-
end
864-
865-
it 'returns schema info' do
866-
is_expected.to eq(expected_result)
867-
end
868-
end
869-
end
870-
end
871-
872864
context 'when header is "== Schema Information"' do
873865
let :header do
874866
AnnotateModels::PREFIX

0 commit comments

Comments
 (0)