Repository navigation
Code review cleanups - #581
Merged
Merged
Conversation
* ActionPushNative: the push notification class is configured with notification_class. It read config[:class], which DeliverBy#constant also reads to pick the delivery method class, so setting it broke the delivery job. Adds the first tests for this delivery method. * Extract SlackDelivery and WebhookDelivery so the individual and bulk delivery methods share one implementation. Discord and Test are three lines each and stay duplicated. * deliver_by with a duplicate name raises ArgumentError, not NameError * recipients :typo raises NoMethodError instead of delivering to nobody * Event: drop the always-true respond_to?(:serialize) guard and the unused accepts_nested_attributes_for :notifications * Generator templates: the example deliver_by comment now names the generated DeliveryMethods::/BulkDeliveryMethods:: class so it constantizes * README documents that if:/unless: symbols are called on the Notifier with the notification as an argument
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Last batch from the library-wide review. One real bug, the rest cleanups.
notification_classreadconfig[:class], butDeliverBy#constantalso readsconfig[:class]to choose the delivery method class, so setting it would have constantized your push notification class as the job. Renamed toconfig.notification_class(the old name was undocumented). Adds the first tests for this delivery method with a fake builder that mirrors theActionPushNative::NotificationAPI.Noticed::SlackDeliveryandNoticed::WebhookDeliveryconcerns shared by the individual and bulk classes. Discord/Test bodies are three lines and stay duplicated.Noticed::DeliveryMethods::Slack::DEFAULT_URLstill resolves via the included module.deliver_byduplicate name →ArgumentError(wasNameError).recipients :typo→NoMethodError(was silently delivering to nobody).Event: drop always-truerespond_to?(:serialize)guard and unusedaccepts_nested_attributes_for.deliver_by ... class:comment now names the namespaced class, so copy-pasting it works.if:/unless:symbol convention (method on the Notifier receiving the notification) — it was undocumented and differs fromwait/queuesymbols, which resolve on the Notification.Test plan
standardrbcleanrails teston main Gemfile, Rails main, 7.1 — 152 runs, 0 failuresRails.application.eager_load!+Zeitwerk::Loader.eager_load_allin the dummy app loads the new concernsrails g noticed:delivery_method Foo --pretendrenders