Skip to content

Commit c781605

Browse files
committed
Move test cases when "hide_default_column_types" is specified in options
1 parent 96e5e02 commit c781605

File tree

1 file changed

+79
-79
lines changed

1 file changed

+79
-79
lines changed

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,85 @@ def mock_column(name, type, options = {})
939939
end
940940
end
941941
end
942+
943+
context 'when "hide_default_column_types" is specified in options' do
944+
let :columns do
945+
[
946+
mock_column(:profile, :json, default: {}),
947+
mock_column(:settings, :jsonb, default: {}),
948+
mock_column(:parameters, :hstore, default: {})
949+
]
950+
end
951+
952+
context 'when "hide_default_column_types" is blank string' do
953+
let :options do
954+
{ hide_default_column_types: '' }
955+
end
956+
957+
let :expected_result do
958+
<<~EOS
959+
# Schema Info
960+
#
961+
# Table name: users
962+
#
963+
# profile :json not null
964+
# settings :jsonb not null
965+
# parameters :hstore not null
966+
#
967+
EOS
968+
end
969+
970+
it 'works with option "hide_default_column_types"' do
971+
is_expected.to eq expected_result
972+
end
973+
end
974+
975+
context 'when "hide_default_column_types" is "skip"' do
976+
let :options do
977+
{ hide_default_column_types: 'skip' }
978+
end
979+
980+
let :expected_result do
981+
<<~EOS
982+
# Schema Info
983+
#
984+
# Table name: users
985+
#
986+
# profile :json default({}), not null
987+
# settings :jsonb default({}), not null
988+
# parameters :hstore default({}), not null
989+
#
990+
EOS
991+
end
992+
993+
it 'works with option "hide_default_column_types"' do
994+
is_expected.to eq expected_result
995+
end
996+
end
997+
998+
context 'when "hide_default_column_types" is "json"' do
999+
let :options do
1000+
{ hide_default_column_types: 'json' }
1001+
end
1002+
1003+
let :expected_result do
1004+
<<~EOS
1005+
# Schema Info
1006+
#
1007+
# Table name: users
1008+
#
1009+
# profile :json not null
1010+
# settings :jsonb default({}), not null
1011+
# parameters :hstore default({}), not null
1012+
#
1013+
EOS
1014+
end
1015+
1016+
it 'works with option "hide_limit_column_types"' do
1017+
is_expected.to eq expected_result
1018+
end
1019+
end
1020+
end
9421021
end
9431022
end
9441023
end
@@ -1392,85 +1471,6 @@ def mock_column(name, type, options = {})
13921471
end
13931472

13941473
context 'with options' do
1395-
context 'when "hide_default_column_types" is specified in options' do
1396-
let :columns do
1397-
[
1398-
mock_column(:profile, :json, default: {}),
1399-
mock_column(:settings, :jsonb, default: {}),
1400-
mock_column(:parameters, :hstore, default: {})
1401-
]
1402-
end
1403-
1404-
context 'when "hide_default_column_types" is blank string' do
1405-
let :options do
1406-
{ hide_default_column_types: '' }
1407-
end
1408-
1409-
let :expected_result do
1410-
<<~EOS
1411-
# Schema Info
1412-
#
1413-
# Table name: users
1414-
#
1415-
# profile :json not null
1416-
# settings :jsonb not null
1417-
# parameters :hstore not null
1418-
#
1419-
EOS
1420-
end
1421-
1422-
it 'works with option "hide_default_column_types"' do
1423-
is_expected.to eq expected_result
1424-
end
1425-
end
1426-
1427-
context 'when "hide_default_column_types" is "skip"' do
1428-
let :options do
1429-
{ hide_default_column_types: 'skip' }
1430-
end
1431-
1432-
let :expected_result do
1433-
<<~EOS
1434-
# Schema Info
1435-
#
1436-
# Table name: users
1437-
#
1438-
# profile :json default({}), not null
1439-
# settings :jsonb default({}), not null
1440-
# parameters :hstore default({}), not null
1441-
#
1442-
EOS
1443-
end
1444-
1445-
it 'works with option "hide_default_column_types"' do
1446-
is_expected.to eq expected_result
1447-
end
1448-
end
1449-
1450-
context 'when "hide_default_column_types" is "json"' do
1451-
let :options do
1452-
{ hide_default_column_types: 'json' }
1453-
end
1454-
1455-
let :expected_result do
1456-
<<~EOS
1457-
# Schema Info
1458-
#
1459-
# Table name: users
1460-
#
1461-
# profile :json not null
1462-
# settings :jsonb default({}), not null
1463-
# parameters :hstore default({}), not null
1464-
#
1465-
EOS
1466-
end
1467-
1468-
it 'works with option "hide_limit_column_types"' do
1469-
is_expected.to eq expected_result
1470-
end
1471-
end
1472-
end
1473-
14741474
context 'when "classified_sort" is specified in options' do
14751475
let :columns do
14761476
[

0 commit comments

Comments
 (0)