aasm 4.0.5 → 4.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +10 -11
- data/CHANGELOG.md +18 -1
- data/Gemfile +6 -2
- data/README.md +21 -4
- data/README_FROM_VERSION_3_TO_4.md +1 -1
- data/aasm.gemspec +5 -2
- data/gemfiles/rails_3.2.gemfile +3 -1
- data/gemfiles/rails_4.0.gemfile +2 -5
- data/gemfiles/rails_4.0_bson1.gemfile +14 -0
- data/gemfiles/rails_4.1.gemfile +2 -5
- data/gemfiles/rails_4.1_bson1.gemfile +14 -0
- data/gemfiles/rails_4.2.gemfile +13 -0
- data/gemfiles/rails_4.2_bson1.gemfile +14 -0
- data/lib/aasm/aasm.rb +1 -1
- data/lib/aasm/base.rb +7 -7
- data/lib/aasm/core/event.rb +10 -2
- data/lib/aasm/core/transition.rb +0 -2
- data/lib/aasm/instance_base.rb +1 -1
- data/lib/aasm/persistence/active_record_persistence.rb +4 -4
- data/lib/aasm/persistence/base.rb +4 -1
- data/lib/aasm/persistence/mongo_mapper_persistence.rb +174 -0
- data/lib/aasm/persistence/mongoid_persistence.rb +1 -5
- data/lib/aasm/persistence.rb +2 -0
- data/lib/aasm/version.rb +1 -1
- data/spec/database.rb +1 -1
- data/spec/models/callbacks/basic.rb +33 -20
- data/spec/models/callbacks/private_method.rb +44 -0
- data/spec/models/callbacks/with_args.rb +20 -4
- data/spec/models/mongo_mapper/no_scope_mongo_mapper.rb +10 -0
- data/spec/models/mongo_mapper/simple_mongo_mapper.rb +11 -0
- data/spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb +12 -0
- data/spec/models/mongoid/simple_new_dsl_mongoid.rb +1 -1
- data/spec/models/persistence.rb +18 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/unit/callbacks_spec.rb +68 -32
- data/spec/unit/complex_example_spec.rb +9 -9
- data/spec/unit/event_spec.rb +6 -6
- data/spec/unit/inspection_spec.rb +2 -2
- data/spec/unit/persistence/active_record_persistence_spec.rb +38 -39
- data/spec/unit/persistence/mongo_mapper_persistance_spec.rb +135 -0
- data/spec/unit/persistence/mongoid_persistance_spec.rb +4 -10
- data/spec/unit/persistence/sequel_persistence_spec.rb +2 -1
- data/spec/unit/subclassing_spec.rb +1 -1
- data/spec/unit/transition_spec.rb +10 -10
- metadata +21 -12
|
@@ -30,15 +30,15 @@ describe "instance methods" do
|
|
|
30
30
|
let(:columns_hash) { Hash[column_name, column] }
|
|
31
31
|
|
|
32
32
|
before :each do
|
|
33
|
-
gate.class.aasm.
|
|
34
|
-
gate.class.
|
|
33
|
+
allow(gate.class.aasm).to receive(:attribute_name).and_return(column_name.to_sym)
|
|
34
|
+
allow(gate.class).to receive(:columns_hash).and_return(columns_hash)
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
context "when AASM column has integer type" do
|
|
38
38
|
let(:column) { double(Object, type: :integer) }
|
|
39
39
|
|
|
40
40
|
it "returns true" do
|
|
41
|
-
expect(subject.call).to
|
|
41
|
+
expect(subject.call).to be_truthy
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ describe "instance methods" do
|
|
|
46
46
|
let(:column) { double(Object, type: :string) }
|
|
47
47
|
|
|
48
48
|
it "returns false" do
|
|
49
|
-
expect(subject.call).to
|
|
49
|
+
expect(subject.call).to be_falsey
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -55,7 +55,7 @@ describe "instance methods" do
|
|
|
55
55
|
subject { lambda{ gate.send(:aasm_guess_enum_method) } }
|
|
56
56
|
|
|
57
57
|
before :each do
|
|
58
|
-
gate.class.aasm.
|
|
58
|
+
allow(gate.class.aasm).to receive(:attribute_name).and_return(:value)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it "pluralizes AASM column name" do
|
|
@@ -75,7 +75,7 @@ describe "instance methods" do
|
|
|
75
75
|
context "when AASM enum setting is simply set to true" do
|
|
76
76
|
let(:with_true_enum) { WithTrueEnum.new }
|
|
77
77
|
before :each do
|
|
78
|
-
WithTrueEnum.aasm.
|
|
78
|
+
allow(WithTrueEnum.aasm).to receive(:attribute_name).and_return(:value)
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
it "infers enum method name from pluralized column name" do
|
|
@@ -93,12 +93,12 @@ describe "instance methods" do
|
|
|
93
93
|
|
|
94
94
|
context "when AASM enum setting is not enabled" do
|
|
95
95
|
before :each do
|
|
96
|
-
Gate.aasm.
|
|
96
|
+
allow(Gate.aasm).to receive(:attribute_name).and_return(:value)
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
context "when AASM column looks like enum" do
|
|
100
100
|
before :each do
|
|
101
|
-
gate.
|
|
101
|
+
allow(gate).to receive(:aasm_column_looks_like_enum).and_return(true)
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
it "infers enum method name from pluralized column name" do
|
|
@@ -108,7 +108,7 @@ describe "instance methods" do
|
|
|
108
108
|
|
|
109
109
|
context "when AASM column doesn't look like enum'" do
|
|
110
110
|
before :each do
|
|
111
|
-
gate.
|
|
111
|
+
allow(gate).to receive(:aasm_column_looks_like_enum)
|
|
112
112
|
.and_return(false)
|
|
113
113
|
end
|
|
114
114
|
|
|
@@ -126,24 +126,17 @@ describe "instance methods" do
|
|
|
126
126
|
let(:enum) { Hash[state_sym, state_code] }
|
|
127
127
|
|
|
128
128
|
before :each do
|
|
129
|
-
gate
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
gate
|
|
136
|
-
.class
|
|
137
|
-
.stub(enum_name)
|
|
138
|
-
.and_return(enum)
|
|
129
|
+
allow(gate).to receive(:aasm_enum).and_return(enum_name)
|
|
130
|
+
allow(gate).to receive(:aasm_write_attribute)
|
|
131
|
+
allow(gate).to receive(:write_attribute)
|
|
132
|
+
|
|
133
|
+
allow(Gate).to receive(enum_name).and_return(enum)
|
|
139
134
|
end
|
|
140
135
|
|
|
141
136
|
describe "aasm_write_state" do
|
|
142
137
|
context "when AASM is configured to skip validations on save" do
|
|
143
138
|
before :each do
|
|
144
|
-
gate
|
|
145
|
-
.stub(:aasm_skipping_validations)
|
|
146
|
-
.and_return(true)
|
|
139
|
+
allow(gate).to receive(:aasm_skipping_validations).and_return(true)
|
|
147
140
|
end
|
|
148
141
|
|
|
149
142
|
it "passes state code instead of state symbol to update_all" do
|
|
@@ -151,10 +144,7 @@ describe "instance methods" do
|
|
|
151
144
|
# parameters in the middle of the chain, so we need to use
|
|
152
145
|
# intermediate object instead.
|
|
153
146
|
obj = double(Object, update_all: 1)
|
|
154
|
-
|
|
155
|
-
.class
|
|
156
|
-
.stub(:where)
|
|
157
|
-
.and_return(obj)
|
|
147
|
+
allow(Gate).to receive(:where).and_return(obj)
|
|
158
148
|
|
|
159
149
|
gate.aasm_write_state state_sym
|
|
160
150
|
|
|
@@ -166,7 +156,7 @@ describe "instance methods" do
|
|
|
166
156
|
context "when AASM is not skipping validations" do
|
|
167
157
|
it "delegates state update to the helper method" do
|
|
168
158
|
# Let's pretend that validation is passed
|
|
169
|
-
gate.
|
|
159
|
+
allow(gate).to receive(:save).and_return(true)
|
|
170
160
|
|
|
171
161
|
gate.aasm_write_state state_sym
|
|
172
162
|
|
|
@@ -197,9 +187,7 @@ describe "instance methods" do
|
|
|
197
187
|
let(:state_sym) { :running }
|
|
198
188
|
|
|
199
189
|
before :each do
|
|
200
|
-
gate
|
|
201
|
-
.stub(:aasm_enum)
|
|
202
|
-
.and_return(nil)
|
|
190
|
+
allow(gate).to receive(:aasm_enum).and_return(nil)
|
|
203
191
|
end
|
|
204
192
|
|
|
205
193
|
describe "aasm_raw_attribute_value" do
|
|
@@ -215,9 +203,8 @@ describe "instance methods" do
|
|
|
215
203
|
let(:value) { 42 }
|
|
216
204
|
|
|
217
205
|
before :each do
|
|
218
|
-
gate.
|
|
219
|
-
gate.
|
|
220
|
-
.and_return(value)
|
|
206
|
+
allow(gate).to receive(:write_attribute)
|
|
207
|
+
allow(gate).to receive(:aasm_raw_attribute_value).and_return(value)
|
|
221
208
|
|
|
222
209
|
gate.send(:aasm_write_attribute, sym)
|
|
223
210
|
end
|
|
@@ -270,6 +257,18 @@ describe "instance methods" do
|
|
|
270
257
|
|
|
271
258
|
end
|
|
272
259
|
|
|
260
|
+
if ActiveRecord::VERSION::MAJOR < 4 && ActiveRecord::VERSION::MINOR < 2 # won't work with Rails >= 4.2
|
|
261
|
+
describe "direct state column access" do
|
|
262
|
+
it "accepts false states" do
|
|
263
|
+
f = FalseState.create!
|
|
264
|
+
expect(f.aasm_state).to eql false
|
|
265
|
+
expect {
|
|
266
|
+
f.aasm.events.map(&:name)
|
|
267
|
+
}.to_not raise_error
|
|
268
|
+
end
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
273
272
|
describe 'subclasses' do
|
|
274
273
|
it "should have the same states as its parent class" do
|
|
275
274
|
expect(DerivateNewDsl.aasm.states).to eq(SimpleNewDsl.aasm.states)
|
|
@@ -289,7 +288,7 @@ describe "named scopes with the new DSL" do
|
|
|
289
288
|
context "Does not already respond_to? the scope name" do
|
|
290
289
|
it "should add a scope" do
|
|
291
290
|
expect(SimpleNewDsl).to respond_to(:unknown_scope)
|
|
292
|
-
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to
|
|
291
|
+
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
|
293
292
|
end
|
|
294
293
|
end
|
|
295
294
|
|
|
@@ -348,7 +347,7 @@ describe 'transitions with persistence' do
|
|
|
348
347
|
|
|
349
348
|
validator.name = nil
|
|
350
349
|
expect(validator).not_to be_valid
|
|
351
|
-
expect(validator.run!).to
|
|
350
|
+
expect(validator.run!).to be_falsey
|
|
352
351
|
expect(validator).to be_sleeping
|
|
353
352
|
|
|
354
353
|
validator.reload
|
|
@@ -357,7 +356,7 @@ describe 'transitions with persistence' do
|
|
|
357
356
|
|
|
358
357
|
validator.name = 'another name'
|
|
359
358
|
expect(validator).to be_valid
|
|
360
|
-
expect(validator.run!).to
|
|
359
|
+
expect(validator.run!).to be_truthy
|
|
361
360
|
expect(validator).to be_running
|
|
362
361
|
|
|
363
362
|
validator.reload
|
|
@@ -372,7 +371,7 @@ describe 'transitions with persistence' do
|
|
|
372
371
|
|
|
373
372
|
persistor.name = nil
|
|
374
373
|
expect(persistor).not_to be_valid
|
|
375
|
-
expect(persistor.run!).to
|
|
374
|
+
expect(persistor.run!).to be_truthy
|
|
376
375
|
expect(persistor).to be_running
|
|
377
376
|
|
|
378
377
|
persistor = InvalidPersistor.find(persistor.id)
|
|
@@ -477,7 +476,7 @@ describe "invalid states with persistence" do
|
|
|
477
476
|
it "should not store states" do
|
|
478
477
|
validator = Validator.create(:name => 'name')
|
|
479
478
|
validator.status = 'invalid_state'
|
|
480
|
-
expect(validator.save).to
|
|
479
|
+
expect(validator.save).to be_falsey
|
|
481
480
|
expect {validator.save!}.to raise_error(ActiveRecord::RecordInvalid)
|
|
482
481
|
|
|
483
482
|
validator.reload
|
|
@@ -487,7 +486,7 @@ describe "invalid states with persistence" do
|
|
|
487
486
|
it "should store invalid states if configured" do
|
|
488
487
|
persistor = InvalidPersistor.create(:name => 'name')
|
|
489
488
|
persistor.status = 'invalid_state'
|
|
490
|
-
expect(persistor.save).to
|
|
489
|
+
expect(persistor.save).to be_truthy
|
|
491
490
|
|
|
492
491
|
persistor.reload
|
|
493
492
|
expect(persistor.status).to eq('invalid_state')
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
describe 'mongo_mapper' do
|
|
2
|
+
begin
|
|
3
|
+
require 'mongo_mapper'
|
|
4
|
+
require 'logger'
|
|
5
|
+
require 'spec_helper'
|
|
6
|
+
|
|
7
|
+
before(:all) do
|
|
8
|
+
Dir[File.dirname(__FILE__) + "/../../models/mongo_mapper/*.rb"].sort.each { |f| require File.expand_path(f) }
|
|
9
|
+
|
|
10
|
+
config = {
|
|
11
|
+
'test' => {
|
|
12
|
+
'database' => "mongo_mapper_#{Process.pid}"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
MongoMapper.setup(config, 'test') #, :logger => Logger.new(STDERR))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
after do
|
|
20
|
+
# Clear Out all non-system Mongo collections between tests
|
|
21
|
+
MongoMapper.database.collections.each do |collection|
|
|
22
|
+
collection.drop unless collection.capped? || (collection.name =~ /\Asystem/)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "named scopes with the old DSL" do
|
|
27
|
+
|
|
28
|
+
context "Does not already respond_to? the scope name" do
|
|
29
|
+
it "should add a scope" do
|
|
30
|
+
expect(SimpleMongoMapper).to respond_to(:unknown_scope)
|
|
31
|
+
expect(SimpleMongoMapper.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
|
32
|
+
#expect(SimpleMongoMapper.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "Already respond_to? the scope name" do
|
|
37
|
+
it "should not add a scope" do
|
|
38
|
+
expect(SimpleMongoMapper).to respond_to(:next)
|
|
39
|
+
expect(SimpleMongoMapper.new.class).to eq(SimpleMongoMapper)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe "named scopes with the new DSL" do
|
|
46
|
+
|
|
47
|
+
context "Does not already respond_to? the scope name" do
|
|
48
|
+
it "should add a scope" do
|
|
49
|
+
expect(SimpleNewDslMongoMapper).to respond_to(:unknown_scope)
|
|
50
|
+
expect(SimpleNewDslMongoMapper.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
context "Already respond_to? the scope name" do
|
|
55
|
+
it "should not add a scope" do
|
|
56
|
+
expect(SimpleNewDslMongoMapper).to respond_to(:next)
|
|
57
|
+
expect(SimpleNewDslMongoMapper.new.class).to eq(SimpleNewDslMongoMapper)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "does not create scopes if requested" do
|
|
62
|
+
expect(NoScopeMongoMapper).not_to respond_to(:ignored_scope)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe "#find_in_state" do
|
|
68
|
+
|
|
69
|
+
let!(:model) { SimpleNewDslMongoMapper.create!(:status => :unknown_scope) }
|
|
70
|
+
let!(:model_id) { model._id }
|
|
71
|
+
|
|
72
|
+
it "should respond to method" do
|
|
73
|
+
expect(SimpleNewDslMongoMapper).to respond_to(:find_in_state)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "should find the model when given the correct scope and model id" do
|
|
77
|
+
expect(SimpleNewDslMongoMapper.find_in_state(model_id, 'unknown_scope').class).to eq(SimpleNewDslMongoMapper)
|
|
78
|
+
expect(SimpleNewDslMongoMapper.find_in_state(model_id, 'unknown_scope')).to eq(model)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should raise DocumentNotFound error when given incorrect scope" do
|
|
82
|
+
expect {SimpleNewDslMongoMapper.find_in_state(model_id, 'next')}.to raise_error MongoMapper::DocumentNotFound
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "should raise DocumentNotFound error when given incorrect model id" do
|
|
86
|
+
expect {SimpleNewDslMongoMapper.find_in_state('bad_id', 'unknown_scope')}.to raise_error MongoMapper::DocumentNotFound
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
describe "#count_in_state" do
|
|
92
|
+
|
|
93
|
+
before do
|
|
94
|
+
3.times { SimpleNewDslMongoMapper.create!(:status => :unknown_scope) }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should respond to method" do
|
|
98
|
+
expect(SimpleNewDslMongoMapper).to respond_to(:count_in_state)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should return n for a scope with n records persisted" do
|
|
102
|
+
expect(SimpleNewDslMongoMapper.count_in_state('unknown_scope').class).to eq(Fixnum)
|
|
103
|
+
expect(SimpleNewDslMongoMapper.count_in_state('unknown_scope')).to eq(3)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should return zero for a scope without records persisted" do
|
|
107
|
+
expect(SimpleNewDslMongoMapper.count_in_state('next').class).to eq(Fixnum)
|
|
108
|
+
expect(SimpleNewDslMongoMapper.count_in_state('next')).to eq(0)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
describe "instance methods" do
|
|
114
|
+
|
|
115
|
+
let(:simple) {SimpleNewDslMongoMapper.new}
|
|
116
|
+
|
|
117
|
+
it "should call aasm_ensure_initial_state on validation before create" do
|
|
118
|
+
expect(SimpleNewDslMongoMapper.aasm.initial_state).to eq(:unknown_scope)
|
|
119
|
+
expect(SimpleNewDslMongoMapper.aasm.attribute_name).to eq(:status)
|
|
120
|
+
expect(simple.status).to eq(nil)
|
|
121
|
+
simple.valid?
|
|
122
|
+
expect(simple.status).to eq('unknown_scope')
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should call aasm_ensure_initial_state before create, even if skipping validations" do
|
|
126
|
+
expect(simple.status).to eq(nil)
|
|
127
|
+
simple.save(:validate => false)
|
|
128
|
+
expect(simple.status).to eq('unknown_scope')
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
rescue LoadError
|
|
133
|
+
puts "Not running MongoMapper specs because mongo_mapper gem is not installed!!!"
|
|
134
|
+
end
|
|
135
|
+
end
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
describe 'mongoid'
|
|
2
|
-
# describe 'mongoid' do
|
|
3
|
-
|
|
1
|
+
describe 'mongoid' do
|
|
4
2
|
begin
|
|
5
3
|
require 'mongoid'
|
|
6
4
|
require 'logger'
|
|
@@ -135,15 +133,11 @@ describe 'mongoid', :if => Gem::Version.create(RUBY_VERSION.dup) >= Gem::Version
|
|
|
135
133
|
describe "instance methods" do
|
|
136
134
|
let(:simple) {SimpleNewDslMongoid.new}
|
|
137
135
|
|
|
138
|
-
it "should
|
|
139
|
-
expect(
|
|
140
|
-
|
|
136
|
+
it "should initialize the aasm state on instantiation" do
|
|
137
|
+
expect(SimpleNewDslMongoid.new.status).to eql 'unknown_scope'
|
|
138
|
+
expect(SimpleNewDslMongoid.new.aasm.current_state).to eql :unknown_scope
|
|
141
139
|
end
|
|
142
140
|
|
|
143
|
-
it "should call aasm_ensure_initial_state before create, even if skipping validations" do
|
|
144
|
-
expect(simple).to receive(:aasm_ensure_initial_state).and_return(true)
|
|
145
|
-
simple.save(:validate => false)
|
|
146
|
-
end
|
|
147
141
|
end
|
|
148
142
|
|
|
149
143
|
rescue LoadError
|
|
@@ -6,7 +6,8 @@ describe 'sequel' do
|
|
|
6
6
|
require 'spec_helper'
|
|
7
7
|
|
|
8
8
|
before(:all) do
|
|
9
|
-
db = Sequel.
|
|
9
|
+
db = Sequel.connect(SEQUEL_DB)
|
|
10
|
+
|
|
10
11
|
# if you want to see the statements while running the spec enable the following line
|
|
11
12
|
# db.loggers << Logger.new($stderr)
|
|
12
13
|
db.create_table(:models) do
|
|
@@ -10,19 +10,19 @@ describe 'transitions' do
|
|
|
10
10
|
|
|
11
11
|
it 'should not raise an exception when not whiny' do
|
|
12
12
|
silencer = Silencer.new
|
|
13
|
-
expect(silencer.smile!).to
|
|
13
|
+
expect(silencer.smile!).to be_falsey
|
|
14
14
|
expect(silencer).to be_silent
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'should not raise an exception when superclass not whiny' do
|
|
18
18
|
sub = SubClassing.new
|
|
19
|
-
expect(sub.smile!).to
|
|
19
|
+
expect(sub.smile!).to be_falsey
|
|
20
20
|
expect(sub).to be_silent
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
it 'should not raise an exception when from is nil even if whiny' do
|
|
24
24
|
silencer = Silencer.new
|
|
25
|
-
expect(silencer.smile_any!).to
|
|
25
|
+
expect(silencer.smile_any!).to be_truthy
|
|
26
26
|
expect(silencer).to be_smiling
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -43,7 +43,7 @@ describe 'transitions' do
|
|
|
43
43
|
silencer.smile! do
|
|
44
44
|
success = true
|
|
45
45
|
end
|
|
46
|
-
}.not_to change { success }
|
|
46
|
+
}.not_to change { success }
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
end
|
|
@@ -64,14 +64,14 @@ describe AASM::Core::Transition do
|
|
|
64
64
|
it 'should set on_transition with deprecation warning' do
|
|
65
65
|
opts = {:from => 'foo', :to => 'bar'}
|
|
66
66
|
st = AASM::Core::Transition.allocate
|
|
67
|
-
st.
|
|
67
|
+
expect(st).to receive(:warn).with('[DEPRECATION] :on_transition is deprecated, use :after instead')
|
|
68
68
|
|
|
69
69
|
st.send :initialize, opts do
|
|
70
70
|
guard :gg
|
|
71
71
|
on_transition :after_callback
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
st.opts[:after].
|
|
74
|
+
expect(st.opts[:after]).to eql [:after_callback]
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
it 'should set after and guard from dsl' do
|
|
@@ -81,8 +81,8 @@ describe AASM::Core::Transition do
|
|
|
81
81
|
after :after_callback
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
st.opts[:guard].
|
|
85
|
-
st.opts[:after].
|
|
84
|
+
expect(st.opts[:guard]).to eql ['g', :gg]
|
|
85
|
+
expect(st.opts[:after]).to eql [:after_callback] # TODO fix this bad code coupling
|
|
86
86
|
end
|
|
87
87
|
|
|
88
88
|
it 'should pass equality check if from and to are the same' do
|
|
@@ -124,7 +124,7 @@ describe AASM::Core::Transition, '- when performing guard checks' do
|
|
|
124
124
|
opts = {:from => 'foo', :to => 'bar'}
|
|
125
125
|
st = AASM::Core::Transition.new(opts)
|
|
126
126
|
|
|
127
|
-
expect(st.allowed?(nil)).to
|
|
127
|
+
expect(st.allowed?(nil)).to be_truthy
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it 'should call the method on the object if guard is a symbol' do
|
|
@@ -185,7 +185,7 @@ describe AASM::Core::Transition, '- when executing the transition with a Proc' d
|
|
|
185
185
|
args = {:arg1 => '1', :arg2 => '2'}
|
|
186
186
|
obj = double('object', :aasm => 'aasm')
|
|
187
187
|
|
|
188
|
-
obj.
|
|
188
|
+
expect(obj).to receive(:test).with(args)
|
|
189
189
|
|
|
190
190
|
st.execute(obj, args)
|
|
191
191
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aasm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Barron
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rake
|
|
@@ -46,20 +46,14 @@ dependencies:
|
|
|
46
46
|
requirements:
|
|
47
47
|
- - ">="
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '
|
|
50
|
-
- - "<"
|
|
51
|
-
- !ruby/object:Gem::Version
|
|
52
|
-
version: '2.99'
|
|
49
|
+
version: '0'
|
|
53
50
|
type: :development
|
|
54
51
|
prerelease: false
|
|
55
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
53
|
requirements:
|
|
57
54
|
- - ">="
|
|
58
55
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '
|
|
60
|
-
- - "<"
|
|
61
|
-
- !ruby/object:Gem::Version
|
|
62
|
-
version: '2.99'
|
|
56
|
+
version: '0'
|
|
63
57
|
- !ruby/object:Gem::Dependency
|
|
64
58
|
name: pry
|
|
65
59
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -74,7 +68,7 @@ dependencies:
|
|
|
74
68
|
- - ">="
|
|
75
69
|
- !ruby/object:Gem::Version
|
|
76
70
|
version: '0'
|
|
77
|
-
description: AASM is a continuation of the acts
|
|
71
|
+
description: AASM is a continuation of the acts-as-state-machine rails plugin, built
|
|
78
72
|
for plain Ruby objects.
|
|
79
73
|
email: scott@elitists.net, ttilley@gmail.com, aasm@mt7.de
|
|
80
74
|
executables: []
|
|
@@ -97,7 +91,11 @@ files:
|
|
|
97
91
|
- callbacks.txt
|
|
98
92
|
- gemfiles/rails_3.2.gemfile
|
|
99
93
|
- gemfiles/rails_4.0.gemfile
|
|
94
|
+
- gemfiles/rails_4.0_bson1.gemfile
|
|
100
95
|
- gemfiles/rails_4.1.gemfile
|
|
96
|
+
- gemfiles/rails_4.1_bson1.gemfile
|
|
97
|
+
- gemfiles/rails_4.2.gemfile
|
|
98
|
+
- gemfiles/rails_4.2_bson1.gemfile
|
|
101
99
|
- lib/aasm.rb
|
|
102
100
|
- lib/aasm/aasm.rb
|
|
103
101
|
- lib/aasm/base.rb
|
|
@@ -112,6 +110,7 @@ files:
|
|
|
112
110
|
- lib/aasm/persistence.rb
|
|
113
111
|
- lib/aasm/persistence/active_record_persistence.rb
|
|
114
112
|
- lib/aasm/persistence/base.rb
|
|
113
|
+
- lib/aasm/persistence/mongo_mapper_persistence.rb
|
|
115
114
|
- lib/aasm/persistence/mongoid_persistence.rb
|
|
116
115
|
- lib/aasm/persistence/plain_persistence.rb
|
|
117
116
|
- lib/aasm/persistence/sequel_persistence.rb
|
|
@@ -128,6 +127,7 @@ files:
|
|
|
128
127
|
- spec/models/callbacks/basic.rb
|
|
129
128
|
- spec/models/callbacks/guard_within_block.rb
|
|
130
129
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
|
130
|
+
- spec/models/callbacks/private_method.rb
|
|
131
131
|
- spec/models/callbacks/with_args.rb
|
|
132
132
|
- spec/models/callbacks/with_state_args.rb
|
|
133
133
|
- spec/models/conversation.rb
|
|
@@ -136,6 +136,9 @@ files:
|
|
|
136
136
|
- spec/models/foo.rb
|
|
137
137
|
- spec/models/guardian.rb
|
|
138
138
|
- spec/models/invalid_persistor.rb
|
|
139
|
+
- spec/models/mongo_mapper/no_scope_mongo_mapper.rb
|
|
140
|
+
- spec/models/mongo_mapper/simple_mongo_mapper.rb
|
|
141
|
+
- spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb
|
|
139
142
|
- spec/models/mongoid/no_scope_mongoid.rb
|
|
140
143
|
- spec/models/mongoid/simple_mongoid.rb
|
|
141
144
|
- spec/models/mongoid/simple_new_dsl_mongoid.rb
|
|
@@ -163,6 +166,7 @@ files:
|
|
|
163
166
|
- spec/unit/memory_leak_spec.rb
|
|
164
167
|
- spec/unit/new_dsl_spec.rb
|
|
165
168
|
- spec/unit/persistence/active_record_persistence_spec.rb
|
|
169
|
+
- spec/unit/persistence/mongo_mapper_persistance_spec.rb
|
|
166
170
|
- spec/unit/persistence/mongoid_persistance_spec.rb
|
|
167
171
|
- spec/unit/persistence/sequel_persistence_spec.rb
|
|
168
172
|
- spec/unit/reloading_spec.rb
|
|
@@ -182,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
182
186
|
requirements:
|
|
183
187
|
- - ">="
|
|
184
188
|
- !ruby/object:Gem::Version
|
|
185
|
-
version:
|
|
189
|
+
version: 1.9.3
|
|
186
190
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
191
|
requirements:
|
|
188
192
|
- - ">="
|
|
@@ -206,6 +210,7 @@ test_files:
|
|
|
206
210
|
- spec/models/callbacks/basic.rb
|
|
207
211
|
- spec/models/callbacks/guard_within_block.rb
|
|
208
212
|
- spec/models/callbacks/multiple_transitions_transition_guard.rb
|
|
213
|
+
- spec/models/callbacks/private_method.rb
|
|
209
214
|
- spec/models/callbacks/with_args.rb
|
|
210
215
|
- spec/models/callbacks/with_state_args.rb
|
|
211
216
|
- spec/models/conversation.rb
|
|
@@ -214,6 +219,9 @@ test_files:
|
|
|
214
219
|
- spec/models/foo.rb
|
|
215
220
|
- spec/models/guardian.rb
|
|
216
221
|
- spec/models/invalid_persistor.rb
|
|
222
|
+
- spec/models/mongo_mapper/no_scope_mongo_mapper.rb
|
|
223
|
+
- spec/models/mongo_mapper/simple_mongo_mapper.rb
|
|
224
|
+
- spec/models/mongo_mapper/simple_new_dsl_mongo_mapper.rb
|
|
217
225
|
- spec/models/mongoid/no_scope_mongoid.rb
|
|
218
226
|
- spec/models/mongoid/simple_mongoid.rb
|
|
219
227
|
- spec/models/mongoid/simple_new_dsl_mongoid.rb
|
|
@@ -241,6 +249,7 @@ test_files:
|
|
|
241
249
|
- spec/unit/memory_leak_spec.rb
|
|
242
250
|
- spec/unit/new_dsl_spec.rb
|
|
243
251
|
- spec/unit/persistence/active_record_persistence_spec.rb
|
|
252
|
+
- spec/unit/persistence/mongo_mapper_persistance_spec.rb
|
|
244
253
|
- spec/unit/persistence/mongoid_persistance_spec.rb
|
|
245
254
|
- spec/unit/persistence/sequel_persistence_spec.rb
|
|
246
255
|
- spec/unit/reloading_spec.rb
|