From 6c14cb6a9a00f7575c48bb746aebfe169080e320 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Fri, 18 Feb 2022 18:33:48 -0800 Subject: [PATCH] Added test for notifications [skip ci] --- test/notifications_test.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+), 0 deletions(-) create mode 100644 test/notifications_test.rb diff --git a/test/notifications_test.rb b/test/notifications_test.rb new file mode 100644 index 0000000..8052c40 --- /dev/null +++ b/test/notifications_test.rb @@ -0,0 +1,25 @@ +require_relative "test_helper" + +class NotificationsTest < Minitest::Test + def test_search + notifications = capture_notifications do + Product.search("product").to_a + end + + assert_equal 1, notifications.size + assert_equal "search.searchkick", notifications.last[:name] + end + + private + + def capture_notifications + notifications = [] + callback = lambda do |name, started, finished, unique_id, payload| + notifications << {name: name, payload: payload} + end + ActiveSupport::Notifications.subscribed(callback, /searchkick/) do + yield + end + notifications + end +end -- libgit2 0.21.0