diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-01-11 23:12:34 +0000 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-15 02:39:08 +0000 |
commit | 1baac9211238f60d2d2a50cccd0bea6979bfa6ba (patch) | |
tree | 7f07f3d1eb65f31f01c52973d115d349a95e3de2 /spec/services/files | |
parent | ffb1c65b0ba7fa8a4ea7e128cb47449f04837869 (diff) | |
download | gitlab-ce-1baac9211238f60d2d2a50cccd0bea6979bfa6ba.tar.gz |
Multi-file upload and Commit API obey LFS filters
Updates Files::MultiService for the commits API which is in turn used by the
multi-file upload web UI
Ensures that files which should be in LFS are transformed into LFS pointers
Uses Lfs::Transformer which then links LfsObjectProjects on success
Diffstat (limited to 'spec/services/files')
-rw-r--r-- | spec/services/files/multi_service_spec.rb | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb index b9971776b33..7b47df32b43 100644 --- a/spec/services/files/multi_service_spec.rb +++ b/spec/services/files/multi_service_spec.rb @@ -4,10 +4,12 @@ describe Files::MultiService do subject { described_class.new(project, user, commit_params) } let(:project) { create(:project, :repository) } + let(:repository) { project.repository } let(:user) { create(:user) } let(:branch_name) { project.default_branch } let(:original_file_path) { 'files/ruby/popen.rb' } let(:new_file_path) { 'files/ruby/popen.rb' } + let(:file_content) { 'New content' } let(:action) { 'update' } let!(:original_commit_id) do @@ -20,7 +22,7 @@ describe Files::MultiService do action: action, file_path: new_file_path, previous_path: original_file_path, - content: 'New content', + content: file_content, last_commit_id: original_commit_id } ] @@ -110,6 +112,36 @@ describe Files::MultiService do end end + context 'when creating a file matching an LFS filter' do + let(:action) { 'create' } + let(:branch_name) { 'lfs' } + let(:new_file_path) { 'test_file.lfs' } + + before do + allow(project).to receive(:lfs_enabled?).and_return(true) + end + + it 'creates an LFS pointer' do + subject.execute + + blob = repository.blob_at('lfs', new_file_path) + + expect(blob.data).to start_with('version https://git-lfs.github.com/spec/v1') + end + + it "creates an LfsObject with the file's content" do + subject.execute + + expect(LfsObject.last.file.read).to eq file_content + end + + it 'links the LfsObject to the project' do + expect do + subject.execute + end.to change { project.lfs_objects.count }.by(1) + end + end + context 'when file status validation is skipped' do let(:action) { 'create' } let(:new_file_path) { 'files/ruby/new_file.rb' } |