diff --git a/lib/pact_broker/api/pact_broker_urls.rb b/lib/pact_broker/api/pact_broker_urls.rb index 74278baeb..0cabda3cd 100644 --- a/lib/pact_broker/api/pact_broker_urls.rb +++ b/lib/pact_broker/api/pact_broker_urls.rb @@ -201,7 +201,7 @@ def verification_publication_url pact, base_url, metadata = "" end def tag_url base_url, tag - "#{tags_url(base_url, tag.version)}/#{tag.name}" + "#{tags_url(base_url, tag.version)}/#{url_encode(tag.name)}" end def templated_tag_url_for_pacticipant pacticipant_name, base_url = "" diff --git a/spec/lib/pact_broker/api/pact_broker_urls_spec.rb b/spec/lib/pact_broker/api/pact_broker_urls_spec.rb index 073228703..541b18fc5 100644 --- a/spec/lib/pact_broker/api/pact_broker_urls_spec.rb +++ b/spec/lib/pact_broker/api/pact_broker_urls_spec.rb @@ -36,6 +36,7 @@ module Api pacticipant: consumer, number: "2/4") end + let(:tag) { double('tag', name: "feat/foo", version: version) } matcher :match_route_in_api do |api| match do |url| @@ -168,6 +169,13 @@ module Api it { is_expected.to eq "http://example.org/matrix/provider/Bar%2FBar/latest/meep/consumer/Foo%2FFoo/latest/bar/badge.svg" } end + + describe "tag_url" do + subject { PactBrokerUrls.tag_url(base_url, tag) } + + it { is_expected.to match_route_in_api(PactBroker::API) } + it { is_expected.to eq "http://example.org/pacticipants/Foo%2FFoo/versions/2%2F4/tags/feat%2Ffoo" } + end end end end