diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-13 03:55:49 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2018-03-16 00:49:01 +0300 |
commit | 1f5e809c047d9561fe03d04c51b1dc4fffd95e04 (patch) | |
tree | d8bd865e43e592e846adcc1a3de02e36c4fd982a /spec/services/files | |
parent | ca66a04ffec2e311e72b5bdd2c68d3286ef6631c (diff) |
Use correct encoding with Lfs::FileTransfromer
Diffstat (limited to 'spec/services/files')
-rw-r--r-- | spec/services/files/multi_service_spec.rb | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb index 7b47df32b43..0dc92762d64 100644 --- a/spec/services/files/multi_service_spec.rb +++ b/spec/services/files/multi_service_spec.rb @@ -16,18 +16,18 @@ describe Files::MultiService do Gitlab::Git::Commit.last_for_path(project.repository, branch_name, original_file_path).sha end - let(:actions) do - [ - { - action: action, - file_path: new_file_path, - previous_path: original_file_path, - content: file_content, - last_commit_id: original_commit_id - } - ] + let(:default_action) do + { + action: action, + file_path: new_file_path, + previous_path: original_file_path, + content: file_content, + last_commit_id: original_commit_id + } end + let(:actions) { [default_action] } + let(:commit_params) do { commit_message: "Update File", @@ -135,6 +135,26 @@ describe Files::MultiService do expect(LfsObject.last.file.read).to eq file_content end + context 'with base64 encoded content' do + let(:raw_file_content) { 'Raw content' } + let(:file_content) { Base64.encode64(raw_file_content) } + let(:actions) { [default_action.merge(encoding: 'base64')] } + + 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 raw_file_content + end + end + it 'links the LfsObject to the project' do expect do subject.execute |