Commit ca4a59e3 authored by Felipe Artur's avatar Felipe Artur

Fix error on changes tab when merge request cannot be created

parent 34760245
...@@ -43,11 +43,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap ...@@ -43,11 +43,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
end end
def diffs def diffs
@diffs = if @merge_request.can_be_created @diffs = @merge_request.diffs(diff_options) if @merge_request.can_be_created
@merge_request.diffs(diff_options)
else
[]
end
@diff_notes_disabled = true @diff_notes_disabled = true
......
= render "projects/diffs/diffs", diffs: @diffs, environment: @environment, show_whitespace_toggle: false - if @merge_request.can_be_created
= render "projects/diffs/diffs", diffs: @diffs, environment: @environment, show_whitespace_toggle: false
- else
.nothing-here-block
This merge request cannot be created.
---
title: Fix error on changes tab when merge request cannot be created
merge_request:
author:
type: fixed
...@@ -4,6 +4,16 @@ describe Projects::MergeRequests::CreationsController do ...@@ -4,6 +4,16 @@ describe Projects::MergeRequests::CreationsController do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { project.owner } let(:user) { project.owner }
let(:fork_project) { create(:forked_project_with_submodules) } let(:fork_project) { create(:forked_project_with_submodules) }
let(:get_diff_params) do
{
namespace_id: fork_project.namespace.to_param,
project_id: fork_project,
merge_request: {
source_branch: 'remove-submodule',
target_branch: 'master'
}
}
end
before do before do
fork_project.add_master(user) fork_project.add_master(user)
...@@ -13,18 +23,23 @@ describe Projects::MergeRequests::CreationsController do ...@@ -13,18 +23,23 @@ describe Projects::MergeRequests::CreationsController do
describe 'GET new' do describe 'GET new' do
context 'merge request that removes a submodule' do context 'merge request that removes a submodule' do
render_views
it 'renders new merge request widget template' do it 'renders new merge request widget template' do
get :new, get :new, get_diff_params
namespace_id: fork_project.namespace.to_param,
project_id: fork_project, expect(response).to be_success
merge_request: { end
source_branch: 'remove-submodule', end
target_branch: 'master' end
}
describe 'GET diffs' do
context 'when merge request cannot be created' do
it 'does not assign diffs var' do
allow_any_instance_of(MergeRequest).to receive(:can_be_created).and_return(false)
get :diffs, get_diff_params.merge(format: 'json')
expect(response).to be_success expect(response).to be_success
expect(assigns[:diffs]).to be_nil
end end
end end
end end
...@@ -37,14 +52,7 @@ describe Projects::MergeRequests::CreationsController do ...@@ -37,14 +52,7 @@ describe Projects::MergeRequests::CreationsController do
end end
it 'renders JSON including serialized pipelines' do it 'renders JSON including serialized pipelines' do
get :pipelines, get :pipelines, get_diff_params.merge(format: 'json')
namespace_id: fork_project.namespace.to_param,
project_id: fork_project,
merge_request: {
source_branch: 'remove-submodule',
target_branch: 'master'
},
format: :json
expect(response).to be_ok expect(response).to be_ok
expect(json_response).to have_key 'pipelines' expect(json_response).to have_key 'pipelines'
......
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