Module: TimecopConsole::MainHelper

Defined in:
app/helpers/timecop_console/main_helper.rb

Instance Method Summary collapse

Instance Method Details

#time_travel_to(date) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/helpers/timecop_console/main_helper.rb', line 3

def time_travel_to(date)
  unless date.respond_to?(:year) && date.respond_to?(:month) && date.respond_to?(:day)
    raise ArgumentError, "Argument must be a Date object"
  end

  update_path = timecop_console.update_path(timecop: {
    'current_time(1i)' => date.year,
    'current_time(2i)' => date.month,
    'current_time(3i)' => date.day,
    'current_time(4i)' => 12,
    'current_time(5i)' => 0
  })

  button_to(date.strftime("%B %d, %Y"),
            update_path,
            method: :post)
end