1
0
Fork 1
mirror of https://github.com/mastodon/mastodon.git synced 2024-12-22 09:08:24 +00:00

Replace i18n view spec with helper spec ()

This commit is contained in:
Matt Jankowski 2023-05-15 11:25:04 -04:00 committed by GitHub
parent 2e1c6e93ad
commit b84bc2de5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 37 deletions

35
spec/locales/i18n_spec.rb Normal file
View file

@ -0,0 +1,35 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'I18n' do
describe 'Pluralizing locale translations' do
subject { I18n.t('generic.validation_errors', count: 1) }
context 'with the `en` locale which has `one` and `other` plural values' do
around do |example|
I18n.with_locale(:en) do
example.run
end
end
it 'translates to `en` correctly and without error' do
expect { subject }.to_not raise_error
expect(subject).to match(/the error below/)
end
end
context 'with the `my` locale which has only `other` plural value' do
around do |example|
I18n.with_locale(:my) do
example.run
end
end
it 'translates to `my` correctly and without error' do
expect { subject }.to_not raise_error
expect(subject).to match(/1/)
end
end
end
end

View file

@ -1,37 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'shared/_error_messages.html.haml' do
let(:status) { Status.new }
before { status.errors.add :base, :invalid }
context 'with a locale that has `one` and `other` plural values' do
around do |example|
I18n.with_locale(:en) do
example.run
end
end
it 'renders the view with one error' do
render partial: 'shared/error_messages', locals: { object: status }
expect(rendered).to match(/is invalid/)
end
end
context 'with a locale that has only `other` plural value' do
around do |example|
I18n.with_locale(:my) do
example.run
end
end
it 'renders the view with one error' do
render partial: 'shared/error_messages', locals: { object: status }
expect(rendered).to match(/is invalid/)
end
end
end