Move TimeZoneSetter middleware in proper place (#11336)
* Move TimeZoneSetter middleware in proper place * Use explicit naming
This commit is contained in:
parent
f84b0d5ad5
commit
38963c6629
3 changed files with 13 additions and 14 deletions
|
|
@ -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
|
||||
12
app/middlewares/set_time_zone.rb
Normal file
12
app/middlewares/set_time_zone.rb
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue