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
Tatuya Kamada
gitlab-ce
Commits
4a8a28eb
Commit
4a8a28eb
authored
Feb 17, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue where files on a fork could not be edited
parent
a2801ec4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
31 deletions
+36
-31
app/controllers/concerns/creates_commit.rb
app/controllers/concerns/creates_commit.rb
+4
-12
spec/controllers/projects/blob_controller_spec.rb
spec/controllers/projects/blob_controller_spec.rb
+32
-19
No files found.
app/controllers/concerns/creates_commit.rb
View file @
4a8a28eb
...
@@ -104,23 +104,15 @@ module CreatesCommit
...
@@ -104,23 +104,15 @@ module CreatesCommit
if
can?
(
current_user
,
:push_code
,
@project
)
if
can?
(
current_user
,
:push_code
,
@project
)
# Edit file in this project
# Edit file in this project
@mr_source_project
=
@project
@mr_source_project
=
@project
if
@project
.
forked?
# Merge request from this project to fork origin
@mr_target_project
=
@project
.
forked_from_project
@mr_target_branch
=
@mr_target_project
.
repository
.
root_ref
else
# Merge request to this project
@mr_target_project
=
@project
@mr_target_branch
=
@ref
||
@target_branch
end
else
else
# Merge request from fork to this project
# Merge request from fork to this project
@mr_source_project
=
current_user
.
fork_of
(
@project
)
@mr_source_project
=
current_user
.
fork_of
(
@project
)
@mr_target_project
=
@project
@mr_target_branch
=
@ref
||
@target_branch
end
end
# Merge request to this project
@mr_target_project
=
@project
@mr_target_branch
=
@ref
||
@target_branch
@mr_source_branch
=
guess_mr_source_branch
@mr_source_branch
=
guess_mr_source_branch
end
end
...
...
spec/controllers/projects/blob_controller_spec.rb
View file @
4a8a28eb
...
@@ -92,26 +92,39 @@ describe Projects::BlobController do
...
@@ -92,26 +92,39 @@ describe Projects::BlobController do
before
{
sign_in
(
guest
)
}
before
{
sign_in
(
guest
)
}
it
"redirects to forked project new merge request"
do
context
'when editing on the fork'
do
default_params
[
:target_branch
]
=
"fork-test-1"
before
do
default_params
[
:create_merge_request
]
=
1
default_params
[
:namespace_id
]
=
forked_project
.
namespace
.
to_param
default_params
[
:project_id
]
=
forked_project
.
to_param
allow_any_instance_of
(
Files
::
UpdateService
).
to
receive
(
:commit
).
and_return
(
:success
)
end
put
:update
,
default_params
it
'redirects to blob'
do
put
:update
,
default_params
expect
(
response
).
to
redirect_to
(
new_namespace_project_merge_request_path
(
expect
(
response
).
to
redirect_to
(
namespace_project_blob_path
(
forked_project
.
namespace
,
forked_project
,
'master/CHANGELOG'
))
forked_project
.
namespace
,
end
forked_project
,
end
merge_request:
{
source_project_id:
forked_project
.
id
,
context
'when editing on the original repository'
do
target_project_id:
project
.
id
,
it
"redirects to forked project new merge request"
do
source_branch:
"fork-test-1"
,
default_params
[
:target_branch
]
=
"fork-test-1"
target_branch:
"master"
default_params
[
:create_merge_request
]
=
1
}
put
:update
,
default_params
expect
(
response
).
to
redirect_to
(
new_namespace_project_merge_request_path
(
forked_project
.
namespace
,
forked_project
,
merge_request:
{
source_project_id:
forked_project
.
id
,
target_project_id:
project
.
id
,
source_branch:
"fork-test-1"
,
target_branch:
"master"
}
)
)
)
)
end
end
end
end
end
end
end
...
...
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