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
ae047419
Commit
ae047419
authored
Jan 25, 2019
by
Mark Chao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose paths needed in API
It is helpful to not duplicate these paths in the FE.
parent
a354a38f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
0 deletions
+72
-0
ee/app/presenters/ee/merge_request_presenter.rb
ee/app/presenters/ee/merge_request_presenter.rb
+24
-0
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+12
-0
ee/spec/presenters/merge_request_presenter_spec.rb
ee/spec/presenters/merge_request_presenter_spec.rb
+32
-0
spec/fixtures/api/schemas/entities/merge_request_widget.json
spec/fixtures/api/schemas/entities/merge_request_widget.json
+4
-0
No files found.
ee/app/presenters/ee/merge_request_presenter.rb
View file @
ae047419
...
...
@@ -11,6 +11,30 @@ module EE
end
end
def
api_approvals_path
if
requires_approve?
api_v4_projects_merge_requests_approvals_path
(
id:
project
.
id
,
merge_request_iid:
merge_request
.
iid
)
end
end
def
api_approval_settings_path
if
requires_approve?
api_v4_projects_merge_requests_approval_settings_path
(
id:
project
.
id
,
merge_request_iid:
merge_request
.
iid
)
end
end
def
api_approve_path
if
requires_approve?
api_v4_projects_merge_requests_approve_path
(
id:
project
.
id
,
merge_request_iid:
merge_request
.
iid
)
end
end
def
api_unapprove_path
if
requires_approve?
api_v4_projects_merge_requests_unapprove_path
(
id:
project
.
id
,
merge_request_iid:
merge_request
.
iid
)
end
end
def
target_project
merge_request
.
target_project
.
present
(
current_user:
current_user
)
end
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
ae047419
...
...
@@ -128,6 +128,18 @@ module EE
expose
:approvals_path
do
|
merge_request
|
presenter
(
merge_request
).
approvals_path
end
expose
:api_approvals_path
do
|
merge_request
|
presenter
(
merge_request
).
api_approvals_path
end
expose
:api_approval_settings_path
do
|
merge_request
|
presenter
(
merge_request
).
api_approval_settings_path
end
expose
:api_approve_path
do
|
merge_request
|
presenter
(
merge_request
).
api_approve_path
end
expose
:api_unapprove_path
do
|
merge_request
|
presenter
(
merge_request
).
api_unapprove_path
end
end
private
...
...
ee/spec/presenters/merge_request_presenter_spec.rb
View file @
ae047419
...
...
@@ -13,6 +13,38 @@ describe MergeRequestPresenter do
end
end
describe
'#api_approvals_path'
do
subject
{
described_class
.
new
(
resource
,
current_user:
user
).
api_approvals_path
}
it
'returns path'
do
is_expected
.
to
eq
(
"/api/v4/projects/
#{
resource
.
project
.
id
}
/merge_requests/
#{
resource
.
iid
}
/approvals"
)
end
end
describe
'#api_approval_settings_path'
do
subject
{
described_class
.
new
(
resource
,
current_user:
user
).
api_approval_settings_path
}
it
'returns path'
do
is_expected
.
to
eq
(
"/api/v4/projects/
#{
resource
.
project
.
id
}
/merge_requests/
#{
resource
.
iid
}
/approval_settings"
)
end
end
describe
'#api_approve_path'
do
subject
{
described_class
.
new
(
resource
,
current_user:
user
).
api_approve_path
}
it
'returns path'
do
is_expected
.
to
eq
(
"/api/v4/projects/
#{
resource
.
project
.
id
}
/merge_requests/
#{
resource
.
iid
}
/approve"
)
end
end
describe
'#api_unapprove_path'
do
subject
{
described_class
.
new
(
resource
,
current_user:
user
).
api_unapprove_path
}
it
'returns path'
do
is_expected
.
to
eq
(
"/api/v4/projects/
#{
resource
.
project
.
id
}
/merge_requests/
#{
resource
.
iid
}
/unapprove"
)
end
end
describe
'#approvers_left'
do
let!
(
:private_group
)
{
create
(
:group_with_members
,
:private
)
}
let!
(
:public_group
)
{
create
(
:group_with_members
)
}
...
...
spec/fixtures/api/schemas/entities/merge_request_widget.json
View file @
ae047419
...
...
@@ -129,6 +129,10 @@
"approvals_before_merge"
:
{
"type"
:
[
"integer"
,
"null"
]
},
"approved"
:
{
"type"
:
"boolean"
},
"approvals_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"api_approvals_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"api_approval_settings_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"api_approve_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"api_unapprove_path"
:
{
"type"
:
[
"string"
,
"null"
]
},
"codeclimate"
:
{
"head_path"
:
{
"type"
:
"string"
},
"base_path"
:
{
"type"
:
"string"
}
...
...
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