Skip to content

Commit

Permalink
I18n pluralization errors (mastodon#24963)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed May 12, 2023
1 parent 433ab0c commit 679aca4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ GEM
httplog (1.6.2)
rack (>= 2.0)
rainbow (>= 2.0.0)
i18n (1.12.0)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
i18n-tasks (1.0.12)
activesupport (>= 4.0.2)
Expand Down
37 changes: 37 additions & 0 deletions spec/views/shared/_error_messages.html.haml_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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

0 comments on commit 679aca4

Please sign in to comment.