summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/language_data_spec.rb
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-08-03 15:24:26 +0200
committerStan Hu <stanhu@gmail.com>2018-10-12 17:17:30 -0700
commit399056ed783e12337a9c47b06b4aae021198f1cd (patch)
tree21645fa92b300735c5431608e17f3e34b34ce653 /spec/lib/gitlab/language_data_spec.rb
parenta5ecb5bbdac05c3b1a96ecb918ce6a4ceed37d75 (diff)
downloadgitlab-ce-399056ed783e12337a9c47b06b4aae021198f1cd.tar.gz
Remove dependencies on Linguist
This saves about 128 MB of baseline RAM usage per Unicorn and Sidekiq process (!). Linguist wasn't detecting languages anymore from CE/EE since 9ae8b57467ac8b38f1fa9020a466d94a93cbb9dd. However, Linguist::BlobHelper was still being depended on by BlobLike and others. This removes the Linguist gem, given it isn't required anymore. EscapeUtils were pulled in as dependency, but given Banzai depends on it, it is now added explicitly. Previously, Linguist was used to detect the best ACE mode. Instead, we rely on ACE to guess the best mode based on the file extension.
Diffstat (limited to 'spec/lib/gitlab/language_data_spec.rb')
-rw-r--r--spec/lib/gitlab/language_data_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/lib/gitlab/language_data_spec.rb b/spec/lib/gitlab/language_data_spec.rb
new file mode 100644
index 00000000000..b08150855fe
--- /dev/null
+++ b/spec/lib/gitlab/language_data_spec.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::LanguageData do
+ describe '#extensions' do
+ before do
+ described_class.clear_extensions!
+ end
+
+ it 'loads the extensions once' do
+ expect(YAML).to receive(:load_file).once.and_call_original
+
+ 2.times do
+ expect(described_class.extensions).to be_a(Set)
+ expect(described_class.extensions.count).to be > 0
+ # Sanity check for known extensions
+ expect(described_class.extensions).to include(*%w(.rb .yml .json))
+ end
+ end
+ end
+end