ruby on rails - How to use the new ActiveSupport::Testing::TimeHelpers inside controller -
edit make more clear
like title tells how use awesome activesupport::testing::timehelpers#travel_to method inside controller. in tests, want achieve this:
somethingconroller < applicationcontroller def index travel_to some_date # stuff depends on current_date end end end
tried include module:
include activesupport::testing::timehelpers
but got:
uninitialized constant activesupport::testing
hoping date traveled applied view
, view_helpers
, controller_action
if must, add require 'active_support/testing/time_helpers'
@ top of file.
although i've no idea you're doing code. try instead:
somethingconroller < applicationcontroller def index @instance = somemodel.find_by_date(12.days.ago) end end
Comments
Post a Comment