From b81b5e9bbf57849ff82f0856dceab2cadca57d99 Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 8 Jul 2022 11:51:41 +1000 Subject: [PATCH] fix: ensure blank? method is defined where used --- lib/pact_broker/api/middleware/basic_auth.rb | 2 ++ lib/pact_broker/index/service.rb | 2 ++ lib/pact_broker/ui/app.rb | 1 + lib/pact_broker/ui/helpers/haml_helpers.rb | 10 ++++++++++ lib/pact_broker/ui/views/dashboard/show.haml | 7 +++---- lib/pact_broker/ui/views/index/show-with-tags.haml | 9 ++++----- lib/pact_broker/ui/views/index/show.haml | 2 +- 7 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 lib/pact_broker/ui/helpers/haml_helpers.rb diff --git a/lib/pact_broker/api/middleware/basic_auth.rb b/lib/pact_broker/api/middleware/basic_auth.rb index 00d7819a2..33bca715c 100644 --- a/lib/pact_broker/api/middleware/basic_auth.rb +++ b/lib/pact_broker/api/middleware/basic_auth.rb @@ -1,11 +1,13 @@ require "rack" require "pact_broker/hash_refinements" +require "pact_broker/string_refinements" module PactBroker module Api module Middleware class BasicAuth using PactBroker::HashRefinements + using PactBroker::StringRefinements def initialize(app, write_credentials, read_credentials, policy) @app = app diff --git a/lib/pact_broker/index/service.rb b/lib/pact_broker/index/service.rb index 69b99dca2..bd002ff75 100644 --- a/lib/pact_broker/index/service.rb +++ b/lib/pact_broker/index/service.rb @@ -4,6 +4,7 @@ require "pact_broker/repositories/helpers" require "pact_broker/index/page" require "pact_broker/verifications/latest_verification_for_consumer_version_tag" +require "pact_broker/string_refinements" module PactBroker module Index @@ -11,6 +12,7 @@ class Service extend PactBroker::Repositories extend PactBroker::Services extend PactBroker::Logging + using PactBroker::StringRefinements DEFAULT_PAGE_SIZE = 30 DEFAULT_PAGE_NUMBER = 1 diff --git a/lib/pact_broker/ui/app.rb b/lib/pact_broker/ui/app.rb index 37ff5b538..6c767258d 100644 --- a/lib/pact_broker/ui/app.rb +++ b/lib/pact_broker/ui/app.rb @@ -5,6 +5,7 @@ require "pact_broker/ui/controllers/can_i_deploy" require "pact_broker/ui/controllers/error_test" require "pact_broker/ui/controllers/dashboard" +require "pact_broker/ui/helpers/haml_helpers" require "pact_broker/doc/controllers/app" module PactBroker diff --git a/lib/pact_broker/ui/helpers/haml_helpers.rb b/lib/pact_broker/ui/helpers/haml_helpers.rb new file mode 100644 index 000000000..1a6ea5b4d --- /dev/null +++ b/lib/pact_broker/ui/helpers/haml_helpers.rb @@ -0,0 +1,10 @@ +require "haml" +require "pact_broker/string_refinements" + +module Haml::Helpers + using PactBroker::StringRefinements + + def blank?(thing) + thing.blank? + end +end diff --git a/lib/pact_broker/ui/views/dashboard/show.haml b/lib/pact_broker/ui/views/dashboard/show.haml index ba3cfa109..29a0af3d8 100644 --- a/lib/pact_broker/ui/views/dashboard/show.haml +++ b/lib/pact_broker/ui/views/dashboard/show.haml @@ -23,10 +23,9 @@ = provider_name - - unless errors.blank? - - errors.each do | error | - %div.alert.alert-danger - = error + - errors.each do | error | + %div.alert.alert-danger + = error - if consumer && provider %form diff --git a/lib/pact_broker/ui/views/index/show-with-tags.haml b/lib/pact_broker/ui/views/index/show-with-tags.haml index 9906e4746..4812824e2 100644 --- a/lib/pact_broker/ui/views/index/show-with-tags.haml +++ b/lib/pact_broker/ui/views/index/show-with-tags.haml @@ -2,15 +2,14 @@ != render :haml, :'index/_css_and_js', :layout => false .container != render :haml, :'index/_navbar', :layout => false, locals: {tag_toggle: false, base_url: base_url} - - if index_items.empty? && search.blank? + - if index_items.empty? && blank?(search) != render :haml, :'index/_getting-started', :layout => false %h1.page-header Pacts - - unless errors.blank? - - errors.each do | error | - %div.alert.alert-danger - = error + - errors.each do | error | + %div.alert.alert-danger + = error %form{action: "#{base_url}"} .field diff --git a/lib/pact_broker/ui/views/index/show.haml b/lib/pact_broker/ui/views/index/show.haml index d44dfce21..e6c9e1373 100644 --- a/lib/pact_broker/ui/views/index/show.haml +++ b/lib/pact_broker/ui/views/index/show.haml @@ -2,7 +2,7 @@ != render :haml, :'index/_css_and_js', :layout => false .container != render :haml, :'index/_navbar', :layout => false, locals: {tag_toggle: true, base_url: base_url} - - if index_items.empty? && search.blank? + - if index_items.empty? && blank?(search) != render :haml, :'index/_getting-started', :layout => false %h1.page-header Pacts