workflow_on_mongoid 0.8.0.7 → 1.0.0.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.
- data/.travis.yml +1 -0
- data/README.rdoc +3 -3
- data/lib/workflow_on_mongoid/version.rb +2 -2
- data/test/main_test.rb +1 -1
- data/test/multiple_workflows_test.rb +56 -62
- data/workflow_on_mongoid.gemspec +1 -1
- metadata +5 -5
data/.travis.yml
CHANGED
data/README.rdoc
CHANGED
@@ -19,9 +19,8 @@ That is all. Now you can use {Workflow}[http://github.com/geekq/workflow] with y
|
|
19
19
|
|
20
20
|
== Versioning
|
21
21
|
|
22
|
-
The version numbers of workflow_on_mongoid track the latest supported version of {Workflow}[http://github.com/geekq/workflow] . The major version number (x.x.x) matches the latest supported version of the Workflow gem, while the minor version number (0.7.0.
|
22
|
+
The version numbers of workflow_on_mongoid track the latest supported version of {Workflow}[http://github.com/geekq/workflow] . The major version number (x.x.x) matches the latest supported version of the Workflow gem, while the minor version number (0.7.0.y) tracks changes to workflow_on_mongoid itself.
|
23
23
|
|
24
|
-
NOTE: workflow_on_mongoid 0.8.0 uses Mongoid 2.0.0.beta.20 . 0.8.0.1+ uses the latest Mongoid 2.0.0.rc . Please choose the appropriate version of workflow_on_mongoid based on the version of Mongoid you are using (the changes from Mongoid 2.0.0.beta to 2.0.0.rc are significant!)
|
25
24
|
|
26
25
|
== Example
|
27
26
|
class MongoidImage
|
@@ -59,5 +58,6 @@ workflow_on_mongoid is hosted on Github: http://github.com/bowsersenior/workflow
|
|
59
58
|
Special thanks to:
|
60
59
|
* Guilherme Cirne (https://github.com/gcirne)
|
61
60
|
* Dariusz Gertych (https://github.com/chytreg)
|
61
|
+
* David Butler (https://github.com/dwbutler)
|
62
62
|
|
63
|
-
Copyright (c) 2011 Mani Tadayon, released under the MIT License
|
63
|
+
Copyright (c) 2011 Mani Tadayon, released under the MIT License
|
data/test/main_test.rb
CHANGED
@@ -3,87 +3,81 @@ $:.unshift test_dir unless $:.include?(test_dir)
|
|
3
3
|
|
4
4
|
require 'test_helper'
|
5
5
|
|
6
|
-
|
7
|
-
class MultipleWorkflowsTest < ActiveRecordTestCase
|
6
|
+
class MultipleWorkflowsTest < ActiveRecordTestCase
|
8
7
|
|
9
|
-
|
8
|
+
test 'multiple workflows' do
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
end
|
10
|
+
ActiveRecord::Schema.define do
|
11
|
+
create_table :bookings do |t|
|
12
|
+
t.string :title, :null => false
|
13
|
+
t.string :workflow_state
|
14
|
+
t.string :workflow_type
|
17
15
|
end
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
18
|
+
exec "INSERT INTO bookings(title, workflow_state, workflow_type) VALUES('booking1', 'initial', 'workflow_1')"
|
19
|
+
exec "INSERT INTO bookings(title, workflow_state, workflow_type) VALUES('booking2', 'initial', 'workflow_2')"
|
20
|
+
|
21
|
+
class Booking < ActiveRecord::Base
|
22
|
+
include Workflow
|
23
|
+
|
24
|
+
def initialize_workflow
|
25
|
+
# define workflow per object instead of per class
|
26
|
+
case workflow_type
|
27
|
+
when 'workflow_1'
|
28
|
+
class << self
|
29
|
+
include Workflow
|
30
|
+
workflow do
|
31
|
+
state :initial do
|
32
|
+
event :progress, :transitions_to => :last
|
34
33
|
end
|
34
|
+
state :last
|
35
35
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
state :intermediate
|
44
|
-
state :last
|
36
|
+
end
|
37
|
+
when 'workflow_2'
|
38
|
+
class << self
|
39
|
+
include Workflow
|
40
|
+
workflow do
|
41
|
+
state :initial do
|
42
|
+
event :progress, :transitions_to => :intermediate
|
45
43
|
end
|
44
|
+
state :intermediate
|
45
|
+
state :last
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
def workflow_spec
|
53
|
-
metaclass.workflow_spec
|
54
|
-
end
|
51
|
+
def metaclass; class << self; self; end; end
|
55
52
|
|
53
|
+
def workflow_spec
|
54
|
+
metaclass.workflow_spec
|
56
55
|
end
|
57
56
|
|
58
|
-
|
59
|
-
# This test fails on jruby...
|
60
|
-
# ...not sure why, but all the class << self stuff above looks fishy
|
61
|
-
nil
|
62
|
-
else
|
63
|
-
booking1 = Booking.find_by_title('booking1')
|
64
|
-
booking1.initialize_workflow
|
57
|
+
end
|
65
58
|
|
66
|
-
|
67
|
-
|
59
|
+
booking1 = Booking.find_by_title('booking1')
|
60
|
+
booking1.initialize_workflow
|
68
61
|
|
69
|
-
|
70
|
-
|
71
|
-
assert booking1.last?, 'booking1 should transition to the "last" state'
|
62
|
+
booking2 = Booking.find_by_title('booking2')
|
63
|
+
booking2.initialize_workflow
|
72
64
|
|
73
|
-
|
74
|
-
|
75
|
-
|
65
|
+
assert booking1.initial?
|
66
|
+
booking1.progress!
|
67
|
+
assert booking1.last?, 'booking1 should transition to the "last" state'
|
76
68
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
69
|
+
assert booking2.initial?
|
70
|
+
booking2.progress!
|
71
|
+
assert booking2.intermediate?, 'booking2 should transition to the "intermediate" state'
|
82
72
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
73
|
+
assert booking1.workflow_spec, 'can access the individual workflow specification'
|
74
|
+
assert_equal 2, booking1.workflow_spec.states.length
|
75
|
+
assert_equal 3, booking2.workflow_spec.states.length
|
76
|
+
end
|
87
77
|
|
78
|
+
class Object
|
79
|
+
# The hidden singleton lurks behind everyone
|
80
|
+
def metaclass; class << self; self; end; end
|
88
81
|
end
|
82
|
+
|
89
83
|
end
|
data/workflow_on_mongoid.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.summary = "Add Mongoid support to the Workflow gem."
|
15
15
|
s.description = "Lets you use the Workflow gem with your Mongoid documents to add state machine functionality."
|
16
16
|
|
17
|
-
s.add_dependency "workflow", '~>0
|
17
|
+
s.add_dependency "workflow", '~>1.0'
|
18
18
|
s.add_dependency "mongoid"
|
19
19
|
|
20
20
|
s.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workflow_on_mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: workflow
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '0
|
21
|
+
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0
|
29
|
+
version: '1.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: mongoid
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: 1.3.7
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 1.8.
|
159
|
+
rubygems_version: 1.8.23
|
160
160
|
signing_key:
|
161
161
|
specification_version: 3
|
162
162
|
summary: Add Mongoid support to the Workflow gem.
|