Skip to content

Commit 3748bab

Browse files
authored
Merge pull request #124 from DatabaseCleaner/fix-truncated-tables-expectation-order
[Fix] Expect truncated tables in any order, and handle postgres extra table
2 parents e260a10 + 2913916 commit 3748bab

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Provide a 'Changelog' link on Rubygems: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/114
44
* Fix bundling and CONTRIBUTE.md instructions: https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/123
5+
* Fix order of arguments in `truncate_tables` expectation https://github.com/DatabaseCleaner/database_cleaner-active_record/pull/124
56

67
## v2.2.1 2025-05-13
78

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)