Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def update
set_wip
update_published_at
if @product.update(product_params)
Newspaper.publish(:product_update, { product: @product, current_user: })
ActiveSupport::Notifications.instrument('product.update', { product: @product, current_user: })
ActiveSupport::Notifications.instrument('product.save', product: @product)
notice_another_mentor_assigned_as_checker
redirect_to Redirection.determin_url(self, @product), notice: notice_message(@product, :update)
Expand Down
2 changes: 1 addition & 1 deletion app/models/comment/after_create_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def after_commit(comment)
create_watch(comment)
notify_to_watching_user(comment)
elsif comment.receiver.present? && comment.receiver != comment.sender
Newspaper.publish(:came_comment, { comment: })
ActiveSupport::Notifications.instrument('came.comment', comment:)
end

if comment.commentable.instance_of?(Talk)
Expand Down
2 changes: 1 addition & 1 deletion app/models/comment_notifier.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class CommentNotifier
def call(payload)
def call(_name, _started, _finished, _id, payload)
comment = payload[:comment]
return if comment.nil?

Expand Down
2 changes: 1 addition & 1 deletion app/models/product_update_notifier_for_checker.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ProductUpdateNotifierForChecker
def call(payload)
def call(_name, _started, _finished, _id, payload)
product = payload[:product]
current_user = payload[:current_user]
return if product.wip? || product.checker_id.nil? || !current_user.nil? && current_user.admin_or_mentor?
Expand Down
2 changes: 1 addition & 1 deletion app/models/product_update_notifier_for_watcher.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ProductUpdateNotifierForWatcher
def call(payload)
def call(_name, _started, _finished, _id, payload)
product = payload[:product]
current_user = payload[:current_user]
return if product.wip? || product.watches.nil? || !current_user.nil? && current_user.admin_or_mentor?
Expand Down
5 changes: 4 additions & 1 deletion config/initializers/active_support_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
ActiveSupport::Notifications.subscribe('came.inquiry', InquiryNotifier.new)
ActiveSupport::Notifications.subscribe('regular_event.update', RegularEventUpdateNotifier.new)
ActiveSupport::Notifications.subscribe('student_or_trainee.create', TimesChannelCreator.new)

ActiveSupport::Notifications.subscribe('product.update', ProductUpdateNotifierForWatcher.new)
ActiveSupport::Notifications.subscribe('product.update', ProductUpdateNotifierForChecker.new)
ActiveSupport::Notifications.subscribe('came.comment', CommentNotifier.new)

learning_status_updater = LearningStatusUpdater.new
ActiveSupport::Notifications.subscribe('product.save', learning_status_updater)
ActiveSupport::Notifications.subscribe('check.create', learning_status_updater)
Expand Down
3 changes: 0 additions & 3 deletions config/initializers/newspaper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,5 @@
Newspaper.subscribe(:question_create, question_notifier)
Newspaper.subscribe(:question_update, question_notifier)

Newspaper.subscribe(:product_update, ProductUpdateNotifierForWatcher.new)
Newspaper.subscribe(:product_update, ProductUpdateNotifierForChecker.new)
Newspaper.subscribe(:came_comment, CommentNotifier.new)
Newspaper.subscribe(:came_comment_in_talk, CommentNotifierForAdmin.new)
end
8 changes: 4 additions & 4 deletions test/models/product_update_notifier_for_checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ProductUpdateNotifierForCheckerTest < ActiveSupport::TestCase
product.save!

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 1 do
ProductUpdateNotifierForChecker.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForChecker.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -30,7 +30,7 @@ class ProductUpdateNotifierForCheckerTest < ActiveSupport::TestCase
product.save!

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForChecker.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForChecker.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -44,7 +44,7 @@ class ProductUpdateNotifierForCheckerTest < ActiveSupport::TestCase
product.save!

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForChecker.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForChecker.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -58,7 +58,7 @@ class ProductUpdateNotifierForCheckerTest < ActiveSupport::TestCase
product.save!

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForChecker.new.call({ product:, current_user: users(:mentormentaro) })
ProductUpdateNotifierForChecker.new.call(nil, nil, nil, nil, { product:, current_user: users(:mentormentaro) })
end
end
end
8 changes: 4 additions & 4 deletions test/models/product_update_notifier_for_watcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ProductUpdateNotifierForWatcherTest < ActiveSupport::TestCase
product = products(:product6)

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 1 do
ProductUpdateNotifierForWatcher.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForWatcher.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -19,7 +19,7 @@ class ProductUpdateNotifierForWatcherTest < ActiveSupport::TestCase
product = products(:product5)

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForWatcher.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForWatcher.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -28,7 +28,7 @@ class ProductUpdateNotifierForWatcherTest < ActiveSupport::TestCase
product = products(:product73)

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForWatcher.new.call({ product:, current_user: product.user })
ProductUpdateNotifierForWatcher.new.call(nil, nil, nil, nil, { product:, current_user: product.user })
end
end

Expand All @@ -37,7 +37,7 @@ class ProductUpdateNotifierForWatcherTest < ActiveSupport::TestCase
product = products(:product6)

assert_difference -> { AbstractNotifier::Testing::Driver.enqueued_deliveries.count }, 0 do
ProductUpdateNotifierForWatcher.new.call({ product:, current_user: users(:mentormentaro) })
ProductUpdateNotifierForWatcher.new.call(nil, nil, nil, nil, { product:, current_user: users(:mentormentaro) })
end
end
end