Skip to content

Commit 8195810

Browse files
committed
add spec when both table and columns have comments
1 parent c3d1c76 commit 8195810

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,41 @@ def mock_column(name, type, options = {})
11401140
end
11411141
end
11421142

1143+
context 'when both table and columns have comments' do
1144+
let :table_comment do
1145+
'users table comment'
1146+
end
1147+
1148+
let :columns do
1149+
[
1150+
mock_column(:id, :integer, limit: 8, comment: 'ID'),
1151+
mock_column(:active, :boolean, limit: 1, comment: 'Active'),
1152+
mock_column(:name, :string, limit: 50, comment: 'Name'),
1153+
mock_column(:notes, :text, limit: 55, comment: 'Notes'),
1154+
mock_column(:no_comment, :text, limit: 20, comment: nil)
1155+
]
1156+
end
1157+
1158+
let :expected_result do
1159+
<<~EOS
1160+
# Schema Info
1161+
#
1162+
# Table name: users(users table comment)
1163+
#
1164+
# id(ID) :integer not null, primary key
1165+
# active(Active) :boolean not null
1166+
# name(Name) :string(50) not null
1167+
# notes(Notes) :text(55) not null
1168+
# no_comment :text(20) not null
1169+
#
1170+
EOS
1171+
end
1172+
1173+
it 'works with option "with_comment' do
1174+
is_expected.to eq expected_result
1175+
end
1176+
end
1177+
11431178
context 'when columns have multibyte comments' do
11441179
let :columns do
11451180
[

0 commit comments

Comments
 (0)