mirror of
https://github.com/aasm/aasm
synced 2023-03-27 23:22:41 -04:00
Added aasm_states_for_select that will return a select friendly collection of states.
Also added additional tests
This commit is contained in:
parent
ba3b99ff1b
commit
bd788a5212
3 changed files with 30 additions and 3 deletions
|
@ -1,3 +1,5 @@
|
|||
* Added aasm_states_for_select that will return a select friendly collection of states.
|
||||
|
||||
* Add some event callbacks, #aasm_event_fired(from, to), and #aasm_event_failed(event)
|
||||
Based on transition logging suggestion [Artem Vasiliev] and timestamp column suggestion [Mike Ferrier]
|
||||
|
||||
|
|
|
@ -64,6 +64,11 @@ module AASM
|
|||
def aasm_events
|
||||
@aasm_events ||= {}
|
||||
end
|
||||
|
||||
def aasm_states_for_select
|
||||
aasm_states.collect { |state| [state.to_s.gsub(/_/, ' ').capitalize, state] }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Instance methods
|
||||
|
|
|
@ -27,17 +27,37 @@ end
|
|||
|
||||
|
||||
describe AASM, '- class level definitions' do
|
||||
it 'should define a class level initial_state() method on its including class' do
|
||||
it 'should define a class level aasm_initial_state() method on its including class' do
|
||||
Foo.should respond_to(:aasm_initial_state)
|
||||
end
|
||||
|
||||
it 'should define a class level state() method on its including class' do
|
||||
it 'should define a class level aasm_state() method on its including class' do
|
||||
Foo.should respond_to(:aasm_state)
|
||||
end
|
||||
|
||||
it 'should define a class level event() method on its including class' do
|
||||
it 'should define a class level aasm_event() method on its including class' do
|
||||
Foo.should respond_to(:aasm_event)
|
||||
end
|
||||
|
||||
it 'should define a class level aasm_states() method on its including class' do
|
||||
Foo.should respond_to(:aasm_states)
|
||||
end
|
||||
|
||||
it 'should define a class level aasm_states_for_select() method on its including class' do
|
||||
Foo.should respond_to(:aasm_states_for_select)
|
||||
end
|
||||
|
||||
it 'should define a class level aasm_events() method on its including class' do
|
||||
Foo.should respond_to(:aasm_events)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe AASM, '- aasm_states_for_select' do
|
||||
it "should return a select friendly array of states in the form of [['Friendly name', :state_name]]" do
|
||||
Foo.aasm_states_for_select.should == [['Open', :open], ['Closed', :closed]]
|
||||
end
|
||||
end
|
||||
|
||||
describe AASM, '- instance level definitions' do
|
||||
|
|
Loading…
Add table
Reference in a new issue