summaryrefslogtreecommitdiff
path: root/spec/models/blob_spec.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-04-06 22:00:00 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2017-04-06 22:05:22 +0200
commit37a7b099d6eafc87209368a9fc7f608282b99e08 (patch)
treea2712e439cec8547d84bed2d57d339cb1cd5c502 /spec/models/blob_spec.rb
parent57c353fca7121a120142161b253004f33d815766 (diff)
parent73cb71e41c0ade92b9673a5d74c7dd78679fae91 (diff)
downloadgitlab-ce-optimise-pipelines.tar.gz
Merge remote-tracking branch 'origin/master' into optimise-pipelinesoptimise-pipelines
Diffstat (limited to 'spec/models/blob_spec.rb')
-rw-r--r--spec/models/blob_spec.rb62
1 files changed, 61 insertions, 1 deletions
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb
index 552229e9b07..0f29766db41 100644
--- a/spec/models/blob_spec.rb
+++ b/spec/models/blob_spec.rb
@@ -53,6 +53,20 @@ describe Blob do
end
end
+ describe '#pdf?' do
+ it 'is falsey when file extension is not .pdf' do
+ git_blob = double(name: 'git_blob.txt')
+
+ expect(described_class.decorate(git_blob)).not_to be_pdf
+ end
+
+ it 'is truthy when file extension is .pdf' do
+ git_blob = double(name: 'git_blob.pdf')
+
+ expect(described_class.decorate(git_blob)).to be_pdf
+ end
+ end
+
describe '#ipython_notebook?' do
it 'is falsey when language is not Jupyter Notebook' do
git_blob = double(text?: true, language: double(name: 'JSON'))
@@ -67,6 +81,20 @@ describe Blob do
end
end
+ describe '#sketch?' do
+ it 'is falsey with image extension' do
+ git_blob = Gitlab::Git::Blob.new(name: "design.png")
+
+ expect(described_class.decorate(git_blob)).not_to be_sketch
+ end
+
+ it 'is truthy with sketch extension' do
+ git_blob = Gitlab::Git::Blob.new(name: "design.sketch")
+
+ expect(described_class.decorate(git_blob)).to be_sketch
+ end
+ end
+
describe '#video?' do
it 'is falsey with image extension' do
git_blob = Gitlab::Git::Blob.new(name: 'image.png')
@@ -83,16 +111,33 @@ describe Blob do
end
end
+ describe '#stl?' do
+ it 'is falsey with image extension' do
+ git_blob = Gitlab::Git::Blob.new(name: 'file.png')
+
+ expect(described_class.decorate(git_blob)).not_to be_stl
+ end
+
+ it 'is truthy with STL extension' do
+ git_blob = Gitlab::Git::Blob.new(name: 'file.stl')
+
+ expect(described_class.decorate(git_blob)).to be_stl
+ end
+ end
+
describe '#to_partial_path' do
let(:project) { double(lfs_enabled?: true) }
def stubbed_blob(overrides = {})
overrides.reverse_merge!(
+ name: nil,
image?: false,
language: nil,
lfs_pointer?: false,
svg?: false,
- text?: false
+ text?: false,
+ binary?: false,
+ stl?: false
)
described_class.decorate(double).tap do |blob|
@@ -131,10 +176,25 @@ describe Blob do
expect(blob.to_partial_path(project)).to eq 'download'
end
+ it 'handles PDFs' do
+ blob = stubbed_blob(name: 'blob.pdf', pdf?: true)
+ expect(blob.to_partial_path(project)).to eq 'pdf'
+ end
+
it 'handles iPython notebooks' do
blob = stubbed_blob(text?: true, ipython_notebook?: true)
expect(blob.to_partial_path(project)).to eq 'notebook'
end
+
+ it 'handles Sketch files' do
+ blob = stubbed_blob(text?: true, sketch?: true, binary?: true)
+ expect(blob.to_partial_path(project)).to eq 'sketch'
+ end
+
+ it 'handles STLs' do
+ blob = stubbed_blob(text?: true, stl?: true)
+ expect(blob.to_partial_path(project)).to eq 'stl'
+ end
end
describe '#size_within_svg_limits?' do