state_machine-audit_trail 0.0.3 → 0.0.4

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.
@@ -2,7 +2,7 @@ require 'state_machine'
2
2
 
3
3
  module StateMachine::AuditTrail
4
4
 
5
- VERSION = "0.0.3"
5
+ VERSION = "0.0.4"
6
6
 
7
7
  def self.setup
8
8
  StateMachine::Machine.send(:include, StateMachine::AuditTrail::TransitionAuditing)
@@ -6,6 +6,6 @@ class StateMachine::AuditTrail::ActiveRecord < StateMachine::AuditTrail::Backend
6
6
  end
7
7
 
8
8
  def foreign_key_field(object)
9
- object.class.name.foreign_key.to_sym
9
+ object.class.base_class.name.foreign_key.to_sym
10
10
  end
11
11
  end
@@ -10,7 +10,7 @@ class StateMachine::AuditTrailGenerator < ::Rails::Generators::Base
10
10
 
11
11
 
12
12
  def create_model
13
- Rails::Generators.invoke('model', [transition_class_name, "#{source_model.tableize}:references", "event:string", "from:string", "to:string", "created_at:timestamp", '--no-timestamps'])
13
+ Rails::Generators.invoke('model', [transition_class_name, "#{source_model.tableize.singularize}:references", "event:string", "from:string", "to:string", "created_at:timestamp", '--no-timestamps', '--fixture=false'])
14
14
  end
15
15
 
16
16
  protected
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,7 @@ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':me
12
12
 
13
13
  ActiveRecord::Base.connection.create_table(:test_models) do |t|
14
14
  t.string :state
15
+ t.string :type
15
16
  t.timestamps
16
17
  end
17
18
 
@@ -22,7 +23,6 @@ ActiveRecord::Base.connection.create_table(:test_model_with_multiple_state_machi
22
23
  end
23
24
 
24
25
 
25
-
26
26
  def create_transition_table(owner_class, state)
27
27
  class_name = "#{owner_class.name}#{state.to_s.camelize}Transition"
28
28
 
@@ -49,7 +49,6 @@ class TestModelWithMultipleStateMachinesSecondTransition < ActiveRecord::Base
49
49
  belongs_to :test_model
50
50
  end
51
51
 
52
-
53
52
  class TestModel < ActiveRecord::Base
54
53
 
55
54
  state_machine :state, :initial => :waiting do # log initial state?
@@ -65,6 +64,9 @@ class TestModel < ActiveRecord::Base
65
64
  end
66
65
  end
67
66
 
67
+ class TestModelDescendant < TestModel
68
+ end
69
+
68
70
  class TestModelWithMultipleStateMachines < ActiveRecord::Base
69
71
 
70
72
  state_machine :first, :initial => :beginning do
@@ -79,4 +79,9 @@ describe StateMachine::AuditTrail do
79
79
  first_transition.created_at.should be_within(10.seconds).of(Time.now.utc)
80
80
  end
81
81
  end
82
+
83
+ it "should properly grab the class name from STI models" do
84
+ m = TestModelDescendant.create!
85
+ lambda { m.start! }.should_not raise_error
86
+ end
82
87
  end
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "state_machine-audit_trail"
4
- s.version = "0.0.3"
4
+ s.version = "0.0.4"
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ["Willem van Bergen", "Jesse Storimer"]
7
7
  s.email = ["willem@shopify.com", "jesse@shopify.com"]
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machine-audit_trail
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 23
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
10
11
  platform: ruby
11
12
  authors:
12
13
  - Willem van Bergen
@@ -15,8 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-04-04 00:00:00 -04:00
19
- default_executable:
19
+ date: 2011-06-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: state_machine
@@ -26,6 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
+ hash: 3
29
30
  segments:
30
31
  - 0
31
32
  version: "0"
@@ -39,6 +40,7 @@ dependencies:
39
40
  requirements:
40
41
  - - ">="
41
42
  - !ruby/object:Gem::Version
43
+ hash: 3
42
44
  segments:
43
45
  - 0
44
46
  version: "0"
@@ -52,6 +54,7 @@ dependencies:
52
54
  requirements:
53
55
  - - ~>
54
56
  - !ruby/object:Gem::Version
57
+ hash: 7
55
58
  segments:
56
59
  - 2
57
60
  version: "2"
@@ -65,6 +68,7 @@ dependencies:
65
68
  requirements:
66
69
  - - ~>
67
70
  - !ruby/object:Gem::Version
71
+ hash: 5
68
72
  segments:
69
73
  - 3
70
74
  version: "3"
@@ -78,6 +82,7 @@ dependencies:
78
82
  requirements:
79
83
  - - ">="
80
84
  - !ruby/object:Gem::Version
85
+ hash: 3
81
86
  segments:
82
87
  - 0
83
88
  version: "0"
@@ -110,7 +115,6 @@ files:
110
115
  - spec/state_machine/audit_trail_spec.rb
111
116
  - state_machine-audit_trail.gemspec
112
117
  - tasks/github_gem.rb
113
- has_rdoc: true
114
118
  homepage: https://github.com/wvanbergen/state_machine-audit_trail
115
119
  licenses: []
116
120
 
@@ -124,6 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
128
  requirements:
125
129
  - - ">="
126
130
  - !ruby/object:Gem::Version
131
+ hash: 3
127
132
  segments:
128
133
  - 0
129
134
  version: "0"
@@ -132,13 +137,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
137
  requirements:
133
138
  - - ">="
134
139
  - !ruby/object:Gem::Version
140
+ hash: 3
135
141
  segments:
136
142
  - 0
137
143
  version: "0"
138
144
  requirements: []
139
145
 
140
146
  rubyforge_project: state_machine
141
- rubygems_version: 1.3.7
147
+ rubygems_version: 1.8.5
142
148
  signing_key:
143
149
  specification_version: 3
144
150
  summary: Log transitions on a state machine to support auditing and business process analytics.