From 86c20d519746cf60c9e83552676ba08cbe2b3f2c Mon Sep 17 00:00:00 2001 From: Akshay Birajdar Date: Tue, 13 Oct 2020 22:44:45 +0530 Subject: [PATCH] Adds specs for state#display_name for localization --- spec/localizer_test_model_deprecated_style.yml | 7 +++++++ spec/localizer_test_model_new_style.yml | 6 ++++++ spec/models/active_record/localizer_test_model.rb | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/spec/localizer_test_model_deprecated_style.yml b/spec/localizer_test_model_deprecated_style.yml index 0d7cbd1..481997b 100644 --- a/spec/localizer_test_model_deprecated_style.yml +++ b/spec/localizer_test_model_deprecated_style.yml @@ -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!" diff --git a/spec/localizer_test_model_new_style.yml b/spec/localizer_test_model_new_style.yml index 7790a14..5a054bd 100644 --- a/spec/localizer_test_model_new_style.yml +++ b/spec/localizer_test_model_new_style.yml @@ -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!" \ No newline at end of file diff --git a/spec/models/active_record/localizer_test_model.rb b/spec/models/active_record/localizer_test_model.rb index ace49cf..3d175a5 100644 --- a/spec/models/active_record/localizer_test_model.rb +++ b/spec/models/active_record/localizer_test_model.rb @@ -24,11 +24,19 @@ describe 'localized state names' do 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