Skip to content

Commit 001b03c

Browse files
committed
Restore test settings before after_suite to fix cross-suite leak
after_all ran after_suite before restoring the per-suite settings snapshot. Suites that enable a setting in before_suite (e.g. test_rack_attack sets enable_security) and do privileged cleanup in after_suite (deleting users) then ran that teardown with the setting still active -> WriteAccessDeniedError. Because after_suite raised, restore_settings never ran, so enable_security leaked into every later suite (data-setup WriteAccessDenied, 401s on public routes). Restore first so teardown runs with settings rolled back and a raising after_suite cannot leak.
1 parent ffadcd8 commit 001b03c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

test/test_case.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,12 @@ def before_all
178178
end
179179

180180
def after_all
181-
after_suite
181+
# Restore settings BEFORE after_suite: teardown often does privileged
182+
# cleanup (deleting users/ontologies) that must run with the suite's
183+
# settings rolled back (e.g. security off). Restoring first also means a
184+
# raising after_suite can't leak a flipped setting into the next suite.
182185
restore_settings(self.class.instance_variable_get(:@suite_settings_snapshot))
186+
after_suite
183187
super
184188
end
185189

0 commit comments

Comments
 (0)