provide state.human_name (in addition to state.localized_name)
This commit is contained in:
parent
01aec09922
commit
ddc505b9eb
|
@ -50,6 +50,7 @@ module AASM
|
||||||
def localized_name
|
def localized_name
|
||||||
AASM::Localizer.new.human_state_name(@clazz, self)
|
AASM::Localizer.new.human_state_name(@clazz, self)
|
||||||
end
|
end
|
||||||
|
alias human_name localized_name
|
||||||
|
|
||||||
def for_select
|
def for_select
|
||||||
[display_name, name.to_s]
|
[display_name, name.to_s]
|
||||||
|
|
|
@ -30,11 +30,15 @@ describe 'localized state names' do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should localize' do
|
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
|
end
|
||||||
|
|
||||||
it 'should use fallback' do
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue