Fix error on changes tab when merge request cannot be created
This commit is contained in:
parent
34760245bc
commit
ca4a59e3df
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
|
- if @merge_request.can_be_created
|
||||||
= render "projects/diffs/diffs", diffs: @diffs, environment: @environment, show_whitespace_toggle: false
|
= render "projects/diffs/diffs", diffs: @diffs, environment: @environment, show_whitespace_toggle: false
|
||||||
|
- else
|
||||||
|
.nothing-here-block
|
||||||
|
This merge request cannot be created.
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
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
|
||||||
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,22 +23,27 @@ 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,
|
|
||||||
merge_request: {
|
|
||||||
source_branch: 'remove-submodule',
|
|
||||||
target_branch: 'master'
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(response).to be_success
|
expect(response).to be_success
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
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(assigns[:diffs]).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'GET pipelines' do
|
describe 'GET pipelines' do
|
||||||
before do
|
before do
|
||||||
create(:ci_pipeline, sha: fork_project.commit('remove-submodule').id,
|
create(:ci_pipeline, sha: fork_project.commit('remove-submodule').id,
|
||||||
|
@ -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'
|
||||||
|
|
Loading…
Reference in New Issue