Commit b2608d2a authored by Gabriel Mazetto's avatar Gabriel Mazetto

Rename uploader mentions to retriever

parent c20672b4
...@@ -17,11 +17,11 @@ module Geo ...@@ -17,11 +17,11 @@ module Geo
def execute def execute
return unless decoded_authorization.present? && jwt_scope_valid? return unless decoded_authorization.present? && jwt_scope_valid?
uploader.execute retriever.execute
end end
def uploader def retriever
uploader_klass.new(object_db_id, decoded_authorization) retriever_klass.new(object_db_id, decoded_authorization)
end end
private private
...@@ -36,7 +36,7 @@ module Geo ...@@ -36,7 +36,7 @@ module Geo
end end
end end
def uploader_klass def retriever_klass
return Gitlab::Geo::Replication::FileRetriever if user_upload? return Gitlab::Geo::Replication::FileRetriever if user_upload?
return Gitlab::Geo::Replication::JobArtifactRetriever if job_artifact? return Gitlab::Geo::Replication::JobArtifactRetriever if job_artifact?
return Gitlab::Geo::Replication::LfsRetriever if lfs? return Gitlab::Geo::Replication::LfsRetriever if lfs?
......
...@@ -2,10 +2,10 @@ require 'spec_helper' ...@@ -2,10 +2,10 @@ require 'spec_helper'
describe Gitlab::Geo::Replication::FileRetriever, :geo do describe Gitlab::Geo::Replication::FileRetriever, :geo do
shared_examples_for 'returns necessary params for sending a file from an API endpoint' do shared_examples_for 'returns necessary params for sending a file from an API endpoint' do
subject { @subject ||= uploader.execute } subject { @subject ||= retriever.execute }
context 'when the upload exists' do context 'when the upload exists' do
let(:uploader) { described_class.new(upload.id, message) } let(:retriever) { described_class.new(upload.id, message) }
before do before do
expect(Upload).to receive(:find_by).with(id: upload.id).and_return(upload) expect(Upload).to receive(:find_by).with(id: upload.id).and_return(upload)
......
...@@ -2,8 +2,8 @@ require 'spec_helper' ...@@ -2,8 +2,8 @@ require 'spec_helper'
describe Gitlab::Geo::Replication::JobArtifactRetriever, :geo do describe Gitlab::Geo::Replication::JobArtifactRetriever, :geo do
context '#execute' do context '#execute' do
let(:uploader) { described_class.new(job_artifact.id, {}) } let(:retriever) { described_class.new(job_artifact.id, {}) }
subject { uploader.execute } subject { retriever.execute }
context 'when the job artifact exists' do context 'when the job artifact exists' do
before do before do
...@@ -34,7 +34,7 @@ describe Gitlab::Geo::Replication::JobArtifactRetriever, :geo do ...@@ -34,7 +34,7 @@ describe Gitlab::Geo::Replication::JobArtifactRetriever, :geo do
end end
it 'logs the missing file' do it 'logs the missing file' do
expect(uploader).to receive(:log_error).with("Could not upload job artifact because it does not have a file", id: job_artifact.id) expect(retriever).to receive(:log_error).with("Could not upload job artifact because it does not have a file", id: job_artifact.id)
subject subject
end end
......
...@@ -2,10 +2,10 @@ require 'spec_helper' ...@@ -2,10 +2,10 @@ require 'spec_helper'
describe Gitlab::Geo::Replication::LfsRetriever, :geo do describe Gitlab::Geo::Replication::LfsRetriever, :geo do
context '#execute' do context '#execute' do
subject { uploader.execute } subject { retriever.execute }
context 'when the LFS object exists' do context 'when the LFS object exists' do
let(:uploader) { described_class.new(lfs_object.id, message) } let(:retriever) { described_class.new(lfs_object.id, message) }
before do before do
expect(LfsObject).to receive(:find_by).with(id: lfs_object.id).and_return(lfs_object) expect(LfsObject).to receive(:find_by).with(id: lfs_object.id).and_return(lfs_object)
...@@ -39,7 +39,7 @@ describe Gitlab::Geo::Replication::LfsRetriever, :geo do ...@@ -39,7 +39,7 @@ describe Gitlab::Geo::Replication::LfsRetriever, :geo do
end end
it 'logs the missing file' do it 'logs the missing file' do
expect(uploader).to receive(:log_error).with("Could not upload LFS object because it does not have a file", id: lfs_object.id) expect(retriever).to receive(:log_error).with("Could not upload LFS object because it does not have a file", id: lfs_object.id)
subject subject
end end
...@@ -47,7 +47,7 @@ describe Gitlab::Geo::Replication::LfsRetriever, :geo do ...@@ -47,7 +47,7 @@ describe Gitlab::Geo::Replication::LfsRetriever, :geo do
end end
context 'when the LFS object does not exist' do context 'when the LFS object does not exist' do
let(:uploader) { described_class.new(10000, {}) } let(:retriever) { described_class.new(10000, {}) }
it 'returns an error hash' do it 'returns an error hash' do
expect(subject).to eq(code: :not_found, message: 'LFS object not found') expect(subject).to eq(code: :not_found, message: 'LFS object not found')
......
...@@ -12,25 +12,25 @@ describe Geo::FileUploadService do ...@@ -12,25 +12,25 @@ describe Geo::FileUploadService do
stub_current_geo_node(node) stub_current_geo_node(node)
end end
describe '#uploader' do describe '#retriever' do
Gitlab::Geo::Replication::USER_UPLOADS_OBJECT_TYPES.each do |file_type| Gitlab::Geo::Replication::USER_UPLOADS_OBJECT_TYPES.each do |file_type|
it "returns a FileUploader given type is #{file_type}" do it "returns a FileRetriever given type is #{file_type}" do
subject = described_class.new({ type: file_type, id: 1 }, 'request-data') subject = described_class.new({ type: file_type, id: 1 }, 'request-data')
expect(subject.uploader).to be_a(Gitlab::Geo::Replication::FileRetriever) expect(subject.retriever).to be_a(Gitlab::Geo::Replication::FileRetriever)
end end
end end
it "returns a LfsUploader given object_type is lfs" do it "returns a LfsRetriever given object_type is lfs" do
subject = described_class.new({ type: 'lfs', id: 1 }, 'request-data') subject = described_class.new({ type: 'lfs', id: 1 }, 'request-data')
expect(subject.uploader).to be_a(Gitlab::Geo::Replication::LfsRetriever) expect(subject.retriever).to be_a(Gitlab::Geo::Replication::LfsRetriever)
end end
it "returns a JobArtifactUploader given object_type is job_artifact" do it "returns a JobArtifactRetriever given object_type is job_artifact" do
subject = described_class.new({ type: 'job_artifact', id: 1 }, 'request-data') subject = described_class.new({ type: 'job_artifact', id: 1 }, 'request-data')
expect(subject.uploader).to be_a(Gitlab::Geo::Replication::JobArtifactRetriever) expect(subject.retriever).to be_a(Gitlab::Geo::Replication::JobArtifactRetriever)
end end
end end
......
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