Skip to content

Commit 217f0e8

Browse files
committed
Add test coverage for bulk altering timestamps
1 parent 4913525 commit 217f0e8

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

activerecord/test/cases/migration_test.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,42 @@ def test_removing_columns
11771177
assert column(:qualification_experience)
11781178
end
11791179

1180+
def test_adding_timestamps
1181+
with_bulk_change_table do |t|
1182+
t.string :title
1183+
end
1184+
1185+
assert column(:title)
1186+
1187+
assert_queries(1) do
1188+
with_bulk_change_table do |t|
1189+
t.timestamps
1190+
t.remove :title
1191+
end
1192+
end
1193+
1194+
[:created_at, :updated_at].each { |c| assert column(c) }
1195+
assert_not column(:title)
1196+
end
1197+
1198+
def test_removing_timestamps
1199+
with_bulk_change_table do |t|
1200+
t.timestamps
1201+
end
1202+
1203+
[:created_at, :updated_at].each { |c| assert column(c) }
1204+
1205+
assert_queries(1) do
1206+
with_bulk_change_table do |t|
1207+
t.remove_timestamps
1208+
t.string :title
1209+
end
1210+
end
1211+
1212+
[:created_at, :updated_at].each { |c| assert_not column(c) }
1213+
assert column(:title)
1214+
end
1215+
11801216
def test_adding_indexes
11811217
with_bulk_change_table do |t|
11821218
t.string :username

0 commit comments

Comments
 (0)