Skip to content

Commit

Permalink
feat: change text on can-i-deploy badge
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 25, 2020
1 parent adb831f commit f9e183e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/pact_broker/api/resources/can_i_deploy_badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/pact_broker/badges/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/pact_broker/api/resources/can_i_deploy_badge_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/pact_broker/badges/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit f9e183e

Please sign in to comment.