Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
alto committed Feb 27, 2013
1 parent 04d0643 commit f4b3701
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lib/aasm/instance_base.rb
Expand Up @@ -32,8 +32,9 @@ def human_state
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

Expand Down
15 changes: 12 additions & 3 deletions spec/unit/inspection_spec.rb
Expand Up @@ -71,9 +71,18 @@
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

0 comments on commit f4b3701

Please sign in to comment.