[ActiveSupport] feature proposal: Create #unfreeze_time to complement #freeze_time in ActiveSupport::Testing::TimeHelpers

ActiveSupport::Testing::TimeHelpers has a method called #freeze_time. It could help users if there was a complementary method called #unfreeze_time

This could mean that a developer could write a test that would stub time at Time.now using #freeze_time, then could call #unfreeze_time when they want to unstub Time

https://github.com/rails/rails/blob/master/activesupport/lib/active_support/testing/time_helpers.rb

I would like to propose this new feature, however this is my first time suggesting a feature in this group so please advise how to take this further if rails contributors like the idea.

How would that method differ from the existing travel_back? If there is a difference, which would be a use case?

It could be set as an alias for #travel_back.

From a semantic perspective #unfreeze_time would read like an opposite to #freeze_time, just like #travel_back is an opposite of #travel_to

It’s a relatively small change that could improve the user experience of using #freeze_time

I think it makes sense. For the code to read well, both verbs have to match.

Would you like to contribute a patch?

Would this be easier if freezing time took place in a block, and any unfrozen time followed the closure of the block? Then we wouldn’t need a separate method. I think this was the recommended practice with Timecop.

Would this be easier if freezing time took place in a block, and any

unfrozen time followed the closure of the block? Then we wouldn't need a
separate method. I think this was the recommended practice with Timecop.

Right. Generally you'd do that, but there are use cases for calls without
blocks.

Anyway, the interface without blocks exists, so the symmetry
freeze/unfreeze has to be provided from an API point of view.

Yes I’d love to contribute a patch for this.

I posted it as an issue in the rails repo and they directed me here. https://github.com/rails/rails/issues/33771#issuecomment-417848091

Could you advise on your normal process for this? I’ve contributed a rails before, but that was for an issue someone else had created.

On Mon, Sep 3, 2018 at 11:16 PM, 'Ryan' via Ruby on Rails: Core <

Yes I'd love to contribute a patch for this.

I posted it as an issue in the rails repo and they directed me here.
https://github.com/rails/rails/issues/33771#issuecomment-417848091

Could you advise on your normal process for this? I've contributed a rails
before, but that was for an issue someone else had created.

Sure, there is a guide that might help you:

    https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html

Please, don't hesitate to ask for help if the guide is not enough, feel
free to write to me directly.

Right, I see the process is to fork rails and and make a PR with the patch. Thanks for the tips, and for the offer of further support.

I have now submitted a PR with this change https://github.com/rails/rails/pull/33813