Move TimeZoneSetter middleware in proper place (#11336)

* Move TimeZoneSetter middleware in proper place

* Use explicit naming
This commit is contained in:
rhymes 2020-11-09 17:11:10 +01:00 committed by GitHub
parent f84b0d5ad5
commit 38963c6629
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 14 deletions

View file

@ -1,13 +0,0 @@
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

View file

@ -0,0 +1,12 @@
# NOTE: this middleware is only for test mode
class SetTimeZone
def initialize(app)
@app = app
end
def call(env)
Time.zone = ActiveSupport::TimeZone.new(ENV["TZ"]) if ENV["TZ"]
@app.call(env)
end
end

View file

@ -4,7 +4,7 @@ Rails.application.configure do
# 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)
config.middleware.use SetTimeZone
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that