aasm 4.11.0 → 4.11.1
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 +1 -1
- data/CHANGELOG.md +10 -1
- data/README.md +28 -2
- data/aasm.gemspec +2 -2
- data/gemfiles/rails_4.0_mongo_mapper.gemfile +0 -1
- data/gemfiles/rails_4.2_mongo_mapper.gemfile +0 -1
- data/lib/aasm/core/event.rb +2 -6
- data/lib/aasm/instance_base.rb +8 -8
- data/lib/aasm/persistence/base.rb +3 -3
- data/lib/aasm/version.rb +1 -1
- data/lib/generators/active_record/aasm_generator.rb +1 -1
- data/spec/en.yml +3 -0
- data/spec/generators/active_record_generator_spec.rb +5 -0
- data/spec/models/active_record/simple_new_dsl.rb +2 -2
- data/spec/models/guard_with_params.rb +24 -0
- data/spec/models/guard_with_params_multiple.rb +18 -0
- data/spec/models/mongo_mapper/simple_mongo_mapper.rb +2 -2
- data/spec/models/mongoid/simple_mongoid.rb +2 -2
- data/spec/models/multi_transitioner.rb +10 -0
- data/spec/models/validator.rb +6 -1
- data/spec/unit/guard_with_params_multiple_spec.rb +10 -0
- data/spec/unit/guard_with_params_spec.rb +10 -0
- data/spec/unit/inspection_spec.rb +5 -0
- data/spec/unit/persistence/active_record_persistence_multiple_spec.rb +4 -1
- data/spec/unit/persistence/active_record_persistence_spec.rb +12 -1
- data/spec/unit/persistence/mongo_mapper_persistence_multiple_spec.rb +4 -1
- data/spec/unit/persistence/mongo_mapper_persistence_spec.rb +4 -1
- data/spec/unit/persistence/mongoid_persistence_multiple_spec.rb +4 -1
- data/spec/unit/persistence/mongoid_persistence_spec.rb +4 -1
- metadata +13 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a57dd3feade6d1aea288f5999b4d93c890b11c60
|
4
|
+
data.tar.gz: 8e14ba9da4f262ca2f2ba0a40f633af6234e2075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08b85c55e73ba7b152e7a8344bf706315aa33016047849fee0e64dff8201f2691132d83d1e2c91b7e603b1e5f8e2a23bb8510573b539f142fa38b718c4aa0191
|
7
|
+
data.tar.gz: 2cdd0ef93171f881ef36bd2b1fe0d06d71dce2a73fffee570515c12f69fdc52fb18ea02e29a5b4591498de9526e3fb1bf6039aff8d4ed9af0c8a069f278150cc
|
data/.travis.yml
CHANGED
@@ -46,4 +46,4 @@ matrix:
|
|
46
46
|
|
47
47
|
notifications:
|
48
48
|
slack:
|
49
|
-
secure:
|
49
|
+
secure: gpltVWntdKz0nSE6A5UvuX4qbN35uW51nsW+Ojgqm8Qsv8K240/NlZRYutFHr7GnJTe0rEEP2Oy3ZBnBtZKFn13RlTEAU/FCAxebr4H24rr29Ypwwp5xjiSE4MuoBEnroo4lw6ka3LsJnrY2PKRMiLJGsS0WsEPY4x8NUG/vyY8=
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 4.11.1
|
4
|
+
|
5
|
+
* fix: generator file name when using custom column name instead of
|
6
|
+
aasm_state (see [issue #398](https://github.com/aasm/aasm/pull/398) for details,
|
7
|
+
thanks to [@bastianwegge](https://github.com/bastianwegge))
|
8
|
+
* fix: Scopes when states are defined as a series of symbols (see [issue #397](https://github.com/aasm/aasm/pull/397) for details, thanks to [@evheny0](https://github.com/evheny0))
|
9
|
+
* fix: Multiple transition behavior when one of the transitions does not
|
10
|
+
have a "from" parameter (see [issue #392](https://github.com/aasm/aasm/issues/392) for details)
|
11
|
+
* fix: permissible states not respecting guard parameters (see [issue #388](https://github.com/aasm/aasm/issues/388)) with [pull-request #389](https://github.com/aasm/aasm/pull/389)
|
12
|
+
|
3
13
|
## 4.11.0
|
4
14
|
|
5
15
|
* support `logger` configuration (see [issue #370](https://github.com/aasm/aasm/pull/370) for details, thanks to [@HoyaBoya](https://github.com/HoyaBoya))
|
@@ -329,4 +339,3 @@
|
|
329
339
|
|
330
340
|
* supporting i18n
|
331
341
|
* supporting regular expressions for hash values and strings
|
332
|
-
|
data/README.md
CHANGED
@@ -132,7 +132,7 @@ class Job
|
|
132
132
|
...
|
133
133
|
end
|
134
134
|
|
135
|
-
def notify_somebody
|
135
|
+
def notify_somebody
|
136
136
|
...
|
137
137
|
end
|
138
138
|
|
@@ -418,6 +418,28 @@ SimpleMultipleExample.aasm(:work).states
|
|
418
418
|
*Final note*: Support for multiple state machines per class is a pretty new feature
|
419
419
|
(since version `4.3`), so please bear with us in case it doesn't work as expected.
|
420
420
|
|
421
|
+
### Auto-generated Status Constants
|
422
|
+
|
423
|
+
AASM automatically [generates constants](https://github.com/aasm/aasm/pull/60)
|
424
|
+
for each status so you don't have to explicitly define them.
|
425
|
+
|
426
|
+
```ruby
|
427
|
+
class Foo
|
428
|
+
include AASM
|
429
|
+
|
430
|
+
aasm do
|
431
|
+
state :initialized
|
432
|
+
state :calculated
|
433
|
+
state :finalized
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
> Foo::STATE_INITIALIZED
|
438
|
+
#=> :initialized
|
439
|
+
> Foo::STATE_CALCULATED
|
440
|
+
#=> :calculated
|
441
|
+
```
|
442
|
+
|
421
443
|
### Extending AASM
|
422
444
|
|
423
445
|
AASM allows you to easily extend `AASM::Base` for your own application purposes.
|
@@ -935,6 +957,9 @@ job.aasm.events(:reject => :sleep).map(&:name)
|
|
935
957
|
# list states for select
|
936
958
|
Job.aasm.states_for_select
|
937
959
|
=> [["Sleeping", "sleeping"], ["Running", "running"], ["Cleaning", "cleaning"]]
|
960
|
+
|
961
|
+
# show permitted states with guard parameter
|
962
|
+
job.aasm.states({:permitted => true}, guard_parameter).map(&:name)
|
938
963
|
```
|
939
964
|
|
940
965
|
|
@@ -1029,7 +1054,7 @@ gem 'aasm'
|
|
1029
1054
|
|
1030
1055
|
### Generators
|
1031
1056
|
|
1032
|
-
After installing
|
1057
|
+
After installing AASM you can run generator:
|
1033
1058
|
|
1034
1059
|
```sh
|
1035
1060
|
% rails generate aasm NAME [COLUMN_NAME]
|
@@ -1055,6 +1080,7 @@ Feel free to
|
|
1055
1080
|
* [Scott Barron](https://github.com/rubyist) (2006–2009, original author)
|
1056
1081
|
* [Travis Tilley](https://github.com/ttilley) (2009–2011)
|
1057
1082
|
* [Thorsten Böttger](http://github.com/alto) (since 2011)
|
1083
|
+
* [Anil Maurya](http://github.com/anilmaurya) (since 2016)
|
1058
1084
|
|
1059
1085
|
|
1060
1086
|
## Contributing ##
|
data/aasm.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "aasm/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "aasm"
|
7
7
|
s.version = AASM::VERSION
|
8
|
-
s.authors = ["
|
9
|
-
s.email = %q{
|
8
|
+
s.authors = ["Thorsten Boettger", "Anil Maurya"]
|
9
|
+
s.email = %q{aasm@mt7.de, anilmaurya8dec@gmail.com}
|
10
10
|
s.homepage = %q{https://github.com/aasm/aasm}
|
11
11
|
s.summary = %q{State machine mixin for Ruby objects}
|
12
12
|
s.description = %q{AASM is a continuation of the acts-as-state-machine rails plugin, built for plain Ruby objects.}
|
data/lib/aasm/core/event.rb
CHANGED
@@ -112,12 +112,8 @@ module AASM::Core
|
|
112
112
|
|
113
113
|
def _fire(obj, options={}, to_state=nil, *args)
|
114
114
|
result = options[:test_only] ? false : nil
|
115
|
-
|
116
|
-
|
117
|
-
return result if transitions.size == 0
|
118
|
-
else
|
119
|
-
transitions = @transitions
|
120
|
-
end
|
115
|
+
transitions = @transitions.select { |t| t.from == obj.aasm(state_machine.name).current_state || t.from == nil}
|
116
|
+
return result if transitions.size == 0
|
121
117
|
|
122
118
|
# If to_state is not nil it either contains a potential
|
123
119
|
# to_state or an arg
|
data/lib/aasm/instance_base.rb
CHANGED
@@ -33,9 +33,9 @@ module AASM
|
|
33
33
|
AASM::Localizer.new.human_state_name(@instance.class, state_object_for_name(current_state))
|
34
34
|
end
|
35
35
|
|
36
|
-
def states(options={})
|
36
|
+
def states(options={}, *args)
|
37
37
|
if options.has_key?(:permitted)
|
38
|
-
selected_events = events(:permitted => options[:permitted])
|
38
|
+
selected_events = events({:permitted => options[:permitted]}, *args)
|
39
39
|
# An array of arrays. Each inner array represents the transitions that
|
40
40
|
# transition from the current state for an event
|
41
41
|
event_transitions = selected_events.map {|e| e.transitions_from_state(current_state) }
|
@@ -45,10 +45,10 @@ module AASM
|
|
45
45
|
return nil if transitions.empty?
|
46
46
|
|
47
47
|
# Return the :to state of the first transition that is allowed (or not) or nil
|
48
|
-
if options[:permitted]
|
49
|
-
transition = transitions.find { |t| t.allowed?(@instance) }
|
48
|
+
if options[:permitted]
|
49
|
+
transition = transitions.find { |t| t.allowed?(@instance, *args) }
|
50
50
|
else
|
51
|
-
transition = transitions.find { |t| !t.allowed?(@instance) }
|
51
|
+
transition = transitions.find { |t| !t.allowed?(@instance, *args) }
|
52
52
|
end
|
53
53
|
transition ? transition.to : nil
|
54
54
|
end.flatten.compact.uniq
|
@@ -60,7 +60,7 @@ module AASM
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
def events(options={})
|
63
|
+
def events(options={}, *args)
|
64
64
|
state = options[:state] || current_state
|
65
65
|
events = @instance.class.aasm(@name).events.select {|e| e.transitions_from_state?(state) }
|
66
66
|
|
@@ -71,9 +71,9 @@ module AASM
|
|
71
71
|
# filters the results of events_for_current_state so that only those that
|
72
72
|
# are really currently possible (given transition guards) are shown.
|
73
73
|
if options[:permitted]
|
74
|
-
events.select! { |e| @instance.send("may_#{e.name}?") }
|
74
|
+
events.select! { |e| @instance.send("may_#{e.name}?", *args) }
|
75
75
|
else
|
76
|
-
events.select! { |e| !@instance.send("may_#{e.name}?") }
|
76
|
+
events.select! { |e| !@instance.send("may_#{e.name}?", *args) }
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -53,9 +53,9 @@ module AASM
|
|
53
53
|
|
54
54
|
class Base
|
55
55
|
# make sure to create a (named) scope for each state
|
56
|
-
def state_with_scope(
|
57
|
-
state_without_scope(
|
58
|
-
create_scope(name) if create_scope?(name)
|
56
|
+
def state_with_scope(*args)
|
57
|
+
names = state_without_scope(*args)
|
58
|
+
names.each { |name| create_scope(name) if create_scope?(name) }
|
59
59
|
end
|
60
60
|
alias_method :state_without_scope, :state
|
61
61
|
alias_method :state, :state_with_scope
|
data/lib/aasm/version.rb
CHANGED
@@ -12,7 +12,7 @@ module ActiveRecord
|
|
12
12
|
|
13
13
|
def copy_aasm_migration
|
14
14
|
if model_exists?
|
15
|
-
migration_template "migration_existing.rb", "db/migrate/
|
15
|
+
migration_template "migration_existing.rb", "db/migrate/add_#{column_name}_to_#{table_name}.rb"
|
16
16
|
else
|
17
17
|
migration_template "migration.rb", "db/migrate/aasm_create_#{table_name}.rb"
|
18
18
|
end
|
data/spec/en.yml
CHANGED
@@ -36,4 +36,9 @@ describe ActiveRecord::Generators::AASMGenerator, type: :generator do
|
|
36
36
|
assert_migration "db/migrate/add_aasm_state_to_jobs.rb"
|
37
37
|
end
|
38
38
|
|
39
|
+
it "add custom aasm_column in existing model" do
|
40
|
+
run_generator %w(job state)
|
41
|
+
assert_migration "db/migrate/add_state_to_jobs.rb"
|
42
|
+
end
|
43
|
+
|
39
44
|
end
|
@@ -2,7 +2,7 @@ class SimpleNewDsl < ActiveRecord::Base
|
|
2
2
|
include AASM
|
3
3
|
aasm :column => :status
|
4
4
|
aasm do
|
5
|
-
state :unknown_scope
|
5
|
+
state :unknown_scope, :another_unknown_scope
|
6
6
|
state :new
|
7
7
|
end
|
8
8
|
end
|
@@ -11,7 +11,7 @@ class MultipleSimpleNewDsl < ActiveRecord::Base
|
|
11
11
|
include AASM
|
12
12
|
aasm :left, :column => :status
|
13
13
|
aasm :left do
|
14
|
-
state :unknown_scope
|
14
|
+
state :unknown_scope, :another_unknown_scope
|
15
15
|
state :new
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class GuardWithParams
|
2
|
+
include AASM
|
3
|
+
aasm do
|
4
|
+
state :new, :reviewed, :finalized
|
5
|
+
|
6
|
+
event :mark_as_reviewed do
|
7
|
+
transitions :from => :new, :to => :reviewed, :guards => [:user_is_manager?]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_is_manager?(user)
|
12
|
+
ok = false
|
13
|
+
if user.has_role? :manager
|
14
|
+
ok = true
|
15
|
+
end
|
16
|
+
return ok
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class GuardParamsClass
|
21
|
+
def has_role?(role)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class GuardWithParamsMultiple
|
2
|
+
include AASM
|
3
|
+
aasm(:left) do
|
4
|
+
state :new, :reviewed, :finalized
|
5
|
+
|
6
|
+
event :mark_as_reviewed do
|
7
|
+
transitions :from => :new, :to => :reviewed, :guards => [:user_is_manager?]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def user_is_manager?(user)
|
12
|
+
ok = false
|
13
|
+
if user.has_role? :manager
|
14
|
+
ok = true
|
15
|
+
end
|
16
|
+
return ok
|
17
|
+
end
|
18
|
+
end
|
@@ -5,7 +5,7 @@ class SimpleMongoMapper
|
|
5
5
|
key :status, String
|
6
6
|
|
7
7
|
aasm column: :status do
|
8
|
-
state :unknown_scope
|
8
|
+
state :unknown_scope, :another_unknown_scope
|
9
9
|
state :next
|
10
10
|
end
|
11
11
|
end
|
@@ -17,7 +17,7 @@ class SimpleMongoMapperMultiple
|
|
17
17
|
key :status, String
|
18
18
|
|
19
19
|
aasm :left, column: :status do
|
20
|
-
state :unknown_scope
|
20
|
+
state :unknown_scope, :another_unknown_scope
|
21
21
|
state :next
|
22
22
|
end
|
23
23
|
end
|
@@ -5,7 +5,7 @@ class SimpleMongoid
|
|
5
5
|
field :status, :type => String
|
6
6
|
|
7
7
|
aasm column: :status do
|
8
|
-
state :unknown_scope
|
8
|
+
state :unknown_scope, :another_unknown_scope
|
9
9
|
state :new
|
10
10
|
end
|
11
11
|
end
|
@@ -17,7 +17,7 @@ class SimpleMongoidMultiple
|
|
17
17
|
field :status, :type => String
|
18
18
|
|
19
19
|
aasm :left, column: :status do
|
20
|
-
state :unknown_scope
|
20
|
+
state :unknown_scope, :another_unknown_scope
|
21
21
|
state :new
|
22
22
|
end
|
23
23
|
end
|
@@ -11,14 +11,24 @@ class MultiTransitioner
|
|
11
11
|
state :sleeping, :initial => true
|
12
12
|
state :running
|
13
13
|
state :dancing
|
14
|
+
state :dead
|
14
15
|
|
15
16
|
event :start do
|
16
17
|
transitions :from => :sleeping, :to => :running, guard: :runnable?
|
17
18
|
transitions :from => :sleeping, :to => :dancing
|
18
19
|
end
|
20
|
+
|
21
|
+
event :sleep do
|
22
|
+
transitions to: :sleeping, if: :alive?
|
23
|
+
transitions to: :dead, from: [:running, :dancing]
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
def runnable?
|
22
28
|
@can_run
|
23
29
|
end
|
30
|
+
|
31
|
+
def alive?
|
32
|
+
true
|
33
|
+
end
|
24
34
|
end
|
data/spec/models/validator.rb
CHANGED
@@ -6,7 +6,12 @@ class Validator < ActiveRecord::Base
|
|
6
6
|
:after_transaction_performed_on_run,
|
7
7
|
:before_all_transactions_performed,
|
8
8
|
:before_transaction_performed_on_fail,
|
9
|
-
:before_transaction_performed_on_run
|
9
|
+
:before_transaction_performed_on_run,
|
10
|
+
:invalid
|
11
|
+
|
12
|
+
validate do |model|
|
13
|
+
errors.add(:validator, "invalid") if invalid
|
14
|
+
end
|
10
15
|
|
11
16
|
include AASM
|
12
17
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "guards with params" do
|
4
|
+
let(:guard) { GuardWithParamsMultiple.new }
|
5
|
+
let(:user) {GuardParamsClass.new}
|
6
|
+
|
7
|
+
it "list permitted states" do
|
8
|
+
expect(guard.aasm(:left).states({:permitted => true}, user).map(&:name)).to eql [:reviewed]
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "guards with params" do
|
4
|
+
let(:guard) { GuardWithParams.new }
|
5
|
+
let(:user) {GuardParamsClass.new}
|
6
|
+
|
7
|
+
it "list permitted states" do
|
8
|
+
expect(guard.aasm.states({:permitted => true}, user).map(&:name)).to eql [:reviewed]
|
9
|
+
end
|
10
|
+
end
|
@@ -74,6 +74,11 @@ describe 'inspection for common cases' do
|
|
74
74
|
expect(states).to include(:running)
|
75
75
|
expect(states).to_not include(:dancing)
|
76
76
|
end
|
77
|
+
|
78
|
+
it "transitions to correct state if from state is missing from one transitions" do
|
79
|
+
multi.sleep
|
80
|
+
expect(multi.aasm.current_state).to eq(:sleeping)
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
it 'should list states in the order they have been defined' do
|
@@ -296,9 +296,12 @@ end
|
|
296
296
|
|
297
297
|
describe "named scopes with the new DSL" do
|
298
298
|
context "Does not already respond_to? the scope name" do
|
299
|
-
it "should add a scope" do
|
299
|
+
it "should add a scope for each state" do
|
300
300
|
expect(MultipleSimpleNewDsl).to respond_to(:unknown_scope)
|
301
|
+
expect(MultipleSimpleNewDsl).to respond_to(:another_unknown_scope)
|
302
|
+
|
301
303
|
expect(MultipleSimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
304
|
+
expect(MultipleSimpleNewDsl.another_unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
302
305
|
end
|
303
306
|
end
|
304
307
|
|
@@ -296,9 +296,12 @@ end
|
|
296
296
|
|
297
297
|
describe "named scopes with the new DSL" do
|
298
298
|
context "Does not already respond_to? the scope name" do
|
299
|
-
it "should add a scope" do
|
299
|
+
it "should add a scope for each state" do
|
300
300
|
expect(SimpleNewDsl).to respond_to(:unknown_scope)
|
301
|
+
expect(SimpleNewDsl).to respond_to(:another_unknown_scope)
|
302
|
+
|
301
303
|
expect(SimpleNewDsl.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
304
|
+
expect(SimpleNewDsl.another_unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
302
305
|
end
|
303
306
|
end
|
304
307
|
|
@@ -544,6 +547,14 @@ describe 'transitions with persistence' do
|
|
544
547
|
expect(validator.name).to eq("name")
|
545
548
|
end
|
546
549
|
|
550
|
+
it "should not fire :after_commit if validation failed when saving object" do
|
551
|
+
validator = Validator.create(:name => 'name')
|
552
|
+
validator.invalid = true
|
553
|
+
expect { validator.run! }.to raise_error(ActiveRecord::RecordInvalid, 'Invalid record')
|
554
|
+
expect(validator).to be_sleeping
|
555
|
+
expect(validator.name).to eq("name")
|
556
|
+
end
|
557
|
+
|
547
558
|
it "should not fire if not saving" do
|
548
559
|
validator = Validator.create(:name => 'name')
|
549
560
|
expect(validator).to be_sleeping
|
@@ -28,9 +28,12 @@ describe 'mongo_mapper' do
|
|
28
28
|
describe "named scopes with the old DSL" do
|
29
29
|
|
30
30
|
context "Does not already respond_to? the scope name" do
|
31
|
-
it "should add a scope" do
|
31
|
+
it "should add a scope for each state" do
|
32
32
|
expect(SimpleMongoMapperMultiple).to respond_to(:unknown_scope)
|
33
|
+
expect(SimpleMongoMapperMultiple).to respond_to(:another_unknown_scope)
|
34
|
+
|
33
35
|
expect(SimpleMongoMapperMultiple.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
36
|
+
expect(SimpleMongoMapperMultiple.another_unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
34
37
|
#expect(SimpleMongoMapperMultiple.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
35
38
|
end
|
36
39
|
end
|
@@ -28,9 +28,12 @@ describe 'mongo_mapper' do
|
|
28
28
|
describe "named scopes with the old DSL" do
|
29
29
|
|
30
30
|
context "Does not already respond_to? the scope name" do
|
31
|
-
it "should add a scope" do
|
31
|
+
it "should add a scope for each state" do
|
32
32
|
expect(SimpleMongoMapper).to respond_to(:unknown_scope)
|
33
|
+
expect(SimpleMongoMapper).to respond_to(:another_unknown_scope)
|
34
|
+
|
33
35
|
expect(SimpleMongoMapper.unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
36
|
+
expect(SimpleMongoMapper.another_unknown_scope.class).to eq(MongoMapper::Plugins::Querying::DecoratedPluckyQuery)
|
34
37
|
#expect(SimpleMongoMapper.unknown_scope.is_a?(ActiveRecord::Relation)).to be_truthy
|
35
38
|
end
|
36
39
|
end
|
@@ -24,9 +24,12 @@ describe 'mongoid' do
|
|
24
24
|
describe "named scopes with the old DSL" do
|
25
25
|
|
26
26
|
context "Does not already respond_to? the scope name" do
|
27
|
-
it "should add a scope" do
|
27
|
+
it "should add a scope for each state" do
|
28
28
|
expect(SimpleMongoidMultiple).to respond_to(:unknown_scope)
|
29
|
+
expect(SimpleMongoidMultiple).to respond_to(:another_unknown_scope)
|
30
|
+
|
29
31
|
expect(SimpleMongoidMultiple.unknown_scope.class).to eq(Mongoid::Criteria)
|
32
|
+
expect(SimpleMongoidMultiple.another_unknown_scope.class).to eq(Mongoid::Criteria)
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
@@ -24,9 +24,12 @@ describe 'mongoid' do
|
|
24
24
|
describe "named scopes with the old DSL" do
|
25
25
|
|
26
26
|
context "Does not already respond_to? the scope name" do
|
27
|
-
it "should add a scope" do
|
27
|
+
it "should add a scope for each state" do
|
28
28
|
expect(SimpleMongoid).to respond_to(:unknown_scope)
|
29
|
+
expect(SimpleMongoid).to respond_to(:another_unknown_scope)
|
30
|
+
|
29
31
|
expect(SimpleMongoid.unknown_scope.class).to eq(Mongoid::Criteria)
|
32
|
+
expect(SimpleMongoid.another_unknown_scope.class).to eq(Mongoid::Criteria)
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
metadata
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Scott Barron
|
8
|
-
- Travis Tilley
|
9
7
|
- Thorsten Boettger
|
8
|
+
- Anil Maurya
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date: 2016-
|
12
|
+
date: 2016-09-21 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: rake
|
@@ -84,7 +83,7 @@ dependencies:
|
|
84
83
|
version: '0'
|
85
84
|
description: AASM is a continuation of the acts-as-state-machine rails plugin, built
|
86
85
|
for plain Ruby objects.
|
87
|
-
email:
|
86
|
+
email: aasm@mt7.de, anilmaurya8dec@gmail.com
|
88
87
|
executables: []
|
89
88
|
extensions: []
|
90
89
|
extra_rdoc_files: []
|
@@ -195,6 +194,8 @@ files:
|
|
195
194
|
- spec/models/dynamoid/dynamoid_simple.rb
|
196
195
|
- spec/models/foo.rb
|
197
196
|
- spec/models/foo_callback_multiple.rb
|
197
|
+
- spec/models/guard_with_params.rb
|
198
|
+
- spec/models/guard_with_params_multiple.rb
|
198
199
|
- spec/models/guardian.rb
|
199
200
|
- spec/models/guardian_multiple.rb
|
200
201
|
- spec/models/initial_state_proc.rb
|
@@ -249,6 +250,8 @@ files:
|
|
249
250
|
- spec/unit/exception_spec.rb
|
250
251
|
- spec/unit/guard_multiple_spec.rb
|
251
252
|
- spec/unit/guard_spec.rb
|
253
|
+
- spec/unit/guard_with_params_multiple_spec.rb
|
254
|
+
- spec/unit/guard_with_params_spec.rb
|
252
255
|
- spec/unit/initial_state_multiple_spec.rb
|
253
256
|
- spec/unit/initial_state_spec.rb
|
254
257
|
- spec/unit/inspection_multiple_spec.rb
|
@@ -300,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
303
|
version: '0'
|
301
304
|
requirements: []
|
302
305
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.
|
306
|
+
rubygems_version: 2.5.1
|
304
307
|
signing_key:
|
305
308
|
specification_version: 4
|
306
309
|
summary: State machine mixin for Ruby objects
|
@@ -353,6 +356,8 @@ test_files:
|
|
353
356
|
- spec/models/dynamoid/dynamoid_simple.rb
|
354
357
|
- spec/models/foo.rb
|
355
358
|
- spec/models/foo_callback_multiple.rb
|
359
|
+
- spec/models/guard_with_params.rb
|
360
|
+
- spec/models/guard_with_params_multiple.rb
|
356
361
|
- spec/models/guardian.rb
|
357
362
|
- spec/models/guardian_multiple.rb
|
358
363
|
- spec/models/initial_state_proc.rb
|
@@ -407,6 +412,8 @@ test_files:
|
|
407
412
|
- spec/unit/exception_spec.rb
|
408
413
|
- spec/unit/guard_multiple_spec.rb
|
409
414
|
- spec/unit/guard_spec.rb
|
415
|
+
- spec/unit/guard_with_params_multiple_spec.rb
|
416
|
+
- spec/unit/guard_with_params_spec.rb
|
410
417
|
- spec/unit/initial_state_multiple_spec.rb
|
411
418
|
- spec/unit/initial_state_spec.rb
|
412
419
|
- spec/unit/inspection_multiple_spec.rb
|