summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorMark Chao <mchao@gitlab.com>2018-10-04 17:16:51 +0800
committerMark Chao <mchao@gitlab.com>2018-10-30 15:44:55 +0800
commita4ba973e24ef6767d635c0291c9b6ce8085aef28 (patch)
tree28efdf13b834db6267fd8bd64d798d8e694b0109 /spec/models
parentbc14e4ed1024efa1e0a411bd59e1339fb1af20c0 (diff)
downloadgitlab-ce-a4ba973e24ef6767d635c0291c9b6ce8085aef28.tar.gz
Allow FoundBlob to access language from gitattributes
Extract language_from_git_attributes as a concern so it can ben included in two blob classes.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/blob_spec.rb16
-rw-r--r--spec/models/concerns/blob_language_from_git_attributes_spec.rb25
2 files changed, 25 insertions, 16 deletions
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb
index da3b29dffb6..81e35e6c931 100644
--- a/spec/models/blob_spec.rb
+++ b/spec/models/blob_spec.rb
@@ -224,22 +224,6 @@ describe Blob do
end
end
- describe '#language_from_gitattributes' do
- subject(:blob) { fake_blob(path: 'file.md') }
-
- it 'returns return value from gitattribute' do
- expect(blob.project.repository).to receive(:gitattribute).with(blob.path, 'gitlab-language').and_return('erb?parent=json')
-
- expect(blob.language_from_gitattributes).to eq('erb?parent=json')
- end
-
- it 'returns nil if project is absent' do
- allow(blob).to receive(:project).and_return(nil)
-
- expect(blob.language_from_gitattributes).to eq(nil)
- end
- end
-
describe '#simple_viewer' do
context 'when the blob is empty' do
it 'returns an empty viewer' do
diff --git a/spec/models/concerns/blob_language_from_git_attributes_spec.rb b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
new file mode 100644
index 00000000000..7f05073b08e
--- /dev/null
+++ b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe BlobLanguageFromGitAttributes do
+ include FakeBlobHelpers
+
+ let(:project) { build(:project, :repository) }
+
+ describe '#language_from_gitattributes' do
+ subject(:blob) { fake_blob(path: 'file.md') }
+
+ it 'returns return value from gitattribute' do
+ expect(blob.project.repository).to receive(:gitattribute).with(blob.path, 'gitlab-language').and_return('erb?parent=json')
+
+ expect(blob.language_from_gitattributes).to eq('erb?parent=json')
+ end
+
+ it 'returns nil if project is absent' do
+ allow(blob).to receive(:project).and_return(nil)
+
+ expect(blob.language_from_gitattributes).to eq(nil)
+ end
+ end
+end