[openstreetmap/openstreetmap-website] Fixed notifications reload error (PR #7359)
Mohd Farhan Akhtar
notifications at github.com
Thu Sep 3 14:33:21 UTC 2026
Fixes #7354
### What was happening
I found that when a user unfollows someone, the `Follow` record gets deleted but the follower notification can stick around. Since the notification is still there but its associated record is gone, opening the notifications page ends up throwing a `NoMethodError`.
While looking into this, I also noticed the same kind of issue with `GpxSuccessNotifier` when the associated trace is deleted.
### What I changed
I updated the cleanup so that notifications are removed along with their associated `Follow` or `Trace` records. I also changed the unfollow flow to use `destroy_all` so the cleanup callbacks actually run.
For older notifications that were already left orphaned, I added a guard so they are simply skipped instead of crashing the page. Record-less notifications that are valid by design, like GPX import failures, are still shown normally.
### Tests
I added regression tests for the different cases, including:
- follower notifications after unfollowing
- existing orphaned follower notifications
- GPX success notifications after deleting a trace
- existing orphaned GPX success notifications
- GPX failure notifications without an associated record
All the relevant tests are passing locally.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/7359
-- Commit Summary --
* Fix notifications reload error
-- File Changes --
M app/controllers/follows_controller.rb (2)
M app/models/follow.rb (2)
M app/models/trace.rb (1)
M app/views/notifications/_page.html.erb (1)
M test/system/web_notifications_test.rb (87)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/7359.patch
https://github.com/openstreetmap/openstreetmap-website/pull/7359.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7359
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7359 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260903/2eee25a7/attachment-0001.htm>
More information about the rails-dev
mailing list