Skip to content

Commit

Permalink
Adds specs for state#display_name for localization
Browse files Browse the repository at this point in the history
  • Loading branch information
the-spectator committed Oct 13, 2020
1 parent c83357d commit a59ef08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spec/localizer_test_model_deprecated_style.yml
Expand Up @@ -4,3 +4,10 @@ en:
localizer_test_model:
aasm_state:
opened: "It's open now!"

fr:
activerecord:
attributes:
localizer_test_model:
aasm_state:
opened: "C'est ouvert maintenant!"
6 changes: 6 additions & 0 deletions spec/localizer_test_model_new_style.yml
Expand Up @@ -3,3 +3,9 @@ en:
attributes:
localizer_test_model:
aasm_state/opened: "It's open now!"

fr:
activerecord:
attributes:
localizer_test_model:
aasm_state/opened: "C'est ouvert maintenant!"
8 changes: 8 additions & 0 deletions spec/models/active_record/localizer_test_model.rb
Expand Up @@ -24,11 +24,19 @@ class LocalizerTestModel < ActiveRecord::Base
state = LocalizerTestModel.aasm.states.detect {|s| s == :opened}
expect(state.localized_name).to eq("It's open now!")
expect(state.human_name).to eq("It's open now!")
expect(state.display_name).to eq("It's open now!")

I18n.with_locale(:fr) do
expect(state.localized_name).to eq("C'est ouvert maintenant!")
expect(state.human_name).to eq("C'est ouvert maintenant!")
expect(state.display_name).to eq("C'est ouvert maintenant!")
end
end

it 'should use fallback' do
state = LocalizerTestModel.aasm.states.detect {|s| s == :closed}
expect(state.localized_name).to eq('Closed')
expect(state.human_name).to eq('Closed')
expect(state.display_name).to eq('Closed')
end
end

0 comments on commit a59ef08

Please sign in to comment.