From 8373f88fba31340ac05fb1be0dc2a2eb2520199a Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Wed, 22 Jun 2022 14:14:55 +1000 Subject: [PATCH] fix: update string refinements with blank? and present? --- lib/pact_broker/string_refinements.rb | 8 ++++++++ lib/pact_broker/ui/controllers/index.rb | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/pact_broker/string_refinements.rb b/lib/pact_broker/string_refinements.rb index e8960bca7..2c389e248 100644 --- a/lib/pact_broker/string_refinements.rb +++ b/lib/pact_broker/string_refinements.rb @@ -4,6 +4,10 @@ module StringRefinements def blank? true end + + def present? + false + end end refine Numeric do @@ -13,6 +17,10 @@ def blank? end refine String do + def present? + !blank? + end + def not_blank? !blank? end diff --git a/lib/pact_broker/ui/controllers/index.rb b/lib/pact_broker/ui/controllers/index.rb index 4f92b3456..e14f7f0de 100644 --- a/lib/pact_broker/ui/controllers/index.rb +++ b/lib/pact_broker/ui/controllers/index.rb @@ -1,5 +1,6 @@ require "pact_broker/ui/controllers/base_controller" require "pact_broker/ui/view_models/index_items" +require "pact_broker/string_refinements" require "haml" module PactBroker @@ -7,6 +8,7 @@ module UI module Controllers class Index < Base include PactBroker::Services + using PactBroker::StringRefinements get "/" do set_headers @@ -27,7 +29,7 @@ class Index < Base index_items = index_service.find_index_items(options) - if index_items.blank? && !search.blank? + if index_items.empty? && !search.blank? error_messages << "No pacticipants found matching: \"#{search}\"" end