spec/zdm_spec.rb in zdm-1.0.7 vs spec/zdm_spec.rb in zdm-1.1.0

- old
+ new

@@ -43,11 +43,11 @@ conn = ActiveRecord::Base.connection stmt = conn.select_rows('show create table people')[0][1] expect(stmt.squish).to eq(<<-EOS.squish) CREATE TABLE `people` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` #{Zdm.rails5? ? 'bigint(20)' : 'int(11)'} NOT NULL AUTO_INCREMENT, `account_id` int(11) DEFAULT NULL, `name` varchar(99) COLLATE utf8_unicode_ci NOT NULL, `code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` datetime DEFAULT NULL, `test` varchar(32) COLLATE utf8_unicode_ci DEFAULT 'foo', @@ -80,11 +80,11 @@ end stmt = conn.select_rows('show create table people')[0][1] expect(stmt.squish).to eq(<<-EOS.squish) CREATE TABLE `people` ( - `id` int(11) NOT NULL AUTO_INCREMENT, + `id` #{Zdm.rails5? ? 'bigint(20)' : 'int(11)'} NOT NULL AUTO_INCREMENT, `account_id` int(11) DEFAULT NULL, `name` varchar(30) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `created_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), @@ -169,7 +169,20 @@ ]) end end + it 'cleans up archive tables' do + Zdm.change_table(:people) do |m| + m.add_column('test2', "varchar(1)") + end + Zdm.cleanup(before: 1.day.ago) + conn = ActiveRecord::Base.connection + tables = conn.send(Zdm.tables_method).select { |name| name.starts_with?('zdma_') } + expect(tables).to_not be_empty + + Zdm.cleanup(before: 1.day.from_now) + tables = conn.send(Zdm.tables_method).select { |name| name.starts_with?('zdma_') } + expect(tables).to be_empty + end end \ No newline at end of file