1

I am working on a task that requires me to throttle payment requests, limiting to one payment per few seconds. The task is well done and working as should, even the tests to confirm the throttle is well implemented are working as should. My only problem is that it's making other payment tests fail.

I have been looking at different articles and they say adding Rack::Attack.enabled = false can fix that for me but it's clearly not because my tests are still failing, tests are still failing.

Below are the articles I've read and implemented and nothing works so far:

Has anyone worked with rack-attack and experienced this?

This is the code I added and everything is still failing: Added Rack::Attack.enabled = false on config/environments/test.rb and I added this on the test file to test it:

before do
 # Enable Rack::Attack for this test
 Rack::Attack.enabled = true
 Rack::Attack.reset!
end

after do
 # Disable Rack::Attack for future tests so it doesn't
 # interfere with the rest of our tests
 Rack::Attack.enabled = false
end

Am I missing something?

Linda Kadz
  • 329
  • 2
  • 17
  • i don't think turn off the `Rack::Attack.enabled` is the good way to go even other payment tests pass since in reality `Rack::Attack.enabled` is always true, right ? furthermore, other payment tests failed indicate that your `throttle` code affect other payment methods, so instead of finding the cheat way somehow all tests pass, you have to figure out what the root cause the test failed (i guess in your `throttle` code, so you should provide this code and also the test failed result). – Lam Phan Dec 03 '21 at 05:09

0 Answers0