simplificator-fsm 0.3.2 → 0.3.3

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
+ :patch: 3
2
3
  :major: 0
3
4
  :minor: 3
4
- :patch: 2
data/lib/fsm/machine.rb CHANGED
@@ -43,6 +43,7 @@ module FSM
43
43
  end
44
44
 
45
45
  def self.set_current_state_name(target, value)
46
+ value = value && value.is_a?(Symbol) ? value.to_s : value
46
47
  target.send("#{Machine[target.class].current_state_attribute_name}=", value)
47
48
  end
48
49
 
@@ -12,6 +12,8 @@ module FSM
12
12
 
13
13
  end
14
14
 
15
+ # TODO: find reasonable names for these methods... actualy find a better way to intercept those calls
16
+ # looks really ugly to me
15
17
  private
16
18
  def self.bar(klass)
17
19
  klass.instance_eval() do
data/test/ar_test.rb CHANGED
@@ -2,9 +2,24 @@ require 'test_helper_ar'
2
2
  class ArTest < Test::Unit::TestCase
3
3
  context 'AR' do
4
4
 
5
- should 'bla' do
5
+ should 'set the state' do
6
+ o1 = Order.new
7
+ assert_equal :open, o1.state
8
+ o1.save!
9
+ o2 = Order.find o1.id
10
+ assert_equal 'open', o2[:state]
11
+ assert_equal :open, o2.state
12
+ end
13
+
14
+ should 'make transition' do
6
15
  o = Order.new
7
- assert_equal :open, o.state
16
+ o.deliver
17
+ assert_equal :delivered, o.state
18
+ o.save!
19
+ o.reload
20
+ o = Order.find(o.id)
21
+ assert_equal :delivered, o.state
8
22
  end
23
+
9
24
  end
10
25
  end
@@ -22,6 +22,7 @@ class Order < ActiveRecord::Base
22
22
  include FSM
23
23
  define_fsm do
24
24
  states :open, :closed, :delivered
25
+ transition(:deliver, :open, :delivered)
25
26
  end
26
27
  end
27
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplificator-fsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - simplificator
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-28 00:00:00 -07:00
12
+ date: 2009-06-24 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15