Skip to content

Fix bugs found in code review - #579

Merged
excid3 merged 2 commits into
mainfrom
fix-review-batch-1
Sep 30, 2026
Merged

excid3 merged 2 commits into
mainfrom
fix-review-batch-1

Conversation

@excid3

@excid3 excid3 commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Summary

Batch of fixes from a full read-through of the library. Every item under "confirmed" was reproduced with a failing test before fixing; each now has a regression test (15 new tests, 144 total).

Confirmed bugs

  • Notifier Notification classes inherited from a top-level ::Notification model in the host app (const_defined? searched Object), so any app with app/models/notification.rb got the wrong superclass/table.
  • Ephemeral bulk delivery ignored the notifier's bulk_deliver_by config entirely (@config = overrides).
  • Ephemeral notifiers skipped before_enqueue and validate!, raised on deliver(recipients, wait: ...), and deliver_later was aliased to the ActiveRecord deliver body.
  • Notifier.with(params) mutated the caller's hash.
  • Noticed::DeliveryMethods::Discord inherited BulkDeliveryMethod so deliver_by :discord crashed.
  • rails g noticed:install / noticed:model could not be found.

From reading

  • BulkDeliveryMethod#fetch_constant returned nil for proc/constant values.
  • DeliverBy#validate! rejected required options set to false.
  • Ephemeral notification_methods were not inherited by subclasses.
  • has_noticed_notifications added a public current_adapter method to every model and used ActiveRecord::Base's adapter rather than the event model's connection.

Behaviour change (noted in CHANGELOG as breaking): ephemeral wait/wait_until/queue/priority lambdas now evaluate in the Notification context (Event for bulk) instead of the bare recipient, matching persisted notifiers.

Test plan

  • standardrb clean
  • rails test on main Gemfile, Rails main, 7.1, 8.1 — 144 runs, 0 failures
  • rails g noticed:install resolves and copies migrations

* Notifier Notification classes inherited from a top-level ::Notification
  model in the host app because const_defined?/const_get searched ancestors
* Ephemeral bulk delivery ignored the notifier's bulk_deliver_by config
* Ephemeral notifiers skipped before_enqueue and validate!, rejected job
  options (deliver(recipients, wait: ...)), and deliver_later was bound to
  the ActiveRecord deliver body
* Ephemeral notification_methods were not inherited by subclasses
* Ephemeral wait/queue/priority lambdas now run in the Notification context
  (Event for bulk) instead of the recipient, matching persisted notifiers
* Notifier.with(params) mutated the caller's hash
* Noticed::DeliveryMethods::Discord inherited BulkDeliveryMethod and crashed
* BulkDeliveryMethod#fetch_constant passed the value instead of the name to
  evaluate_option, returning nil for procs and constants
* DeliverBy#validate! rejected required options set to false
* rails g noticed:install could not be resolved (class was ModelGenerator)
* has_noticed_notifications added a public current_adapter method to every
  model and read ActiveRecord::Base's adapter instead of the event model's
* deliver_later delegates to deliver instead of alias_method, so subclasses
  that override deliver (Ephemeral) get it for free
* ephemeral_perform_later requires context: explicitly; computed_options
  dups once instead of every caller
* Drop tests that only asserted a deleted method or duplicated end-to-end
  coverage
* Trim CHANGELOG
@excid3
excid3 merged commit e1ed6d8 into main Sep 30, 2026
36 checks passed
@excid3
excid3 deleted the fix-review-batch-1 branch September 30, 2026 21:00
@excid3 excid3 mentioned this pull request Sep 30, 2026
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant