-
Notifications
You must be signed in to change notification settings - Fork 2
Refactor deletion of dangling labels #1606
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1606 +/- ##
=======================================
Coverage 94.77% 94.78%
=======================================
Files 130 130
Lines 3330 3334 +4
=======================================
+ Hits 3156 3160 +4
Misses 174 174 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I am just wondering if we need Label#to_s
? I could not find any usage and it is also not covered by the tests.
I knew you would point that out. It is not used, that's right. I found it helpful to have while debugging, since it replaced the magic object ID with the actual label name when printing. If you like, I can add a simple test for that. |
The test is a bit silly 😉 but at least Codecov is happy now 👍 |
We recently discovered an edge case where a moved file was not updated correctly. At first, it got removed and recreated, and later on only removed. While these changes look pretty difficult, they are the best and only working approach I could find to fix the problem ;). For now, I'd suggest to go with this solution. See #1606 for more details.
We recently discovered an edge case where a moved file was not updated correctly. At first, it got removed and recreated, and later on only removed. While these changes look pretty difficult, they are the best and only working approach I could find to fix the problem ;). For now, I'd suggest to go with this solution. See #1606 for more details.
We recently discovered an edge case where a moved file was not updated correctly. At first, it got removed and recreated, and later on only removed. While these changes look pretty difficult, they are the best and only working approach I could find to fix the problem ;). For now, I'd suggest to go with this solution. See #1606 for more details.
The previous mechanism required newly-assigned TaskLabels to be saved before aiming to destroy dangling labels. However, there is one edge-case previously used in the tests which caused erroneous behavior: Imagine, there is a dangling label (with no matching TaskLabel). Then, a task is assigned that dangling label through the `label_names=` mechanism. This will cause the `Label.find_or_initialize_by(name:)` method to return the dangling label and assign that to the task. However, when this assignment is not saved it (and no `TaskLabel` record is created), the following call to destroy dangling labels also removed the one just assigned to a task. This caused errors in tests, when switching from `labels` to `label_names` in the TaskController specs to remove the use of unpermitted parameters and transactional fixtures. The new mechanism will still remove dangling labels, but only those associated with a TaskLabel just removed. Through the transactional setting of destroy hooks, this still ensures there aren't any leftovers.
Since a label is considered "unique" based on its name, overwriting `to_s` makes sense to aid debugging.
The previous mechanism required newly-assigned TaskLabels to be saved before aiming to destroy dangling labels. However, there is one edge-case previously used in the tests which caused erroneous behavior:
Imagine, there is a dangling label (with no matching TaskLabel). Then, a task is assigned that dangling label through the
label_names=
mechanism. This will cause theLabel.find_or_initialize_by(name:)
method to return the dangling label and assign that to the task. However, when this assignment is not saved it (and noTaskLabel
record is created), the following call to destroy dangling labels also removed the one just assigned to a task.This caused errors in tests, when switching from
labels
tolabel_names
in the TaskController specs to remove the use of unpermitted parameters and transactional fixtures.The new mechanism will still remove dangling labels, but only those associated with a TaskLabel just removed. Through the transactional setting of destroy hooks, this still ensures there aren't any leftovers.