lib/rails-caddy/controllers/timecop_controller.rb
# to be used as an around_filter
to be used as an around_filter
to be used as an around_filter
def handle_timecop_offset
      if !session[:timecop_adjusted_time].nil?
        Timecop.travel(session[:timecop_adjusted_time])
      else
        Timecop.return
      end
      yield
      if !session[:timecop_adjusted_time].nil?
        session[:timecop_adjusted_time] = Time.now + 3 
      end
    end
def handle_timecop_offset if ! session [ :timecop_adjusted_time ] . nil? Timecop . travel ( session [ :timecop_adjusted_time ] ) else Timecop . return end yield if ! session [ :timecop_adjusted_time ] . nil? session [ :timecop_adjusted_time ] = Time . now + 3 end end
to be used as an around_filter
to be used as an around_filter
# Establish now #puts "***** Time traveling to #{session[:timecop_adjusted_time].to_s}" # Run the intended action # 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 #puts "====== Resetting session to: #{Time.now + 3}" # slide it forward a couple of seconds