gitlab-org--gitlab-foss/spec/support/helpers/fake_blob_helpers.rb
Francisco Javier López 5a3e6fdff9
Fixing image lfs bug and also displaying text lfs
This commit, introduced in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/23812,
fixes a problem creating a displaying image diff notes when the image
is stored in LFS. The main problem was that `Gitlab::Diff::File` was
returning an invalid valid in `text?` for this kind of files.

It also fixes a rendering problem with other LFS files, like text
ones. They LFS pointer shouldn't be shown when LFS is enabled
for the project, but they were.
2018-12-27 16:51:07 +01:00

40 lines
744 B
Ruby

module FakeBlobHelpers
class FakeBlob
include BlobLike
attr_reader :path, :size, :data, :lfs_oid, :lfs_size
def initialize(path: 'file.txt', size: 1.kilobyte, data: 'foo', binary: false, lfs: nil)
@path = path
@size = size
@data = data
@binary = binary
@lfs_pointer = lfs.present?
if @lfs_pointer
@lfs_oid = SecureRandom.hex(20)
@lfs_size = 1.megabyte
end
end
alias_method :name, :path
def id
0
end
def binary_in_repo?
@binary
end
def external_storage
:lfs if @lfs_pointer
end
alias_method :external_size, :lfs_size
end
def fake_blob(**kwargs)
Blob.decorate(FakeBlob.new(**kwargs), project)
end
end