Commit 82cda94d authored by Etienne Baqué's avatar Etienne Baqué

Updated multiple files based on review comments

Updated api release rspec files.
Updated release api documentation.
parent 6f131875
...@@ -123,8 +123,8 @@ Example response: ...@@ -123,8 +123,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.2&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.2&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.2&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.2&scope=all&state=opened"
} }
}, },
{ {
...@@ -183,8 +183,8 @@ Example response: ...@@ -183,8 +183,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened"
} }
} }
] ]
...@@ -298,8 +298,8 @@ Example response: ...@@ -298,8 +298,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened"
} }
} }
``` ```
...@@ -427,8 +427,8 @@ Example response: ...@@ -427,8 +427,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.3&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.3&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.3&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.3&scope=all&state=opened"
} }
} }
``` ```
...@@ -532,8 +532,8 @@ Example response: ...@@ -532,8 +532,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened"
} }
} }
``` ```
...@@ -618,8 +618,8 @@ Example response: ...@@ -618,8 +618,8 @@ Example response:
] ]
}, },
"_links":{ "_links":{
"merge_requests": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened", "merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?release_tag=v0.1&scope=all&state=opened",
"issues": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened" "issues_url": "https://gitlab.example.com/root/awesome_app/issues?release_tag=v0.1&scope=all&state=opened"
} }
} }
``` ```
......
...@@ -1315,8 +1315,8 @@ module API ...@@ -1315,8 +1315,8 @@ module API
end end
end end
expose :_links do expose :_links do
expose :merge_requests expose :merge_requests_url
expose :issues expose :issues_url
end end
private private
...@@ -1335,11 +1335,11 @@ module API ...@@ -1335,11 +1335,11 @@ module API
Gitlab::Routing.url_helpers.project_tag_path(project, object.tag) Gitlab::Routing.url_helpers.project_tag_path(project, object.tag)
end end
def merge_requests def merge_requests_url
Gitlab::Routing.url_helpers.project_merge_requests_url(project, params_for_issues_and_mrs) Gitlab::Routing.url_helpers.project_merge_requests_url(project, params_for_issues_and_mrs)
end end
def issues def issues_url
Gitlab::Routing.url_helpers.project_issues_url(project, params_for_issues_and_mrs) Gitlab::Routing.url_helpers.project_issues_url(project, params_for_issues_and_mrs)
end end
......
...@@ -38,10 +38,10 @@ ...@@ -38,10 +38,10 @@
"additionalProperties": false "additionalProperties": false
}, },
"_links": { "_links": {
"required": ["merge_requests", "issues"], "required": ["merge_requests_url", "issues_url"],
"properties": { "properties": {
"merge_requests": { "type": "string" }, "merge_requests_url": { "type": "string" },
"issues": { "type": "string" } "issues_url": { "type": "string" }
} }
} }
}, },
......
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
"additionalProperties": false "additionalProperties": false
}, },
"_links": { "_links": {
"required": ["merge_requests", "issues"], "required": ["merge_requests_url", "issues_url"],
"properties": { "properties": {
"merge_requests": { "type": "string" }, "merge_requests_url": { "type": "string" },
"issues": { "type": "string" } "issues_url": { "type": "string" }
} }
} }
}, },
......
...@@ -64,28 +64,20 @@ describe API::Releases do ...@@ -64,28 +64,20 @@ describe API::Releases do
expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}") expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}")
end end
it 'returns the merge requests and issues links' do it 'returns the merge requests and issues links, with correct query' do
get api("/projects/#{project.id}/releases", maintainer)
links = json_response.first['_links']
expect(links.keys).to include('merge_requests', 'issues')
expect(links['merge_requests']).to include("/#{release_2.project.full_path}/merge_requests")
expect(links['issues']).to include("/#{release_2.project.full_path}/issues")
end
it 'returns urls with correct parameters and release tag' do
get api("/projects/#{project.id}/releases", maintainer) get api("/projects/#{project.id}/releases", maintainer)
links = json_response.first['_links'] links = json_response.first['_links']
release = json_response.first['tag_name'] release = json_response.first['tag_name']
expected_params = %w(release_tag scope state) expected_query = "release_tag=#{release}&scope=all&state=opened"
release_tag_param = "release_tag=#{release}" path_base = "/#{project.namespace.path}/#{project.path}"
mr_uri = URI.parse(links['merge_requests_url'])
expect(links['merge_requests'].split('?')[1]).to include(*expected_params) issue_uri = URI.parse(links['issues_url'])
expect(links['issues'].split('?')[1]).to include(*expected_params)
expect(links['merge_requests']).to include(release_tag_param) expect(mr_uri.path).to eq("#{path_base}/merge_requests")
expect(links['issues']).to include(release_tag_param) expect(issue_uri.path).to eq("#{path_base}/issues")
expect(mr_uri.query).to eq(expected_query)
expect(issue_uri.query).to eq(expected_query)
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment