summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/i18n/metadata_entry_spec.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-09-01 14:30:43 +0000
committerDouwe Maan <douwe@gitlab.com>2017-09-01 14:30:43 +0000
commitdceb2112d2ec34a947edfb2c9ec4d286fea4661a (patch)
treef1d2f5f7724a6560d88d2a848a0cb6f504aafdb1 /spec/lib/gitlab/i18n/metadata_entry_spec.rb
parentba3cfd07dd9bd0de57239d5a748d98f783507d92 (diff)
parent4761235f6944d1627346ca835a192c1ed32f745e (diff)
downloadgitlab-ce-dceb2112d2ec34a947edfb2c9ec4d286fea4661a.tar.gz
Merge branch 'bvl-validate-po-files' into 'master'
Validate PO files in static analysis See merge request !13000
Diffstat (limited to 'spec/lib/gitlab/i18n/metadata_entry_spec.rb')
-rw-r--r--spec/lib/gitlab/i18n/metadata_entry_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/lib/gitlab/i18n/metadata_entry_spec.rb b/spec/lib/gitlab/i18n/metadata_entry_spec.rb
new file mode 100644
index 00000000000..ab71d6454a9
--- /dev/null
+++ b/spec/lib/gitlab/i18n/metadata_entry_spec.rb
@@ -0,0 +1,51 @@
+require 'spec_helper'
+
+describe Gitlab::I18n::MetadataEntry do
+ describe '#expected_plurals' do
+ it 'returns the number of plurals' do
+ data = {
+ msgid: "",
+ msgstr: [
+ "",
+ "Project-Id-Version: gitlab 1.0.0\\n",
+ "Report-Msgid-Bugs-To: \\n",
+ "PO-Revision-Date: 2017-07-13 12:10-0500\\n",
+ "Language-Team: Spanish\\n",
+ "Language: es\\n",
+ "MIME-Version: 1.0\\n",
+ "Content-Type: text/plain; charset=UTF-8\\n",
+ "Content-Transfer-Encoding: 8bit\\n",
+ "Plural-Forms: nplurals=2; plural=n != 1;\\n",
+ "Last-Translator: Bob Van Landuyt <bob@gitlab.com>\\n",
+ "X-Generator: Poedit 2.0.2\\n"
+ ]
+ }
+ entry = described_class.new(data)
+
+ expect(entry.expected_plurals).to eq(2)
+ end
+
+ it 'returns 0 for the POT-metadata' do
+ data = {
+ msgid: "",
+ msgstr: [
+ "",
+ "Project-Id-Version: gitlab 1.0.0\\n",
+ "Report-Msgid-Bugs-To: \\n",
+ "PO-Revision-Date: 2017-07-13 12:10-0500\\n",
+ "Language-Team: Spanish\\n",
+ "Language: es\\n",
+ "MIME-Version: 1.0\\n",
+ "Content-Type: text/plain; charset=UTF-8\\n",
+ "Content-Transfer-Encoding: 8bit\\n",
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n",
+ "Last-Translator: Bob Van Landuyt <bob@gitlab.com>\\n",
+ "X-Generator: Poedit 2.0.2\\n"
+ ]
+ }
+ entry = described_class.new(data)
+
+ expect(entry.expected_plurals).to eq(0)
+ end
+ end
+end