Commit 6c14cb6a9a00f7575c48bb746aebfe169080e320

Authored by Andrew Kane
1 parent 17ad1119

Added test for notifications [skip ci]

Showing 1 changed file with 25 additions and 0 deletions   Show diff stats
test/notifications_test.rb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +require_relative "test_helper"
  2 +
  3 +class NotificationsTest < Minitest::Test
  4 + def test_search
  5 + notifications = capture_notifications do
  6 + Product.search("product").to_a
  7 + end
  8 +
  9 + assert_equal 1, notifications.size
  10 + assert_equal "search.searchkick", notifications.last[:name]
  11 + end
  12 +
  13 + private
  14 +
  15 + def capture_notifications
  16 + notifications = []
  17 + callback = lambda do |name, started, finished, unique_id, payload|
  18 + notifications << {name: name, payload: payload}
  19 + end
  20 + ActiveSupport::Notifications.subscribed(callback, /searchkick/) do
  21 + yield
  22 + end
  23 + notifications
  24 + end
  25 +end
... ...