From 142f300cbd7446c30729bbc9a4f9676f1f61a3ae Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 13 Feb 2022 17:39:08 +0100 Subject: [PATCH] Fix drop_table with options migration Fix #138 --- lib/chrono_model/adapter/migrations.rb | 2 +- spec/chrono_model/adapter/migrations_spec.rb | 29 ++++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/chrono_model/adapter/migrations.rb b/lib/chrono_model/adapter/migrations.rb index 512cbf51..189925fd 100644 --- a/lib/chrono_model/adapter/migrations.rb +++ b/lib/chrono_model/adapter/migrations.rb @@ -93,7 +93,7 @@ def change_table(table_name, **options, &block) # If dropping a temporal table, drops it from the temporal schema # adding the CASCADE option so to delete the history, view and triggers. # - def drop_table(table_name, *) + def drop_table(table_name, **options) return super unless is_chrono?(table_name) on_temporal_schema { execute "DROP TABLE #{table_name} CASCADE" } diff --git a/spec/chrono_model/adapter/migrations_spec.rb b/spec/chrono_model/adapter/migrations_spec.rb index e9872447..c498d59b 100644 --- a/spec/chrono_model/adapter/migrations_spec.rb +++ b/spec/chrono_model/adapter/migrations_spec.rb @@ -181,17 +181,30 @@ end describe '.drop_table' do - before :all do - adapter.create_table table, :temporal => true, &columns + context 'with temporal tables' do + before :all do + adapter.create_table table, :temporal => true, &columns - adapter.drop_table table + adapter.drop_table table + end + + it { is_expected.to_not have_public_backing } + it { is_expected.to_not have_temporal_backing } + it { is_expected.to_not have_history_backing } + it { is_expected.to_not have_history_functions } + it { is_expected.to_not have_public_interface } end - it { is_expected.to_not have_public_backing } - it { is_expected.to_not have_temporal_backing } - it { is_expected.to_not have_history_backing } - it { is_expected.to_not have_history_functions } - it { is_expected.to_not have_public_interface } + context 'without temporal tables' do + before :all do + adapter.create_table table, :temporal => false, &columns + + adapter.drop_table table, :temporal => false + end + + it { is_expected.to_not have_public_backing } + it { is_expected.to_not have_public_interface } + end end describe '.add_index' do