Commit 05d3494b authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'kerrizor/add-additional-guard-against-nil-mrd-objects' into 'master'

Add guard for nil merge_request_diff.id

See merge request gitlab-org/gitlab!28034
parents 5ab3372b 7c9418bd
......@@ -98,7 +98,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@merge_request.merge_request_diff
end
return unless @merge_request_diff
return unless @merge_request_diff&.id
@comparable_diffs = @merge_request_diffs.select { |diff| diff.id < @merge_request_diff.id }
......
......@@ -16,6 +16,18 @@ describe Projects::MergeRequests::DiffsController do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when the merge_request_diff.id is blank' do
it 'returns 404' do
allow_next_instance_of(MergeRequest) do |instance|
allow(instance).to receive(:merge_request_diff).and_return(MergeRequestDiff.new(merge_request_id: instance.id))
go
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
shared_examples 'forked project with submodules' do
......
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