Created
March 31, 2017 11:22
-
-
Save naveedkakal/97544531c74976fb4c29b386daf65bb6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This allows us to set a different date | |
# in the admin area, and use TimeCop to process each | |
# request as being on that different date - useful for | |
# testing different phases of the challenge. | |
module TimeTravelFilters | |
extend ActiveSupport::Concern | |
included do | |
if Rails.env.development? || Rails.env.staging? | |
around_filter :time_travel_for_request | |
end | |
end | |
def time_travel_for_request | |
time_travel | |
yield | |
time_travel_return | |
end | |
def time_travel | |
logger.info 'TIME TRAVEL START' | |
if session[:timecop_date] | |
Timecop.travel(session[:timecop_date]) | |
else | |
Timecop.return | |
end | |
end | |
def time_travel_return | |
logger.info 'TIME TRAVEL RETURN' | |
Timecop.return | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment