Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0f5c6b6a
Commit
0f5c6b6a
authored
Oct 09, 2019
by
Etienne Baqué
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified release api entity
Updated release payload to include links. Updated rspec accordingly.
parent
fc69d1cf
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
2 deletions
+60
-2
lib/api/entities.rb
lib/api/entities.rb
+22
-2
spec/fixtures/api/schemas/public_api/v4/release.json
spec/fixtures/api/schemas/public_api/v4/release.json
+7
-0
spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json
.../api/schemas/public_api/v4/release/release_for_guest.json
+7
-0
spec/requests/api/releases_spec.rb
spec/requests/api/releases_spec.rb
+24
-0
No files found.
lib/api/entities.rb
View file @
0f5c6b6a
...
...
@@ -1314,6 +1314,10 @@ module API
release
.
links
.
sorted
end
end
expose
:_links
do
expose
:merge_requests
expose
:issues
end
private
...
...
@@ -1324,11 +1328,27 @@ module API
def
commit_path
return
unless
object
.
commit
Gitlab
::
Routing
.
url_helpers
.
project_commit_path
(
object
.
project
,
object
.
commit
.
id
)
Gitlab
::
Routing
.
url_helpers
.
project_commit_path
(
project
,
object
.
commit
.
id
)
end
def
tag_path
Gitlab
::
Routing
.
url_helpers
.
project_tag_path
(
object
.
project
,
object
.
tag
)
Gitlab
::
Routing
.
url_helpers
.
project_tag_path
(
project
,
object
.
tag
)
end
def
merge_requests
Gitlab
::
Routing
.
url_helpers
.
project_merge_requests_url
(
project
,
params_for_issues_and_mrs
)
end
def
issues
Gitlab
::
Routing
.
url_helpers
.
project_issues_url
(
project
,
params_for_issues_and_mrs
)
end
def
params_for_issues_and_mrs
{
scope:
'all'
,
state:
'opened'
,
release_tag:
object
.
tag
}
end
def
project
@project
||=
object
.
project
end
end
...
...
spec/fixtures/api/schemas/public_api/v4/release.json
View file @
0f5c6b6a
...
...
@@ -36,6 +36,13 @@
}
},
"additionalProperties"
:
false
},
"_links"
:
{
"required"
:
[
"merge_requests"
,
"issues"
],
"properties"
:
{
"merge_requests"
:
{
"type"
:
"string"
},
"issues"
:
{
"type"
:
"string"
}
}
}
},
"additionalProperties"
:
false
...
...
spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json
View file @
0f5c6b6a
...
...
@@ -24,6 +24,13 @@
"links"
:
{
"$ref"
:
"../../../release/links.json"
}
},
"additionalProperties"
:
false
},
"_links"
:
{
"required"
:
[
"merge_requests"
,
"issues"
],
"properties"
:
{
"merge_requests"
:
{
"type"
:
"string"
},
"issues"
:
{
"type"
:
"string"
}
}
}
},
"additionalProperties"
:
false
...
...
spec/requests/api/releases_spec.rb
View file @
0f5c6b6a
...
...
@@ -63,6 +63,30 @@ describe API::Releases do
expect
(
json_response
.
second
[
'commit_path'
]).
to
eq
(
"/
#{
release_1
.
project
.
full_path
}
/commit/
#{
release_1
.
commit
.
id
}
"
)
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
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
)
end
end
it
'returns an upcoming_release status for a future release'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment