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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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:
]
},
"_links":{
"merge_requests": "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"
"merge_requests_url": "https://gitlab.example.com/root/awesome_app/merge_requests?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
end
end
expose :_links do
expose :merge_requests
expose :issues
expose :merge_requests_url
expose :issues_url
end
private
......@@ -1335,11 +1335,11 @@ module API
Gitlab::Routing.url_helpers.project_tag_path(project, object.tag)
end
def merge_requests
def merge_requests_url
Gitlab::Routing.url_helpers.project_merge_requests_url(project, params_for_issues_and_mrs)
end
def issues
def issues_url
Gitlab::Routing.url_helpers.project_issues_url(project, params_for_issues_and_mrs)
end
......
......@@ -38,10 +38,10 @@
"additionalProperties": false
},
"_links": {
"required": ["merge_requests", "issues"],
"required": ["merge_requests_url", "issues_url"],
"properties": {
"merge_requests": { "type": "string" },
"issues": { "type": "string" }
"merge_requests_url": { "type": "string" },
"issues_url": { "type": "string" }
}
}
},
......
......@@ -26,10 +26,10 @@
"additionalProperties": false
},
"_links": {
"required": ["merge_requests", "issues"],
"required": ["merge_requests_url", "issues_url"],
"properties": {
"merge_requests": { "type": "string" },
"issues": { "type": "string" }
"merge_requests_url": { "type": "string" },
"issues_url": { "type": "string" }
}
}
},
......
......@@ -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}")
end
it 'returns the merge requests and issues links' 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
it 'returns the merge requests and issues links, with correct query' do
get api("/projects/#{project.id}/releases", maintainer)
links = json_response.first['_links']
release = json_response.first['tag_name']
expected_params = %w(release_tag scope state)
release_tag_param = "release_tag=#{release}"
expect(links['merge_requests'].split('?')[1]).to include(*expected_params)
expect(links['issues'].split('?')[1]).to include(*expected_params)
expect(links['merge_requests']).to include(release_tag_param)
expect(links['issues']).to include(release_tag_param)
expected_query = "release_tag=#{release}&scope=all&state=opened"
path_base = "/#{project.namespace.path}/#{project.path}"
mr_uri = URI.parse(links['merge_requests_url'])
issue_uri = URI.parse(links['issues_url'])
expect(mr_uri.path).to eq("#{path_base}/merge_requests")
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
......
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