Sha256: ec7b3a7f19324720ae8e359de7aaeff3e06bb49de5dd30a91c7b986d65b5b6e6
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
# Defines extensions applied to ActionController::Base to support our time travel module TimecopConsole module ControllerMethods def self.included(base) base.class_eval do around_filter :handle_timecop_offset end end # to be used as an around_filter def handle_timecop_offset # Establish now if session[TimecopConsole::SESSION_KEY_NAME].present? Rails.logger.debug "[timecop-console] Time traveling to #{session[TimecopConsole::SESSION_KEY_NAME].to_s}" Timecop.travel(session[TimecopConsole::SESSION_KEY_NAME]) else Timecop.return end # Run the intended action yield if session[TimecopConsole::SESSION_KEY_NAME].present? # we want to continue to slide time forward, even if it's only 3 seconds at a time. # this ensures that subsequent calls during the same "time travel" actually pass time adjusted_time = Time.now + 3 Rails.logger.debug "[timecop-console] Resetting session to: #{adjusted_time}" session[TimecopConsole::SESSION_KEY_NAME] = adjusted_time end end private :handle_timecop_offset end end
Version data entries
3 entries across 3 versions & 1 rubygems