Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect auto-correct for Rails/FreezeTime, when block is passed #764

Closed
Darhazer opened this issue Sep 9, 2022 · 0 comments · Fixed by #766
Closed

Incorrect auto-correct for Rails/FreezeTime, when block is passed #764

Darhazer opened this issue Sep 9, 2022 · 0 comments · Fixed by #766
Labels
bug Something isn't working

Comments

@Darhazer
Copy link
Member

Darhazer commented Sep 9, 2022

When travel_to is used with a block (e.g. in an around hook), the block is being removed from the auto-corrected code, despite freeze_time also accepting a block

Original code:

around do |example|
  travel_to(Time.current, &example)
end

Expected behavior

Correct to

around do |example|
  freeze_time(&example)
end

Actual behavior

around do |example|
  freeze_time
end

RuboCop version

$ [bundle exec] rubocop -V
1.36.0 (using Parser 3.1.2.1, rubocop-ast 1.21.0, running on ruby 3.1.2) [arm64-darwin21]
  - rubocop-rails 2.16.0
@koic koic added the bug Something isn't working label Sep 9, 2022
koic added a commit to koic/rubocop-rails that referenced this issue Sep 9, 2022
Fixes rubocop#764.

This PR fixes an incorrect autocorrect for `Rails/FreezeTime` when
using `travel_to` with an argument of the current time and proc argument.
@koic koic closed this as completed in #766 Sep 11, 2022
koic added a commit that referenced this issue Sep 11, 2022
…ils_freeze_time

[Fix #764] Fix an incorrect autocorrect for `Rails/FreezeTime`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants