[deploy] Flaky Spec Fix:Set TimeZone For All Spec Requests to Match Zonebie (#10891)
This commit is contained in:
parent
adb41a0a15
commit
c55bd0948f
3 changed files with 21 additions and 0 deletions
13
app/lib/middleware/time_zone_setter.rb
Normal file
13
app/lib/middleware/time_zone_setter.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
module Middleware
|
||||
class TimeZoneSetter
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
Time.zone = ActiveSupport::TimeZone.new(ENV["TZ"]) if ENV["TZ"]
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -5,6 +5,10 @@ $VERBOSE = nil
|
|||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Include middleware to ensure timezone for browser requests for Capybara specs
|
||||
# matches the random zonebie timezone set at the beginning of our spec run
|
||||
config.middleware.use(Middleware::TimeZoneSetter)
|
||||
|
||||
# The test environment is used exclusively to run your application's
|
||||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
|
|
|
|||
|
|
@ -84,6 +84,10 @@ RSpec.configure do |config|
|
|||
end
|
||||
|
||||
config.before(:suite) do
|
||||
# Set the TZ ENV variable with the current random timezone from zonebie
|
||||
# which we can then use to properly set the browser time for Capybara specs
|
||||
ENV["TZ"] = Time.zone.tzinfo.name
|
||||
|
||||
Search::Cluster.recreate_indexes
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue