Skip to content

Commit 0f288cf

Browse files
committed
[Fix] Expect truncated tables in any order, and handle postgres extra table
1 parent d519bf4 commit 0f288cf

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

spec/database_cleaner/active_record/truncation_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@
106106
it "specifies cascade when truncating" do
107107
User.create!({name: 1})
108108

109-
expect(strategy.send(:connection)).to receive(:truncate_tables).with(['users', 'agents'], {truncate_option: :cascade})
109+
tables_to_truncate = ["agents", "users"]
110+
tables_to_truncate << "user_profiles" if helper.db == :postgres
111+
112+
expect(strategy.send(:connection)).to receive(:truncate_tables).with(array_including(tables_to_truncate), {truncate_option: :cascade})
110113
strategy.clean
111114
end
112115
end
@@ -117,7 +120,10 @@
117120
it "specifies restrict when truncating" do
118121
User.create!
119122

120-
expect(strategy.send(:connection)).to receive(:truncate_tables).with(['users', 'agents'], {truncate_option: :restrict})
123+
tables_to_truncate = ["agents", "users"]
124+
tables_to_truncate << "user_profiles" if helper.db == :postgres
125+
126+
expect(strategy.send(:connection)).to receive(:truncate_tables).with(array_including(tables_to_truncate), {truncate_option: :restrict})
121127
strategy.clean
122128
end
123129
end

0 commit comments

Comments
 (0)