Skip to content

Commit

Permalink
feat: change URL for retrieving latest version so that it does not cl…
Browse files Browse the repository at this point in the history
…ash with a version called "latest"
  • Loading branch information
bethesque committed Jan 25, 2018
1 parent aa60a85 commit 8e45062
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions lib/pact_broker/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ module PactBroker
add ['pacticipants', :name], Api::Resources::Pacticipant, {resource_name: "pacticipant"}
add ['pacticipants', :pacticipant_name, 'versions'], Api::Resources::Versions, {resource_name: "pacticipant_versions"}
add ['pacticipants', :pacticipant_name, 'versions', :pacticipant_version_number], Api::Resources::Version, {resource_name: "pacticipant_version"}
add ['pacticipants', :pacticipant_name, 'versions', 'latest', :tag], Api::Resources::Version, {resource_name: "latest_tagged_pacticipant_version"}
add ['pacticipants', :pacticipant_name, 'versions', 'latest'], Api::Resources::Version, {resource_name: "latest_pacticipant_version"}
add ['pacticipants', :pacticipant_name, 'latest-version', :tag], Api::Resources::Version, {resource_name: "latest_tagged_pacticipant_version"}
add ['pacticipants', :pacticipant_name, 'latest-version'], Api::Resources::Version, {resource_name: "latest_pacticipant_version"}
add ['pacticipants', :pacticipant_name, 'versions', :pacticipant_version_number, 'tags', :tag_name], Api::Resources::Tag, {resource_name: "pacticipant_version_tag"}
add ['pacticipants', :pacticipant_name, 'labels', :label_name], Api::Resources::Label, {resource_name: "pacticipant_label"}

Expand Down
4 changes: 2 additions & 2 deletions lib/pact_broker/api/resources/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ def to_json
templated: true
},
'pb:latest-version' => {
href: base_url + '/pacticipants/{pacticipant}/versions/latest',
href: base_url + '/pacticipants/{pacticipant}/latest-version',
title: 'Latest pacticipant version',
templated: true
},
'pb:latest-tagged-version' => {
href: base_url + '/pacticipants/{pacticipant}/versions/latest/{tag}',
href: base_url + '/pacticipants/{pacticipant}/latest-version/{tag}',
title: 'Latest pacticipant version with the specified tag',
templated: true
},
Expand Down
2 changes: 1 addition & 1 deletion lib/pact_broker/api/resources/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def delete_resource
def version
if path_info[:tag]
@version ||= version_service.find_by_pacticpant_name_and_latest_tag(path_info[:pacticipant_name], path_info[:tag])
elsif path_info[:number]
elsif path_info[:pacticipant_version_number]
@version ||= version_service.find_by_pacticipant_name_and_number path_info
else
@version ||= version_service.find_latest_by_pacticpant_name path_info
Expand Down
4 changes: 2 additions & 2 deletions spec/service_consumers/hal_relation_proxy_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ class HalRelationProxyApp
# the consumer does not need to know the actual URLs.
PATH_REPLACEMENTS = {
'/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-TAGGED-VERSION-Condor-production' =>
'/pacticipants/Condor/versions/latest/production',
'/pacticipants/Condor/latest-version/production',
'/HAL-REL-PLACEHOLDER-INDEX-PB-LATEST-VERSION-Condor' =>
'/pacticipants/Condor/versions/latest'
'/pacticipants/Condor/latest-version'
}

RESPONSE_BODY_REPLACEMENTS = {
Expand Down

0 comments on commit 8e45062

Please sign in to comment.