summaryrefslogtreecommitdiff
path: root/spec/models/snippet_blob_spec.rb
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-05-03 13:03:57 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-05-03 13:03:57 +0100
commit7788118c3d059ef93bcc49c1b6b6ec7d72faf8b5 (patch)
tree6642a358083285d90234f8d4ba27d61bfd9448bd /spec/models/snippet_blob_spec.rb
parent637ed8a21e9f9457d1b194f9c591a0813c20cc3e (diff)
parentcac04fbd777ff992bbd92e9ae3cded01d45b07d0 (diff)
downloadgitlab-ce-7788118c3d059ef93bcc49c1b6b6ec7d72faf8b5.tar.gz
Merge remote-tracking branch 'origin/master' into add-sentry-js-again-with-vue
Diffstat (limited to 'spec/models/snippet_blob_spec.rb')
-rw-r--r--spec/models/snippet_blob_spec.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/models/snippet_blob_spec.rb b/spec/models/snippet_blob_spec.rb
new file mode 100644
index 00000000000..120b390586b
--- /dev/null
+++ b/spec/models/snippet_blob_spec.rb
@@ -0,0 +1,47 @@
+require 'spec_helper'
+
+describe SnippetBlob, models: true do
+ let(:snippet) { create(:snippet) }
+
+ subject { described_class.new(snippet) }
+
+ describe '#id' do
+ it 'returns the snippet ID' do
+ expect(subject.id).to eq(snippet.id)
+ end
+ end
+
+ describe '#name' do
+ it 'returns the snippet file name' do
+ expect(subject.name).to eq(snippet.file_name)
+ end
+ end
+
+ describe '#size' do
+ it 'returns the data size' do
+ expect(subject.size).to eq(subject.data.bytesize)
+ end
+ end
+
+ describe '#data' do
+ it 'returns the snippet content' do
+ expect(subject.data).to eq(snippet.content)
+ end
+ end
+
+ describe '#rendered_markup' do
+ context 'when the content is GFM' do
+ let(:snippet) { create(:snippet, file_name: 'file.md') }
+
+ it 'returns the rendered GFM' do
+ expect(subject.rendered_markup).to eq(snippet.content_html)
+ end
+ end
+
+ context 'when the content is not GFM' do
+ it 'returns nil' do
+ expect(subject.rendered_markup).to be_nil
+ end
+ end
+ end
+end