Commit 1e4100cc authored by Stan Hu's avatar Stan Hu

Merge branch 'id-remove-file-type-for-diff-viewers' into 'master'

Remove file type checking for diff viewers

See merge request gitlab-org/gitlab!22471
parents 27625667 972775f4
......@@ -4,7 +4,7 @@ module DiffViewer
class Base
PARTIAL_PATH_PREFIX = 'projects/diffs/viewers'
class_attribute :partial_name, :type, :extensions, :file_types, :binary, :switcher_icon, :switcher_title
class_attribute :partial_name, :type, :extensions, :binary, :switcher_icon, :switcher_title
# These limits relate to the sum of the old and new blob sizes.
# Limits related to the actual size of the diff are enforced in Gitlab::Diff::File.
......@@ -50,7 +50,6 @@ module DiffViewer
return true if blob.nil?
return false if verify_binary && binary? != blob.binary_in_repo?
return true if extensions&.include?(blob.extension)
return true if file_types&.include?(blob.file_type)
false
end
......
......@@ -43,34 +43,6 @@ describe DiffViewer::Base do
end
end
context 'when the file type is supported' do
let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
let(:diff_file) { commit.diffs.diff_file_with_new_path('LICENSE') }
before do
viewer_class.file_types = %i(license)
viewer_class.binary = false
end
context 'when the binaryness matches' do
it 'returns true' do
expect(viewer_class.can_render?(diff_file)).to be_truthy
end
end
context 'when the binaryness does not match' do
before do
allow_next_instance_of(Blob) do |instance|
allow(instance).to receive(:binary_in_repo?).and_return(true)
end
end
it 'returns false' do
expect(viewer_class.can_render?(diff_file)).to be_falsey
end
end
end
context 'when the extension and file type are not supported' do
it 'returns false' do
expect(viewer_class.can_render?(diff_file)).to be_falsey
......
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