Closed jarosluv closed 1 month ago
As usual, right after I posted the bug report, I realized the issue. I'll leave this note here in case someone else faces a similar situation.
From the documentation, I understood that between tests, you should use Rack::Attack.clear_configuration
to isolate test examples. However, this command actually resets all throttling, blocking, etc. settings and configurations made in the app initializer.
In reality, to isolate test scenarios, you should use Rack::Attack.cache.store.clear
(or Rails.cache.clear
). This way, the configuration is preserved, but the locks are cleared.
So, my question is: Did I misunderstand the documentation in README.md
, or is this aspect described ambiguously?
Hi @jarosluv. First of all, thanks for the detailed report.
From the README
I understand that between test cases you should use Rack::Attack.reset!
, and only use Rack::Attack.clear_configuration
to unset blocklist and safelist configurations.
That said, if you want to open a PR improving the README
, I'm open to review it.
Using
Rack::Attack.clear_configuration
breaks subsequent tests.Expected Behavior
Second consecutive request is throttled when Rack Attack throttling is set to limit = 1.
Actual Behavior
Second consecutive request returns status code 200 when I use
Rack::Attack.clear_configuration
in the previous test.Steps to Reproduce