docbrown/app/workers/notification_subscriptions/update_worker.rb
Lewis Sparlin e621659279
Add Article post_commit when user_id changes with specs (#15132)
* Add Article post_commit when user_id changes with specs

* Add example in requests/admin/articles_spec for updating user
2021-10-25 10:53:21 +07:00

19 lines
556 B
Ruby

module NotificationSubscriptions
class UpdateWorker
include Sidekiq::Worker
sidekiq_options queue: :medium_priority, retry: 10, lock: :until_executing
def perform(notifiable_id, notifiable_class)
raise InvalidNotifiableForUpdate, notifiable_class unless %w[Article].include?(notifiable_class)
notifiable = notifiable_class.constantize.find_by(id: notifiable_id)
return unless notifiable
NotificationSubscriptions::Update.call(notifiable)
end
end
class InvalidNotifiableForUpdate < StandardError; end
end