Skip to content

Commit

Permalink
Merge branch 'master' into webhook-status
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 14, 2017
2 parents c99c30a + 915a7ee commit 620922b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions lib/pact_broker/api/decorators/pact_collection_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def create_representable_pact pact
represented.collect do | pact |
{
:href => latest_pact_url(options[:base_url], pact),
:name => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
:title => "Pact"
:title => "Latest pact between #{pact.consumer.name} and #{pact.provider.name}",
}
end
end
Expand Down
22 changes: 12 additions & 10 deletions lib/pact_broker/api/decorators/pact_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,42 +56,44 @@ def to_hash(options = {})

link :'pb:latest-pact-version' do | options |
{
title: "Pact",
name: "Latest version of this pact",
title: "Latest version of this pact",
href: latest_pact_url(options.fetch(:base_url), represented)

}
end

link :'pb:all-pact-versions' do | options |
{
title: "All versions of this pact",
href: pact_versions_url(represented.consumer.name, represented.provider.name, options.fetch(:base_url))
}
end

link :'pb:latest-untagged-pact-version' do | options |
{
title: "Pact",
name: "Latest untagged version of this pact",
title: "Latest untagged version of this pact",
href: latest_untagged_pact_url(represented, options.fetch(:base_url))
}
end

link :'pb:latest-tagged-pact-version' do | options |
{
title: "Pact",
name: "Latest tagged version of this pact",
title: "Latest tagged version of this pact",
href: "#{latest_pact_url(options.fetch(:base_url), represented)}/{tag}",
templated: true
}
end

link :'pb:previous-distinct' do | options |
{
title: "Pact",
name: "Previous distinct version of this pact",
title: "Previous distinct version of this pact",
href: previous_distinct_pact_version_url(represented, options.fetch(:base_url))
}
end

link :'pb:diff-previous-distinct' do | options |
{
title: "Diff",
name: "Diff with previous distinct version of this pact",
title: "Diff with previous distinct version of this pact",
href: previous_distinct_diff_url(represented, options.fetch(:base_url))

}
Expand Down
3 changes: 1 addition & 2 deletions lib/pact_broker/api/decorators/pact_versions_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class PactVersionsDecorator < BaseDecorator
link :self do | context |
{
href: context[:resource_url],
title: "Pact versions",
name: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
title: "All versions of the pact between #{context[:consumer_name]} and #{context[:provider_name]}"
}
end

Expand Down
4 changes: 1 addition & 3 deletions lib/pact_broker/api/decorators/webhook_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ class WebhookDecorator < BaseDecorator
href: webhooks_url(options[:base_url])
}
end


end
end
end
end
end
1 change: 0 additions & 1 deletion lib/pact_broker/api/decorators/webhooks_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class WebhooksDecorator < BaseDecorator
templated: true
}]
end

end
end
end
Expand Down
14 changes: 8 additions & 6 deletions spec/lib/pact_broker/api/decorators/pact_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ module Decorators

it "includes a link to the diff with the previous distinct version" do
expect(subject[:_links][:'pb:diff-previous-distinct']).to eq({href: 'http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/version/1234/diff/previous-distinct',
title: 'Diff',
name: 'Diff with previous distinct version of this pact'})
title: 'Diff with previous distinct version of this pact'})
end

it "includes a link to the previous distinct pact version" do
expect(subject[:_links][:'pb:previous-distinct']).to eq({href: 'http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/version/1234/previous-distinct',
title: 'Pact',
name: 'Previous distinct version of this pact'})
title: 'Previous distinct version of this pact'})
end

it "includes a link to tag this version" do
Expand All @@ -80,11 +78,15 @@ module Decorators
end

it "includes a link to the latest pact" do
expect(subject[:_links][:'pb:latest-pact-version'][:title]).to eq "Pact"
expect(subject[:_links][:'pb:latest-pact-version'][:name]).to eq "Latest version of this pact"
expect(subject[:_links][:'pb:latest-pact-version'][:title]).to eq "Latest version of this pact"
expect(subject[:_links][:'pb:latest-pact-version'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/latest"
end

it "includes a link to all pact versions" do
expect(subject[:_links][:'pb:all-pact-versions'][:title]).to eq "All versions of this pact"
expect(subject[:_links][:'pb:all-pact-versions'][:href]).to eq "http://example.org/pacts/provider/A%20Provider/consumer/A%20Consumer/versions"
end

it "includes a link to the pact version" do
expect(subject[:_links][:'pb:consumer-version'][:title]).to eq "Consumer version"
expect(subject[:_links][:'pb:consumer-version'][:name]).to eq "1234"
Expand Down

0 comments on commit 620922b

Please sign in to comment.