Commit 4a8a28eb authored by Douwe Maan's avatar Douwe Maan

Fix issue where files on a fork could not be edited

parent a2801ec4
......@@ -104,22 +104,14 @@ module CreatesCommit
if can?(current_user, :push_code, @project)
# Edit file in this 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
# Merge request from fork to this project
@mr_source_project = current_user.fork_of(@project)
end
# Merge request to this project
@mr_target_project = @project
@mr_target_branch = @ref || @target_branch
end
@mr_source_branch = guess_mr_source_branch
end
......
......@@ -92,12 +92,24 @@ describe Projects::BlobController do
before { sign_in(guest) }
context 'when editing on the fork' do
before do
default_params[:namespace_id] = forked_project.namespace.to_param
default_params[:project_id] = forked_project.to_param
end
it 'redirects to blob' do
put :update, default_params
expect(response).to redirect_to(namespace_project_blob_path(forked_project.namespace, forked_project, 'master/CHANGELOG'))
end
end
context 'when editing on the original repository' do
it "redirects to forked project new merge request" do
default_params[:target_branch] = "fork-test-1"
default_params[:create_merge_request] = 1
allow_any_instance_of(Files::UpdateService).to receive(:commit).and_return(:success)
put :update, default_params
expect(response).to redirect_to(
......@@ -115,4 +127,5 @@ describe Projects::BlobController do
end
end
end
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