Skip to content

Commit

Permalink
feat(pact resource): improve usage of name and title fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Sep 14, 2017
1 parent d5ea068 commit 3a9a178
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
15 changes: 5 additions & 10 deletions lib/pact_broker/api/decorators/pact_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ 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)

}
Expand All @@ -72,33 +71,29 @@ def to_hash(options = {})

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
9 changes: 3 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,8 +78,7 @@ 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

Expand Down

0 comments on commit 3a9a178

Please sign in to comment.