diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 12:09:43 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-16 12:09:43 +0300 |
commit | 984357420ab0a91e8c73f04393a83b5ade63b460 (patch) | |
tree | 48f35fa1c4e55a6fbd59576a0f243e317c109ee1 /spec/uploaders | |
parent | 6b9b8a52ba3ffc3ec3f20d36e33af3dace089e99 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/object_storage_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index a0583c860cd..c73a9a7aab1 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -210,6 +210,27 @@ RSpec.describe ObjectStorage do end end + describe '#use_open_file' do + context 'when file is stored locally' do + it "returns the file" do + expect { |b| uploader.use_open_file(&b) }.to yield_with_args(an_instance_of(ObjectStorage::Concern::OpenFile)) + end + end + + context 'when file is stored remotely' do + let(:store) { described_class::Store::REMOTE } + + before do + stub_artifacts_object_storage + stub_request(:get, %r{s3.amazonaws.com/#{uploader.path}}).to_return(status: 200, body: '') + end + + it "returns the file" do + expect { |b| uploader.use_open_file(&b) }.to yield_with_args(an_instance_of(ObjectStorage::Concern::OpenFile)) + end + end + end + describe '#migrate!' do subject { uploader.migrate!(new_store) } @@ -844,4 +865,19 @@ RSpec.describe ObjectStorage do end end end + + describe 'OpenFile' do + subject { ObjectStorage::Concern::OpenFile.new(file) } + + let(:file) { double(read: true, size: true, path: true) } + + it 'delegates read and size methods' do + expect(subject.read).to eq(true) + expect(subject.size).to eq(true) + end + + it 'does not delegate path method' do + expect { subject.path }.to raise_error(NoMethodError) + end + end end |