Skip to content

Commit

Permalink
feat: add group url to /integrations _links
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed May 14, 2019
1 parent 25336bb commit e2584f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pact_broker/api/decorators/integration_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class IntegrationDecorator < BaseDecorator
href: matrix_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
}
end

link "pb:group" do | options |
{
href: group_url(represented.consumer.name, options.fetch(:base_url))
}
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lib/pact_broker/api/pact_broker_urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ def matrix_url_from_params params, base_url = ''
matrix_url(params.fetch(:consumer_name), params.fetch(:provider_name), base_url)
end

def group_url(pacticipant_name, base_url = '')
"#{base_url}/groups/#{pacticipant_name}"
end

def hal_browser_url target_url
"/hal-browser/browser.html#" + target_url
end
Expand Down
12 changes: 12 additions & 0 deletions spec/lib/pact_broker/api/decorators/integration_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Decorators
before do
allow(integration_decorator).to receive(:dashboard_url_for_integration).and_return("/dashboard")
allow(integration_decorator).to receive(:matrix_url).and_return("/matrix")
allow(integration_decorator).to receive(:group_url).and_return("/group")
end

let(:integration) do
Expand All @@ -34,6 +35,9 @@ module Decorators
"pb:matrix" => {
"title" => "Matrix of pacts/verification results for the consumer and the provider",
"href" => "/matrix"
},
"pb:group" => {
"href" => "/group"
}
}
}
Expand Down Expand Up @@ -64,6 +68,14 @@ module Decorators
)
subject
end

it "generates the correct group url for the matrix" do
expect(integration_decorator).to receive(:group_url).with(
"the consumer",
"http://example.org"
)
subject
end
end
end
end
Expand Down

0 comments on commit e2584f5

Please sign in to comment.