From f9e183e99c3d101809b2ef72ec54f76c154aee5f Mon Sep 17 00:00:00 2001 From: Beth Skurrie Date: Fri, 25 Sep 2020 12:39:32 +1000 Subject: [PATCH] feat: change text on can-i-deploy badge --- lib/pact_broker/api/resources/can_i_deploy_badge.rb | 2 +- lib/pact_broker/badges/service.rb | 6 +++--- .../pact_broker/api/resources/can_i_deploy_badge_spec.rb | 4 ++-- spec/lib/pact_broker/badges/service_spec.rb | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/pact_broker/api/resources/can_i_deploy_badge.rb b/lib/pact_broker/api/resources/can_i_deploy_badge.rb index 08af4f66f..c2ef799a4 100644 --- a/lib/pact_broker/api/resources/can_i_deploy_badge.rb +++ b/lib/pact_broker/api/resources/can_i_deploy_badge.rb @@ -46,7 +46,7 @@ def moved_temporarily? begin if pacticipant if version - badge_service.can_i_deploy_badge_url(pacticipant_name, identifier_from_path[:tag], identifier_from_path[:to], label, results.deployable?) + badge_service.can_i_deploy_badge_url(identifier_from_path[:tag], identifier_from_path[:to], label, results.deployable?) else badge_service.error_badge_url("version", "not found") end diff --git a/lib/pact_broker/badges/service.rb b/lib/pact_broker/badges/service.rb index 07b3a3e48..0d2ddfa28 100644 --- a/lib/pact_broker/badges/service.rb +++ b/lib/pact_broker/badges/service.rb @@ -33,9 +33,9 @@ def pact_verification_badge_url(pact, label, initials, pseudo_branch_verificatio build_shield_io_uri(title, status, color) end - def can_i_deploy_badge_url(pacticipant_name, tag, environment_tag, label, deployable) - title = label || "Can I deploy #{tag} #{pacticipant_name} to #{environment_tag}?" - status = deployable ? "yes" : "no" + def can_i_deploy_badge_url(tag, environment_tag, label, deployable) + title = label || "can-i-deploy" + status = "#{tag} to #{environment_tag}" color = deployable ? "brightgreen" : "red" build_shield_io_uri(title, status, color) end diff --git a/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb b/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb index 85186ca6b..4920fd3ed 100644 --- a/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb +++ b/spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb @@ -32,7 +32,7 @@ module Resources context "when the pacticipant exists" do it "returns a redirect to the badge" do - expect(badge_service).to receive(:can_i_deploy_badge_url).with("Foo", "main", "prod", nil, true) + expect(badge_service).to receive(:can_i_deploy_badge_url).with("main", "prod", nil, true) expect(subject.status).to eq 307 end end @@ -59,7 +59,7 @@ module Resources subject { get(path, label: "some custom label") } it "returns a redirect to a badge with a custom label" do - expect(badge_service).to receive(:can_i_deploy_badge_url).with("Foo", "main", "prod", "some custom label", true) + expect(badge_service).to receive(:can_i_deploy_badge_url).with("main", "prod", "some custom label", true) subject end end diff --git a/spec/lib/pact_broker/badges/service_spec.rb b/spec/lib/pact_broker/badges/service_spec.rb index 8b1aa9e61..2bbcdc49b 100644 --- a/spec/lib/pact_broker/badges/service_spec.rb +++ b/spec/lib/pact_broker/badges/service_spec.rb @@ -29,6 +29,12 @@ module Badges allow(Service).to receive(:logger).and_return(logger) end + describe "can_i_deploy_badge_url" do + subject { Service.can_i_deploy_badge_url("main", "prod", nil, true) } + + it { is_expected.to eq URI("https://img.shields.io/badge/can--i--deploy-main%20to%20prod-brightgreen.svg") } + end + describe "pact_verification_badge_url" do context "with the pact is nil" do let(:pact) { nil }