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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Ryan-3

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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Ryan-3
In reply to this post by Ryan-3
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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

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

Would you like to contribute a patch?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Geoff Harcourt
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. 

On Sun, Sep 2, 2018, 6:18 PM Xavier Noria <[hidden email]> wrote:
I think it makes sense. For the code to read well, both verbs have to match.

Would you like to contribute a patch?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Xavier Noria
On Mon, Sep 3, 2018 at 1:28 AM, Geoff Harcourt <[hidden email]> wrote:

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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Ryan-3
In reply to this post by Xavier Noria
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 Sunday, 2 September 2018 23:18:39 UTC+1, Xavier Noria wrote:
I think it makes sense. For the code to read well, both verbs have to match.

Would you like to contribute a patch?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Xavier Noria
On Mon, Sep 3, 2018 at 11:16 PM, 'Ryan' via Ruby on Rails: Core <[hidden email]> wrote:

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:


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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Ryan-3
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. 

On Tuesday, 4 September 2018 15:12:54 UTC+1, Xavier Noria wrote:
On Mon, Sep 3, 2018 at 11:16 PM, 'Ryan' via Ruby on Rails: Core <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="bmYrGfc0BAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">rubyonra...@googlegroups.com> wrote:

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. <a href="https://github.com/rails/rails/issues/33771#issuecomment-417848091" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fissues%2F33771%23issuecomment-417848091\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoYNMvEjjV39OvYD2d0RLfQy1vtQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fissues%2F33771%23issuecomment-417848091\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoYNMvEjjV39OvYD2d0RLfQy1vtQ&#39;;return true;">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:

    <a href="https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fedgeguides.rubyonrails.org%2Fcontributing_to_ruby_on_rails.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXcGgbndXgqs6SYQkNmjYQrLLeOQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fedgeguides.rubyonrails.org%2Fcontributing_to_ruby_on_rails.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXcGgbndXgqs6SYQkNmjYQrLLeOQ&#39;;return true;">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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

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

On Tuesday, 4 September 2018 18:47:37 UTC+1, Ryan wrote:
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. 

On Tuesday, 4 September 2018 15:12:54 UTC+1, Xavier Noria wrote:
On Mon, Sep 3, 2018 at 11:16 PM, 'Ryan' via Ruby on Rails: Core <[hidden email]> wrote:

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. <a href="https://github.com/rails/rails/issues/33771#issuecomment-417848091" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fissues%2F33771%23issuecomment-417848091\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoYNMvEjjV39OvYD2d0RLfQy1vtQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Frails%2Frails%2Fissues%2F33771%23issuecomment-417848091\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHoYNMvEjjV39OvYD2d0RLfQy1vtQ&#39;;return true;">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:

    <a href="https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fedgeguides.rubyonrails.org%2Fcontributing_to_ruby_on_rails.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXcGgbndXgqs6SYQkNmjYQrLLeOQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fedgeguides.rubyonrails.org%2Fcontributing_to_ruby_on_rails.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHXcGgbndXgqs6SYQkNmjYQrLLeOQ&#39;;return true;">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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.