Commit 89f47854 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'osw-fallback-to-collection-when-no-diff-refs' into 'master'

Render MR page when no persisted diff_refs or diffs size

Closes #49342

See merge request gitlab-org/gitlab-ce!20680
parents 953a061d 3ecc2b04
...@@ -182,7 +182,7 @@ class MergeRequestDiff < ActiveRecord::Base ...@@ -182,7 +182,7 @@ class MergeRequestDiff < ActiveRecord::Base
end end
def diffs(diff_options = nil) def diffs(diff_options = nil)
if without_files? && comparison = diff_refs.compare_in(project) if without_files? && comparison = diff_refs&.compare_in(project)
# It should fetch the repository when diffs are cleaned by the system. # It should fetch the repository when diffs are cleaned by the system.
# We don't keep these for storage overload purposes. # We don't keep these for storage overload purposes.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/37639 # See https://gitlab.com/gitlab-org/gitlab-ce/issues/37639
......
---
title: Render MR page when diffs cannot be fetched from the database or the git repository
merge_request: 20680
author:
type: fixed
...@@ -53,6 +53,23 @@ describe Projects::MergeRequestsController do ...@@ -53,6 +53,23 @@ describe Projects::MergeRequestsController do
it_behaves_like "loads labels", :show it_behaves_like "loads labels", :show
describe 'as html' do describe 'as html' do
context 'when diff files were cleaned' do
render_views
it 'renders page when diff size is not persisted and diff_refs does not exist' do
diff = merge_request.merge_request_diff
diff.clean!
diff.update!(real_size: nil,
start_commit_sha: nil,
base_commit_sha: nil)
go(format: :html)
expect(response).to be_success
end
end
it "renders merge request page" do it "renders merge request page" do
go(format: :html) go(format: :html)
......
...@@ -82,6 +82,14 @@ describe MergeRequestDiff do ...@@ -82,6 +82,14 @@ describe MergeRequestDiff do
diff.diffs diff.diffs
end end
it 'returns persisted diffs if diff refs does not exist' do
expect(diff).to receive(:load_diffs)
diff.update!(start_commit_sha: nil, base_commit_sha: nil)
diff.diffs
end
end end
end end
......
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