aasm 3.0.13 → 3.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,83 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
-
3
- describe 'AuthMachine on initialization' do
4
- before(:each) do
5
- @auth = AuthMachine.new
6
- end
7
-
8
- it 'should be in the pending state' do
9
- @auth.aasm_current_state.should == :pending
10
- end
11
-
12
- it 'should have an activation code' do
13
- @auth.has_activation_code?.should be_true
14
- @auth.activation_code.should_not be_nil
15
- end
16
- end
17
-
18
- describe 'AuthMachine when being unsuspended' do
19
- it 'should be able to be unsuspended' do
20
- @auth = AuthMachine.new
21
- @auth.activate!
22
- @auth.suspend!
23
- @auth.may_unsuspend?.should be_true
24
- end
25
-
26
- it 'should not be able to be unsuspended into active' do
27
- @auth = AuthMachine.new
28
- @auth.suspend!
29
- @auth.may_unsuspend?(:active).should_not be_true
30
- end
31
-
32
- it 'should be able to be unsuspended into active if polite' do
33
- @auth = AuthMachine.new
34
- @auth.suspend!
35
- @auth.may_wait?(:waiting, :please).should be_true
36
- @auth.wait!(nil, :please)
37
- end
38
-
39
- it 'should not be able to be unsuspended into active if not polite' do
40
- @auth = AuthMachine.new
41
- @auth.suspend!
42
- @auth.may_wait?(:waiting).should_not be_true
43
- @auth.may_wait?(:waiting, :rude).should_not be_true
44
- lambda {@auth.wait!(nil, :rude)}.should raise_error(AASM::InvalidTransition)
45
- lambda {@auth.wait!}.should raise_error(AASM::InvalidTransition)
46
- end
47
-
48
- it 'should not be able to be unpassified' do
49
- @auth = AuthMachine.new
50
- @auth.activate!
51
- @auth.suspend!
52
- @auth.unsuspend!
53
-
54
- @auth.may_unpassify?.should_not be_true
55
- lambda {@auth.unpassify!}.should raise_error(AASM::InvalidTransition)
56
- end
57
-
58
- it 'should be active if previously activated' do
59
- @auth = AuthMachine.new
60
- @auth.activate!
61
- @auth.suspend!
62
- @auth.unsuspend!
63
-
64
- @auth.aasm_current_state.should == :active
65
- end
66
-
67
- it 'should be pending if not previously activated, but an activation code is present' do
68
- @auth = AuthMachine.new
69
- @auth.suspend!
70
- @auth.unsuspend!
71
-
72
- @auth.aasm_current_state.should == :pending
73
- end
74
-
75
- it 'should be passive if not previously activated and there is no activation code' do
76
- @auth = AuthMachine.new
77
- @auth.activation_code = nil
78
- @auth.suspend!
79
- @auth.unsuspend!
80
-
81
- @auth.aasm_current_state.should == :passive
82
- end
83
- end
@@ -1,79 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
-
3
- class Foo2
4
- include AASM
5
- aasm_initial_state :open
6
- aasm_state :open,
7
- :before_enter => :before_enter_open,
8
- :before_exit => :before_exit_open,
9
- :after_enter => :after_enter_open,
10
- :after_exit => :after_exit_open
11
- aasm_state :closed,
12
- :before_enter => :before_enter_closed,
13
- :before_exit => :before_exit_closed,
14
- :after_enter => :after_enter_closed,
15
- :after_exit => :after_exit_closed
16
-
17
- aasm_event :close, :before => :before, :after => :after do
18
- transitions :to => :closed, :from => [:open]
19
- end
20
-
21
- aasm_event :open, :before => :before, :after => :after do
22
- transitions :to => :open, :from => :closed
23
- end
24
-
25
- def before_enter_open
26
- end
27
- def before_exit_open
28
- end
29
- def after_enter_open
30
- end
31
- def after_exit_open
32
- end
33
-
34
- def before_enter_closed
35
- end
36
- def before_exit_closed
37
- end
38
- def after_enter_closed
39
- end
40
- def after_exit_closed
41
- end
42
-
43
- def before
44
- end
45
- def after
46
- end
47
- end
48
-
49
- describe Foo2, '- new callbacks' do
50
- before(:each) do
51
- @foo = Foo2.new
52
- end
53
-
54
- it "should get close callbacks" do
55
- @foo.should_receive(:before).once.ordered
56
- @foo.should_receive(:before_exit_open).once.ordered # these should be before the state changes
57
- @foo.should_receive(:before_enter_closed).once.ordered
58
- @foo.should_receive(:aasm_write_state).once.ordered.and_return(true) # this is when the state changes
59
- @foo.should_receive(:after_exit_open).once.ordered # these should be after the state changes
60
- @foo.should_receive(:after_enter_closed).once.ordered
61
- @foo.should_receive(:after).once.ordered
62
-
63
- @foo.close!
64
- end
65
-
66
- it "should get open callbacks" do
67
- @foo.close!
68
-
69
- @foo.should_receive(:before).once.ordered
70
- @foo.should_receive(:before_exit_closed).once.ordered # these should be before the state changes
71
- @foo.should_receive(:before_enter_open).once.ordered
72
- @foo.should_receive(:aasm_write_state).once.ordered.and_return(true) # this is when the state changes
73
- @foo.should_receive(:after_exit_closed).once.ordered # these should be after the state changes
74
- @foo.should_receive(:after_enter_open).once.ordered
75
- @foo.should_receive(:after).once.ordered
76
-
77
- @foo.open!
78
- end
79
- end
@@ -1,7 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
-
3
- describe 'aasm_states' do
4
- it 'should contain all of the states' do
5
- Conversation.aasm_states.should == [:needs_attention, :read, :closed, :awaiting_response, :junk]
6
- end
7
- end