Skip to content

Commit 96e5e02

Browse files
committed
Move test cases when "hide_limit_column_types" is specified in options
1 parent 7263d55 commit 96e5e02

File tree

1 file changed

+83
-83
lines changed

1 file changed

+83
-83
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,89 @@ def mock_column(name, type, options = {})
856856
end
857857
end
858858
end
859+
860+
context 'when "hide_limit_column_types" is specified in options' do
861+
let :columns do
862+
[
863+
mock_column(:id, :integer, limit: 8),
864+
mock_column(:active, :boolean, limit: 1),
865+
mock_column(:name, :string, limit: 50),
866+
mock_column(:notes, :text, limit: 55)
867+
]
868+
end
869+
870+
context 'when "hide_limit_column_types" is blank string' do
871+
let :options do
872+
{ hide_limit_column_types: '' }
873+
end
874+
875+
let :expected_result do
876+
<<~EOS
877+
# Schema Info
878+
#
879+
# Table name: users
880+
#
881+
# id :integer not null, primary key
882+
# active :boolean not null
883+
# name :string(50) not null
884+
# notes :text(55) not null
885+
#
886+
EOS
887+
end
888+
889+
it 'works with option "hide_limit_column_types"' do
890+
is_expected.to eq expected_result
891+
end
892+
end
893+
894+
context 'when "hide_limit_column_types" is "integer,boolean"' do
895+
let :options do
896+
{ hide_limit_column_types: 'integer,boolean' }
897+
end
898+
899+
let :expected_result do
900+
<<~EOS
901+
# Schema Info
902+
#
903+
# Table name: users
904+
#
905+
# id :integer not null, primary key
906+
# active :boolean not null
907+
# name :string(50) not null
908+
# notes :text(55) not null
909+
#
910+
EOS
911+
end
912+
913+
it 'works with option "hide_limit_column_types"' do
914+
is_expected.to eq expected_result
915+
end
916+
end
917+
918+
context 'when "hide_limit_column_types" is "integer,boolean,string,text"' do
919+
let :options do
920+
{ hide_limit_column_types: 'integer,boolean,string,text' }
921+
end
922+
923+
let :expected_result do
924+
<<~EOS
925+
# Schema Info
926+
#
927+
# Table name: users
928+
#
929+
# id :integer not null, primary key
930+
# active :boolean not null
931+
# name :string not null
932+
# notes :text not null
933+
#
934+
EOS
935+
end
936+
937+
it 'works with option "hide_limit_column_types"' do
938+
is_expected.to eq expected_result
939+
end
940+
end
941+
end
859942
end
860943
end
861944
end
@@ -1309,89 +1392,6 @@ def mock_column(name, type, options = {})
13091392
end
13101393

13111394
context 'with options' do
1312-
context 'when "hide_limit_column_types" is specified in options' do
1313-
let :columns do
1314-
[
1315-
mock_column(:id, :integer, limit: 8),
1316-
mock_column(:active, :boolean, limit: 1),
1317-
mock_column(:name, :string, limit: 50),
1318-
mock_column(:notes, :text, limit: 55)
1319-
]
1320-
end
1321-
1322-
context 'when "hide_limit_column_types" is blank string' do
1323-
let :options do
1324-
{ hide_limit_column_types: '' }
1325-
end
1326-
1327-
let :expected_result do
1328-
<<~EOS
1329-
# Schema Info
1330-
#
1331-
# Table name: users
1332-
#
1333-
# id :integer not null, primary key
1334-
# active :boolean not null
1335-
# name :string(50) not null
1336-
# notes :text(55) not null
1337-
#
1338-
EOS
1339-
end
1340-
1341-
it 'works with option "hide_limit_column_types"' do
1342-
is_expected.to eq expected_result
1343-
end
1344-
end
1345-
1346-
context 'when "hide_limit_column_types" is "integer,boolean"' do
1347-
let :options do
1348-
{ hide_limit_column_types: 'integer,boolean' }
1349-
end
1350-
1351-
let :expected_result do
1352-
<<~EOS
1353-
# Schema Info
1354-
#
1355-
# Table name: users
1356-
#
1357-
# id :integer not null, primary key
1358-
# active :boolean not null
1359-
# name :string(50) not null
1360-
# notes :text(55) not null
1361-
#
1362-
EOS
1363-
end
1364-
1365-
it 'works with option "hide_limit_column_types"' do
1366-
is_expected.to eq expected_result
1367-
end
1368-
end
1369-
1370-
context 'when "hide_limit_column_types" is "integer,boolean,string,text"' do
1371-
let :options do
1372-
{ hide_limit_column_types: 'integer,boolean,string,text' }
1373-
end
1374-
1375-
let :expected_result do
1376-
<<~EOS
1377-
# Schema Info
1378-
#
1379-
# Table name: users
1380-
#
1381-
# id :integer not null, primary key
1382-
# active :boolean not null
1383-
# name :string not null
1384-
# notes :text not null
1385-
#
1386-
EOS
1387-
end
1388-
1389-
it 'works with option "hide_limit_column_types"' do
1390-
is_expected.to eq expected_result
1391-
end
1392-
end
1393-
end
1394-
13951395
context 'when "hide_default_column_types" is specified in options' do
13961396
let :columns do
13971397
[

0 commit comments

Comments
 (0)