gitlab-org--gitlab-foss/spec/support/helpers/fake_blob_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
921 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-04-25 20:22:56 +00:00
module FakeBlobHelpers
class FakeBlob
include BlobLike
2017-04-25 20:22:56 +00:00
attr_reader :path, :size, :data, :lfs_oid, :lfs_size, :mode
2017-04-25 20:22:56 +00:00
def initialize(path: 'file.txt', size: 1.kilobyte, data: 'foo', binary: false, lfs: nil, mode: nil)
2017-04-25 20:22:56 +00:00
@path = path
@size = size
@data = data
@binary = binary
@mode = mode
2017-04-25 20:22:56 +00:00
@lfs_pointer = lfs.present?
if @lfs_pointer
@lfs_oid = SecureRandom.hex(20)
@lfs_size = 1.megabyte
end
end
alias_method :name, :path
def id
"00000000"
end
def commit_id
"11111111"
2017-04-25 20:22:56 +00:00
end
def binary_in_repo?
2017-04-25 20:22:56 +00:00
@binary
end
def external_storage
:lfs if @lfs_pointer
2017-04-25 20:22:56 +00:00
end
alias_method :external_size, :lfs_size
2017-04-25 20:22:56 +00:00
end
def fake_blob(**kwargs)
container = kwargs.delete(:container) || project
Blob.decorate(FakeBlob.new(**kwargs), container)
2017-04-25 20:22:56 +00:00
end
end