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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
3f6121f2
Commit
3f6121f2
authored
May 10, 2017
by
Oswaldo Ferreira
Committed by
Fatih Acet
May 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Returns new_blob_path only when user can push_code to project
parent
ca3d868c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
app/serializers/merge_request_entity.rb
app/serializers/merge_request_entity.rb
+5
-3
spec/serializers/merge_request_entity_spec.rb
spec/serializers/merge_request_entity_spec.rb
+17
-0
No files found.
app/serializers/merge_request_entity.rb
View file @
3f6121f2
...
...
@@ -98,10 +98,12 @@ class MergeRequestEntity < IssuableEntity
end
expose
:new_blob_path
do
|
merge_request
|
if
can?
(
current_user
,
:push_code
,
merge_request
.
project
)
namespace_project_new_blob_path
(
merge_request
.
project
.
namespace
,
merge_request
.
project
,
merge_request
.
source_branch
)
end
end
expose
:conflict_resolution_path
do
|
merge_request
|
presenter
(
merge_request
).
conflict_resolution_path
...
...
spec/serializers/merge_request_entity_spec.rb
View file @
3f6121f2
...
...
@@ -65,6 +65,23 @@ describe MergeRequestEntity do
.
to
eq
(
resource
.
merge_commit_message
(
include_description:
true
))
end
describe
'new_blob_path'
do
context
'when user can push to project'
do
it
'returns path'
do
project
.
add_developer
(
user
)
expect
(
subject
[
:new_blob_path
])
.
to
eq
(
"/
#{
resource
.
project
.
full_path
}
/new/
#{
resource
.
source_branch
}
"
)
end
end
context
'when user cannot push to project'
do
it
'returns nil'
do
expect
(
subject
[
:new_blob_path
]).
to
be_nil
end
end
end
describe
'diff_head_sha'
do
before
do
allow
(
resource
).
to
receive
(
:diff_head_sha
)
{
'sha'
}
...
...
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