workflow 0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -1
  2. data/lib/workflow.rb +7 -1
  3. data/test/test_workflow.rb +35 -1
  4. metadata +2 -2
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ Rake::TestTask.new do |t|
10
10
  t.warning = true
11
11
  end
12
12
 
13
- PKG_VERSION = "0.1"
13
+ PKG_VERSION = "0.1.1"
14
14
  PKG_FILES = FileList[
15
15
  'LICENSE',
16
16
  'README.rdoc',
data/lib/workflow.rb CHANGED
@@ -147,7 +147,13 @@ module Workflow
147
147
  private
148
148
 
149
149
  def spec
150
- self.class.workflow_spec
150
+ c = self.class
151
+ # using a simple loop instead of class_inheritable_accessor to avoid
152
+ # dependency on Rails' ActiveSupport
153
+ until c.workflow_spec || !(c.include? Workflow)
154
+ c = c.superclass
155
+ end
156
+ c.workflow_spec
151
157
  end
152
158
 
153
159
  def halt(reason = nil)
@@ -215,4 +215,38 @@ class WorkflowTest < Test::Unit::TestCase
215
215
  end
216
216
  c.new.my_transition!(args)
217
217
  end
218
- end
218
+
219
+ test 'Single table inheritance (STI)' do
220
+ class BigOrder < Order
221
+ end
222
+
223
+ bo = BigOrder.new
224
+ assert bo.submitted?
225
+ assert !bo.accepted?
226
+ end
227
+
228
+ test 'Two-level inheritance' do
229
+ class BigOrder < Order
230
+ end
231
+
232
+ class EvenBiggerOrder < BigOrder
233
+ end
234
+
235
+ assert EvenBiggerOrder.new.submitted?
236
+ end
237
+
238
+ test 'Iheritance with workflow definition override' do
239
+ class BigOrder < Order
240
+ end
241
+
242
+ class SpecialBigOrder < BigOrder
243
+ workflow do
244
+ state :start_big
245
+ end
246
+ end
247
+
248
+ special = SpecialBigOrder.new
249
+ assert_equal 'start_big', special.current_state.to_s
250
+ end
251
+ end
252
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workflow
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dobriakov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-25 00:00:00 +02:00
12
+ date: 2009-04-29 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15