From ddc505b9eb09ab7b162fc6ee7d77505d8d0b9531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20B=C3=B6ttger?= Date: Sat, 11 Jan 2014 12:43:10 +0100 Subject: [PATCH] provide state.human_name (in addition to state.localized_name) --- lib/aasm/state.rb | 1 + spec/unit/localizer_spec.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/aasm/state.rb b/lib/aasm/state.rb index 82af510..a12e495 100644 --- a/lib/aasm/state.rb +++ b/lib/aasm/state.rb @@ -50,6 +50,7 @@ module AASM def localized_name AASM::Localizer.new.human_state_name(@clazz, self) end + alias human_name localized_name def for_select [display_name, name.to_s] diff --git a/spec/unit/localizer_spec.rb b/spec/unit/localizer_spec.rb index a1a4f71..6a5719a 100644 --- a/spec/unit/localizer_spec.rb +++ b/spec/unit/localizer_spec.rb @@ -30,11 +30,15 @@ describe 'localized state names' do end it 'should localize' do - LocalizerTestModel.aasm.states.detect {|s| s == :opened}.localized_name.should == "It's open now!" + state = LocalizerTestModel.aasm.states.detect {|s| s == :opened} + state.localized_name.should == "It's open now!" + state.human_name.should == "It's open now!" end it 'should use fallback' do - LocalizerTestModel.aasm.states.detect {|s| s == :closed}.localized_name.should == 'Closed' + state = LocalizerTestModel.aasm.states.detect {|s| s == :closed} + state.localized_name.should == 'Closed' + state.human_name.should == 'Closed' end end