From f4b3701a686ef2c81944de92b8811d61aa55b5dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20Bo=CC=88ttger?= Date: Fri, 22 Feb 2013 22:47:23 +1300 Subject: [PATCH] added test --- lib/aasm/instance_base.rb | 3 ++- spec/unit/inspection_spec.rb | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/aasm/instance_base.rb b/lib/aasm/instance_base.rb index f3db298..0c32874 100644 --- a/lib/aasm/instance_base.rb +++ b/lib/aasm/instance_base.rb @@ -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 diff --git a/spec/unit/inspection_spec.rb b/spec/unit/inspection_spec.rb index dd60129..ffef7ec 100644 --- a/spec/unit/inspection_spec.rb +++ b/spec/unit/inspection_spec.rb @@ -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