-
Notifications
You must be signed in to change notification settings - Fork 762
Open
Labels
Description
The readme explains how to disable callbacks in the test environment with Searchkick.disable_callbacks
. As described in #1031, this does not disable callbacks when running Rails system tests as the server starts in a separate thread.
I suggest adding info on how to disable callbacks to that section of the readme. In particular, the code suggested in that issue, or something like this:
System tests
As the callbacks setting is a thread variable, you will need to add additional code to disable it in system tests.
lib/searchkick_disable_middleware.rb
:
class SearchkickDisableMiddleware
def initialize(app)
@app = app
end
def call(env)
Searchkick.callbacks(false) do
@app.call(env)
end
end
end
In config/environments/test.rb
:
require 'searchkick_disable_middleware'
Rails.application.configure do
# (Your other configuration...)
config.middleware.insert_before(0, SearchkickDisableMiddleware)
end
SofiaSousa