Merge branch 'dm-fix-editing-files-on-forks-quick' into 'master'
Fix issue where files on a fork could not be edited Closes #28188 See merge request !9349
This commit is contained in:
commit
608711c247
2 changed files with 39 additions and 32 deletions
|
@ -104,23 +104,15 @@ 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)
|
||||
@mr_target_project = @project
|
||||
@mr_target_branch = @ref || @target_branch
|
||||
end
|
||||
|
||||
# Merge request to this project
|
||||
@mr_target_project = @project
|
||||
@mr_target_branch = @ref || @target_branch
|
||||
|
||||
@mr_source_branch = guess_mr_source_branch
|
||||
end
|
||||
|
||||
|
|
|
@ -86,32 +86,47 @@ describe Projects::BlobController do
|
|||
end
|
||||
|
||||
context 'when user has forked project' do
|
||||
let(:guest) { create(:user) }
|
||||
let!(:forked_project) { Projects::ForkService.new(project, guest).execute }
|
||||
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: "fork-test-1", target_branch: "master") }
|
||||
let(:forked_project_link) { create(:forked_project_link, forked_from_project: project) }
|
||||
let!(:forked_project) { forked_project_link.forked_to_project }
|
||||
let(:guest) { forked_project.owner }
|
||||
|
||||
before { sign_in(guest) }
|
||||
before do
|
||||
sign_in(guest)
|
||||
end
|
||||
|
||||
it "redirects to forked project new merge request" do
|
||||
default_params[:target_branch] = "fork-test-1"
|
||||
default_params[:create_merge_request] = 1
|
||||
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
|
||||
|
||||
allow_any_instance_of(Files::UpdateService).to receive(:commit).and_return(:success)
|
||||
it 'redirects to blob' do
|
||||
put :update, default_params
|
||||
|
||||
put :update, default_params
|
||||
expect(response).to redirect_to(namespace_project_blob_path(forked_project.namespace, forked_project, 'master/CHANGELOG'))
|
||||
end
|
||||
end
|
||||
|
||||
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"
|
||||
}
|
||||
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
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue