Skip to content

Commit e2584f5

Browse files
committed
feat: add group url to /integrations _links
1 parent 25336bb commit e2584f5

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lib/pact_broker/api/decorators/integration_decorator.rb

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ class IntegrationDecorator < BaseDecorator
2828
href: matrix_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
2929
}
3030
end
31+
32+
link "pb:group" do | options |
33+
{
34+
href: group_url(represented.consumer.name, options.fetch(:base_url))
35+
}
36+
end
3137
end
3238
end
3339
end

lib/pact_broker/api/pact_broker_urls.rb

+4
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def matrix_url_from_params params, base_url = ''
212212
matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url)
213213
end
214214

215+
def group_url(pacticipant_name, base_url = '')
216+
"#{base_url}/groups/#{pacticipant_name}"
217+
end
218+
215219
def hal_browser_url target_url
216220
"/hal-browser/browser.html#" + target_url
217221
end

spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Decorators
88
before do
99
allow(integration_decorator).to receive(:dashboard_url_for_integration).and_return("/dashboard")
1010
allow(integration_decorator).to receive(:matrix_url).and_return("/matrix")
11+
allow(integration_decorator).to receive(:group_url).and_return("/group")
1112
end
1213

1314
let(:integration) do
@@ -34,6 +35,9 @@ module Decorators
3435
"pb:matrix" => {
3536
"title" => "Matrix of pacts/verification results for the consumer and the provider",
3637
"href" => "/matrix"
38+
},
39+
"pb:group" => {
40+
"href" => "/group"
3741
}
3842
}
3943
}
@@ -64,6 +68,14 @@ module Decorators
6468
)
6569
subject
6670
end
71+
72+
it "generates the correct group url for the matrix" do
73+
expect(integration_decorator).to receive(:group_url).with(
74+
"the consumer",
75+
"http://example.org"
76+
)
77+
subject
78+
end
6779
end
6880
end
6981
end

0 commit comments

Comments
 (0)