Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/i18n/translation_entry_spec.rb')
-rw-r--r--spec/lib/gitlab/i18n/translation_entry_spec.rb112
1 files changed, 19 insertions, 93 deletions
diff --git a/spec/lib/gitlab/i18n/translation_entry_spec.rb b/spec/lib/gitlab/i18n/translation_entry_spec.rb
index 2c95b0b0124..f05346d07d3 100644
--- a/spec/lib/gitlab/i18n/translation_entry_spec.rb
+++ b/spec/lib/gitlab/i18n/translation_entry_spec.rb
@@ -6,7 +6,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#singular_translation' do
it 'returns the normal `msgstr` for translations without plural' do
data = { msgid: 'Hello world', msgstr: 'Bonjour monde' }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.singular_translation).to eq('Bonjour monde')
end
@@ -18,7 +18,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
'msgstr[0]' => 'Bonjour monde',
'msgstr[1]' => 'Bonjour mondes'
}
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.singular_translation).to eq('Bonjour monde')
end
@@ -27,7 +27,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#all_translations' do
it 'returns all translations for singular translations' do
data = { msgid: 'Hello world', msgstr: 'Bonjour monde' }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.all_translations).to eq(['Bonjour monde'])
end
@@ -39,7 +39,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
'msgstr[0]' => 'Bonjour monde',
'msgstr[1]' => 'Bonjour mondes'
}
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.all_translations).to eq(['Bonjour monde', 'Bonjour mondes'])
end
@@ -52,7 +52,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
msgid_plural: 'Hello worlds',
'msgstr[0]' => 'Bonjour monde'
}
- entry = described_class.new(entry_data: data, nplurals: 1, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 1)
expect(entry.plural_translations).to eq(['Bonjour monde'])
end
@@ -65,7 +65,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
'msgstr[1]' => 'Bonjour mondes',
'msgstr[2]' => 'Bonjour tous les mondes'
}
- entry = described_class.new(entry_data: data, nplurals: 3, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 3)
expect(entry.plural_translations).to eq(['Bonjour mondes', 'Bonjour tous les mondes'])
end
@@ -77,7 +77,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
msgid: 'hello world',
msgstr: 'hello'
}
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry).to have_singular_translation
end
@@ -89,7 +89,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
"msgstr[0]" => 'hello world',
"msgstr[1]" => 'hello worlds'
}
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry).to have_singular_translation
end
@@ -100,7 +100,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
msgid_plural: 'hello worlds',
"msgstr[0]" => 'hello worlds'
}
- entry = described_class.new(entry_data: data, nplurals: 1, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 1)
expect(entry).not_to have_singular_translation
end
@@ -109,7 +109,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#msgid_contains_newlines' do
it 'is true when the msgid is an array' do
data = { msgid: %w(hello world) }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.msgid_has_multiple_lines?).to be_truthy
end
@@ -118,7 +118,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#plural_id_contains_newlines' do
it 'is true when the msgid is an array' do
data = { msgid_plural: %w(hello world) }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.plural_id_has_multiple_lines?).to be_truthy
end
@@ -127,7 +127,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#translations_contain_newlines' do
it 'is true when the msgid is an array' do
data = { msgstr: %w(hello world) }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry.translations_have_multiple_lines?).to be_truthy
end
@@ -135,7 +135,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#contains_unescaped_chars' do
let(:data) { { msgid: '' } }
- let(:entry) { described_class.new(entry_data: data, nplurals: 2, html_allowed: nil) }
+ let(:entry) { described_class.new(entry_data: data, nplurals: 2) }
it 'is true when the msgid is an array' do
string = '「100%確定」'
@@ -177,7 +177,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#msgid_contains_unescaped_chars' do
it 'is true when the msgid contains a `%`' do
data = { msgid: '「100%確定」' }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
expect(entry.msgid_contains_unescaped_chars?).to be_truthy
@@ -187,7 +187,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#plural_id_contains_unescaped_chars' do
it 'is true when the plural msgid contains a `%`' do
data = { msgid_plural: '「100%確定」' }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
expect(entry.plural_id_contains_unescaped_chars?).to be_truthy
@@ -197,7 +197,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
describe '#translations_contain_unescaped_chars' do
it 'is true when the translation contains a `%`' do
data = { msgstr: '「100%確定」' }
- entry = described_class.new(entry_data: data, nplurals: 2, html_allowed: nil)
+ entry = described_class.new(entry_data: data, nplurals: 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
expect(entry.translations_contain_unescaped_chars?).to be_truthy
@@ -205,7 +205,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
end
describe '#msgid_contains_potential_html?' do
- subject(:entry) { described_class.new(entry_data: data, nplurals: 2, html_allowed: nil) }
+ subject(:entry) { described_class.new(entry_data: data, nplurals: 2) }
context 'when there are no angle brackets in the msgid' do
let(:data) { { msgid: 'String with no brackets' } }
@@ -225,7 +225,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
end
describe '#plural_id_contains_potential_html?' do
- subject(:entry) { described_class.new(entry_data: data, nplurals: 2, html_allowed: nil) }
+ subject(:entry) { described_class.new(entry_data: data, nplurals: 2) }
context 'when there are no angle brackets in the plural_id' do
let(:data) { { msgid_plural: 'String with no brackets' } }
@@ -245,7 +245,7 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
end
describe '#translations_contain_potential_html?' do
- subject(:entry) { described_class.new(entry_data: data, nplurals: 2, html_allowed: nil) }
+ subject(:entry) { described_class.new(entry_data: data, nplurals: 2) }
context 'when there are no angle brackets in the translations' do
let(:data) { { msgstr: 'This string has no angle brackets' } }
@@ -263,78 +263,4 @@ RSpec.describe Gitlab::I18n::TranslationEntry do
end
end
end
-
- describe '#msgid_html_allowed?' do
- subject(:entry) do
- described_class.new(entry_data: { msgid: 'String with a <strong>' }, nplurals: 2, html_allowed: html_todo)
- end
-
- context 'when the html in the string is in the todolist' do
- let(:html_todo) { { 'plural_id' => nil, 'translations' => [] } }
-
- it 'returns true' do
- expect(entry.msgid_html_allowed?).to be true
- end
- end
-
- context 'when the html in the string is not in the todolist' do
- let(:html_todo) { nil }
-
- it 'returns false' do
- expect(entry.msgid_html_allowed?).to be false
- end
- end
- end
-
- describe '#plural_id_html_allowed?' do
- subject(:entry) do
- described_class.new(entry_data: { msgid_plural: 'String with many <strong>' }, nplurals: 2, html_allowed: html_todo)
- end
-
- context 'when the html in the string is in the todolist' do
- let(:html_todo) { { 'plural_id' => 'String with many <strong>', 'translations' => [] } }
-
- it 'returns true' do
- expect(entry.plural_id_html_allowed?).to be true
- end
- end
-
- context 'when the html in the string is not in the todolist' do
- let(:html_todo) { { 'plural_id' => 'String with some <strong>', 'translations' => [] } }
-
- it 'returns false' do
- expect(entry.plural_id_html_allowed?).to be false
- end
- end
- end
-
- describe '#translations_html_allowed?' do
- subject(:entry) do
- described_class.new(entry_data: { msgstr: 'String with a <strong>' }, nplurals: 2, html_allowed: html_todo)
- end
-
- context 'when the html in the string is in the todolist' do
- let(:html_todo) { { 'plural_id' => nil, 'translations' => ['String with a <strong>'] } }
-
- it 'returns true' do
- expect(entry.translations_html_allowed?).to be true
- end
- end
-
- context 'when the html in the string is not in the todolist' do
- let(:html_todo) { { 'plural_id' => nil, 'translations' => ['String with a different <strong>'] } }
-
- it 'returns false' do
- expect(entry.translations_html_allowed?).to be false
- end
- end
-
- context 'when the todolist only has the msgid' do
- let(:html_todo) { { 'plural_id' => nil, 'translations' => nil } }
-
- it 'returns false' do
- expect(entry.translations_html_allowed?).to be false
- end
- end
- end
end