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

Allow access to CurrentAttributes in test teardown #40588

Conversation

etiennebarrie
Copy link
Contributor

Summary

When using CurrentAttributes in tests, they get reset before teardown.
It's annoying when you use multiple setup/teardown in different places and expect to be able to use CurrentAttributes.

For example:

AccountTestHelper
  setup: Current.account = Account.first
SomeTest
  setup: Redis.current.set("account:#{Current.account.id}", Current.account.data)
  teardown: Redis.current.del("account:#{Current.account.id}") # Current.account has already been reset

Since the test helper helps to prevent leaks, it can call reset_all at the very end of teardown, in after_teardown, after the call to super.

@rafaelfranca
cc @byroot

@rafaelfranca rafaelfranca merged commit e71b4a5 into rails:master Nov 9, 2020
rafaelfranca added a commit that referenced this pull request Nov 9, 2020
…ributes-testhelper-teardown

Allow access to CurrentAttributes in test teardown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants