1
0
Fork 0
mirror of https://github.com/aasm/aasm synced 2023-03-27 23:22:41 -04:00

added test

This commit is contained in:
Thorsten Böttger 2013-02-22 22:47:23 +13:00
parent 04d0643a68
commit f4b3701a68
2 changed files with 14 additions and 4 deletions

View file

@ -32,8 +32,9 @@ module AASM
AASM::Localizer.new.human_state_name(@instance.class, current_state)
end
# QUESTION: shouldn't events and permissible_events be the same thing?
def events(state=current_state)
events = @instance.class.aasm_events.values.select {|e| e.transitions_from_state?(state) }
events = @instance.class.aasm.events.values.select {|e| e.transitions_from_state?(state) }
events.map {|e| e.name}
end

View file

@ -71,9 +71,18 @@ describe :aasm_events_for_current_state do
let(:foo) {Foo.new}
it 'work' do
foo.aasm_events_for_current_state.should include(:close)
foo.aasm_events_for_current_state.should include(:null)
foo.aasm.events.should include(:close)
foo.aasm.events.should include(:null)
foo.close
foo.aasm_events_for_current_state.should be_empty
foo.aasm.events.should be_empty
end
end
describe 'permissible events' do
let(:foo) {Foo.new}
it 'work' do
foo.aasm.permissible_events.should include(:close)
foo.aasm.permissible_events.should_not include(:null)
end
end