diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-04-25 15:22:56 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-04-27 12:23:26 -0500 |
commit | 964e7d206b2c9ce0c884ee5c13fafa3763a142a2 (patch) | |
tree | 32ea77b2d528bef67b4ed526f8b5520ffea666ba /spec/support/helpers | |
parent | b73b16798dd0fe402df42a1e706f3b1034c22270 (diff) | |
download | gitlab-ce-964e7d206b2c9ce0c884ee5c13fafa3763a142a2.tar.gz |
Add specs
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/fake_blob_helpers.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/support/helpers/fake_blob_helpers.rb b/spec/support/helpers/fake_blob_helpers.rb new file mode 100644 index 00000000000..b29af732ad3 --- /dev/null +++ b/spec/support/helpers/fake_blob_helpers.rb @@ -0,0 +1,50 @@ +module FakeBlobHelpers + class FakeBlob + include Linguist::BlobHelper + + 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 mode + nil + end + + def id + 0 + end + + def binary? + @binary + end + + def load_all_data!(repository) + # No-op + end + + def lfs_pointer? + @lfs_pointer + end + + def truncated? + false + end + end + + def fake_blob(**kwargs) + Blob.decorate(FakeBlob.new(**kwargs), project) + end +end |