diff --git a/lib/generators/noticed/delivery_method_generator.rb b/lib/generators/noticed/delivery_method_generator.rb index 2465a86a..57ade434 100644 --- a/lib/generators/noticed/delivery_method_generator.rb +++ b/lib/generators/noticed/delivery_method_generator.rb @@ -12,6 +12,7 @@ class DeliveryMethodGenerator < Rails::Generators::NamedBase desc "Generates a class for a custom delivery method with the given NAME." def generate_notification + template "application_delivery_method.rb", "app/notifiers/delivery_methods/application_delivery_method.rb" template "delivery_method.rb", "app/notifiers/delivery_methods/#{singular_name}.rb" end end diff --git a/lib/generators/noticed/notifier_generator.rb b/lib/generators/noticed/notifier_generator.rb index b805de5b..6e62a7a3 100644 --- a/lib/generators/noticed/notifier_generator.rb +++ b/lib/generators/noticed/notifier_generator.rb @@ -14,6 +14,7 @@ class NotifierGenerator < Rails::Generators::NamedBase desc "Generates a notification with the given NAME." def generate_notification + template "application_notifier.rb", "app/notifiers/application_notifier.rb" template "notifier.rb", "app/notifiers/#{file_path}_notifier.rb" end diff --git a/lib/generators/noticed/templates/application_delivery_method.rb.tt b/lib/generators/noticed/templates/application_delivery_method.rb.tt new file mode 100644 index 00000000..1983c371 --- /dev/null +++ b/lib/generators/noticed/templates/application_delivery_method.rb.tt @@ -0,0 +1,2 @@ +class ApplicationDeliveryMethod < Noticed::DeliveryMethod +end diff --git a/lib/generators/noticed/templates/application_notifier.rb.tt b/lib/generators/noticed/templates/application_notifier.rb.tt new file mode 100644 index 00000000..90c8fd4e --- /dev/null +++ b/lib/generators/noticed/templates/application_notifier.rb.tt @@ -0,0 +1,2 @@ +class ApplicationNotifier < Noticed::Event +end diff --git a/lib/generators/noticed/templates/delivery_method.rb.tt b/lib/generators/noticed/templates/delivery_method.rb.tt index 66694fd0..8665f764 100644 --- a/lib/generators/noticed/templates/delivery_method.rb.tt +++ b/lib/generators/noticed/templates/delivery_method.rb.tt @@ -1,4 +1,4 @@ -class DeliveryMethods::<%= class_name %> < Noticed::DeliveryMethod +class DeliveryMethods::<%= class_name %> < ApplicationDeliveryMethod # Specify the config options your delivery method requires in its config block required_options # :foo, :bar diff --git a/lib/generators/noticed/templates/notifier.rb.tt b/lib/generators/noticed/templates/notifier.rb.tt index 8392a356..cf87ec04 100644 --- a/lib/generators/noticed/templates/notifier.rb.tt +++ b/lib/generators/noticed/templates/notifier.rb.tt @@ -2,7 +2,7 @@ # # <%= class_name %>.with(record: @post, message: "New post").deliver(User.all) -class <%= class_name %>Notifier < Noticed::Event +class <%= class_name %>Notifier < ApplicationNotifier # Add your delivery methods # # deliver_by :email do |config| diff --git a/test/dummy/app/notifiers/application_notifier.rb b/test/dummy/app/notifiers/application_notifier.rb new file mode 100644 index 00000000..90c8fd4e --- /dev/null +++ b/test/dummy/app/notifiers/application_notifier.rb @@ -0,0 +1,2 @@ +class ApplicationNotifier < Noticed::Event +end diff --git a/test/dummy/app/notifiers/bulk_notifier.rb b/test/dummy/app/notifiers/bulk_notifier.rb index 42cc3c05..edf05a0f 100644 --- a/test/dummy/app/notifiers/bulk_notifier.rb +++ b/test/dummy/app/notifiers/bulk_notifier.rb @@ -1,3 +1,3 @@ -class BulkNotifier < Noticed::Event +class BulkNotifier < ApplicationNotifier bulk_deliver_by :webhook, url: "https://example.org/bulk" end diff --git a/test/dummy/app/notifiers/comment_notifier.rb b/test/dummy/app/notifiers/comment_notifier.rb index c27d94c9..63e9d992 100644 --- a/test/dummy/app/notifiers/comment_notifier.rb +++ b/test/dummy/app/notifiers/comment_notifier.rb @@ -1,4 +1,4 @@ -class CommentNotifier < Noticed::Event +class CommentNotifier < ApplicationNotifier deliver_by :test # delivery_by :email, mailer: "UserMailer", method: "new_comment" diff --git a/test/dummy/app/notifiers/delivery_methods/application_delivery_method.rb b/test/dummy/app/notifiers/delivery_methods/application_delivery_method.rb new file mode 100644 index 00000000..1983c371 --- /dev/null +++ b/test/dummy/app/notifiers/delivery_methods/application_delivery_method.rb @@ -0,0 +1,2 @@ +class ApplicationDeliveryMethod < Noticed::DeliveryMethod +end diff --git a/test/dummy/app/notifiers/priority_notifier.rb b/test/dummy/app/notifiers/priority_notifier.rb index 1bd89234..5abbb6cd 100644 --- a/test/dummy/app/notifiers/priority_notifier.rb +++ b/test/dummy/app/notifiers/priority_notifier.rb @@ -1,3 +1,3 @@ -class PriorityNotifier < Noticed::Event +class PriorityNotifier < ApplicationNotifier deliver_by :test, priority: 2 end diff --git a/test/dummy/app/notifiers/queue_notifier.rb b/test/dummy/app/notifiers/queue_notifier.rb index 6bd99b03..0a2c5423 100644 --- a/test/dummy/app/notifiers/queue_notifier.rb +++ b/test/dummy/app/notifiers/queue_notifier.rb @@ -1,3 +1,3 @@ -class QueueNotifier < Noticed::Event +class QueueNotifier < ApplicationNotifier deliver_by :test, queue: :example_queue end diff --git a/test/dummy/app/notifiers/receipt_notifier.rb b/test/dummy/app/notifiers/receipt_notifier.rb index 8dfd7eb7..41b226c5 100644 --- a/test/dummy/app/notifiers/receipt_notifier.rb +++ b/test/dummy/app/notifiers/receipt_notifier.rb @@ -1,4 +1,4 @@ -class ReceiptNotifier < Noticed::Event +class ReceiptNotifier < ApplicationNotifier deliver_by :test deliver_by :email do |config| diff --git a/test/dummy/app/notifiers/record_notifier.rb b/test/dummy/app/notifiers/record_notifier.rb index 1bb50fe7..8c00f758 100644 --- a/test/dummy/app/notifiers/record_notifier.rb +++ b/test/dummy/app/notifiers/record_notifier.rb @@ -1,3 +1,3 @@ -class RecordNotifier < Noticed::Event +class RecordNotifier < ApplicationNotifier validates :record, presence: true end diff --git a/test/dummy/app/notifiers/simple_notifier.rb b/test/dummy/app/notifiers/simple_notifier.rb index f96c51d5..377baeff 100644 --- a/test/dummy/app/notifiers/simple_notifier.rb +++ b/test/dummy/app/notifiers/simple_notifier.rb @@ -1,4 +1,4 @@ -class SimpleNotifier < Noticed::Event +class SimpleNotifier < ApplicationNotifier deliver_by :test required_params :message diff --git a/test/dummy/app/notifiers/test_notifier.rb b/test/dummy/app/notifiers/test_notifier.rb index 4103c5a0..fc43db83 100644 --- a/test/dummy/app/notifiers/test_notifier.rb +++ b/test/dummy/app/notifiers/test_notifier.rb @@ -1,3 +1,3 @@ -class TestNotifier < Noticed::Event +class TestNotifier < ApplicationNotifier deliver_by :test end diff --git a/test/dummy/app/notifiers/wait_notifier.rb b/test/dummy/app/notifiers/wait_notifier.rb index 38f82150..ef8a76a2 100644 --- a/test/dummy/app/notifiers/wait_notifier.rb +++ b/test/dummy/app/notifiers/wait_notifier.rb @@ -1,3 +1,3 @@ -class WaitNotifier < Noticed::Event +class WaitNotifier < ApplicationNotifier deliver_by :test, wait: 5.minutes end diff --git a/test/dummy/app/notifiers/wait_until_notifier.rb b/test/dummy/app/notifiers/wait_until_notifier.rb index eab4bd42..09ec6772 100644 --- a/test/dummy/app/notifiers/wait_until_notifier.rb +++ b/test/dummy/app/notifiers/wait_until_notifier.rb @@ -1,3 +1,3 @@ -class WaitUntilNotifier < Noticed::Event +class WaitUntilNotifier < ApplicationNotifier deliver_by :test, wait_until: -> { 1.hour.from_now } end