diff options
author | Robert Speicher <robert@gitlab.com> | 2017-02-20 20:05:51 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2017-02-20 20:05:51 +0000 |
commit | 608711c247c1d58bd8f38e459ea9897b76802dc3 (patch) | |
tree | cd627cb5d9cbdba96e22da53ba6d90a92e48c7ee /spec/controllers | |
parent | 91ac1991b5810b4f2378b5821e02bbeb4d379140 (diff) | |
parent | cd0f688707c4330207626bb47b1bf4e0df0e988e (diff) | |
download | gitlab-ce-608711c247c1d58bd8f38e459ea9897b76802dc3.tar.gz |
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
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/blob_controller_spec.rb | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index b36d0e69330..7d4636e98d1 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -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") } - - before { sign_in(guest) } - - 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( - 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" - } + 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 do + sign_in(guest) + end + + 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 + + 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 |