Skip to content

Business intelligence made simple

Switched to notify_list for q param [skip ci]

Andrew Kane0d46f5bba0ab
diff --git a/app/controllers/blazer/checks_controller.rb b/app/controllers/blazer/checks_controller.rb
index 7089e817..4bdaad7e 100644
--- a/app/controllers/blazer/checks_controller.rb
+++ b/app/controllers/blazer/checks_controller.rb
@@ -5,7 +5,7 @@ module Blazer
def index
state_order = [nil, "disabled", "error", "timed out", "failing", "passing"]
@checks = Blazer::Check.joins(:query).includes(:query).order("blazer_queries.name, blazer_checks.id").to_a.sort_by { |q| state_order.index(q.state) || 99 }
- @checks.select! { |c| "#{c.query.name} #{c.emails}".downcase.include?(params[:q]) } if params[:q]
+ @checks.select! { |c| ([c.query.name] + Blazer.notifiers.flat_map { |n| n.notify_list(c) }).join(" ").downcase.include?(params[:q]) } if params[:q]
end
def new
diff --git a/test/checks_test.rb b/test/checks_test.rb
index c7b24e88..ca56b901 100644
--- a/test/checks_test.rb
+++ b/test/checks_test.rb
@@ -14,6 +14,17 @@ class ChecksTest < ActionDispatch::IntegrationTest
assert_response :success
end
+ def test_index_q
+ query = create_query
+ create_check(query: query, check_type: "bad_data", emails: "[email protected]")
+ create_check(query: query, check_type: "bad_data", emails: "[email protected]")
+
+ get blazer.checks_path(q: "hi")
+ assert_response :success
+ assert_match "[email protected]", response.body
+ refute_match "[email protected]", response.body
+ end
+
def test_new
get blazer.new_check_path
assert_response :success