Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 22:00:14 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 22:00:14 +0300
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/services/lfs/file_transformer_spec.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/services/lfs/file_transformer_spec.rb')
-rw-r--r--spec/services/lfs/file_transformer_spec.rb38
1 files changed, 37 insertions, 1 deletions
diff --git a/spec/services/lfs/file_transformer_spec.rb b/spec/services/lfs/file_transformer_spec.rb
index e87c80b4c6c..9d4d8851c2d 100644
--- a/spec/services/lfs/file_transformer_spec.rb
+++ b/spec/services/lfs/file_transformer_spec.rb
@@ -2,7 +2,7 @@
require "spec_helper"
-RSpec.describe Lfs::FileTransformer do
+RSpec.describe Lfs::FileTransformer, feature_category: :git_lfs do
let(:project) { create(:project, :repository, :wiki_repo) }
let(:repository) { project.repository }
let(:file_content) { 'Test file content' }
@@ -13,6 +13,10 @@ RSpec.describe Lfs::FileTransformer do
describe '#new_file' do
context 'with lfs disabled' do
+ before do
+ allow(project).to receive(:lfs_enabled?).and_return(false)
+ end
+
it 'skips gitattributes check' do
expect(repository.raw).not_to receive(:blob_at)
@@ -98,6 +102,38 @@ RSpec.describe Lfs::FileTransformer do
expect(project.lfs_objects_projects.first.repository_type).to eq('design')
end
end
+
+ context 'when content type detection enabled' do
+ let(:detect_content_type) { true }
+
+ before do
+ allow(Gitlab::Utils::MimeType).to receive(:from_string).with(file_content).and_return(mime_type)
+ end
+
+ context 'when mime type detected' do
+ let(:mime_type) { 'image/tiff' }
+
+ it 'creates a file with custom content type' do
+ expect(CarrierWaveStringFile).to receive(:new_file).with({
+ file_content: file_content,
+ filename: anything,
+ content_type: mime_type
+ })
+
+ subject.new_file(file_path, file, detect_content_type: detect_content_type)
+ end
+ end
+
+ context 'when mime type not detected' do
+ let(:mime_type) { nil }
+
+ it 'creates a file with default content type' do
+ expect(CarrierWaveStringFile).to receive(:new).with(file_content)
+
+ subject.new_file(file_path, file, detect_content_type: detect_content_type)
+ end
+ end
+ end
end
context "when doesn't use LFS" do