state_manager 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.7
1
+ 0.2.8
@@ -43,7 +43,13 @@ module StateManager
43
43
  module ManagerMethods
44
44
 
45
45
  def write_state(value)
46
- resource.send :update_attribute, self.class._state_property, value.path
46
+ # Since new objects will have a nil state value, this method will be called
47
+ # during instantiation. We want to hold off on writing to the database.
48
+ if resource.new_record?
49
+ resource.send :write_attribute, self.class._state_property, value.path
50
+ else
51
+ resource.send :update_attribute, self.class._state_property, value.path
52
+ end
47
53
  end
48
54
 
49
55
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "state_manager"
8
- s.version = "0.2.7"
8
+ s.version = "0.2.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gordon Hempton"]
12
- s.date = "2012-07-03"
12
+ s.date = "2012-07-30"
13
13
  s.description = "Finite state machine implementation that keeps logic separate from model classes and supports sub-states."
14
14
  s.email = "ghempton@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -49,7 +49,7 @@ Gem::Specification.new do |s|
49
49
  s.homepage = "http://github.com/ghempton/state_manager"
50
50
  s.licenses = ["MIT"]
51
51
  s.require_paths = ["lib"]
52
- s.rubygems_version = "1.8.15"
52
+ s.rubygems_version = "1.8.23"
53
53
  s.summary = "%Q{Finite state machine implementation.}"
54
54
 
55
55
  if s.respond_to? :specification_version then
@@ -89,6 +89,16 @@ class ActiveRecordTest < Test::Unit::TestCase
89
89
  assert_state 'unsubmitted'
90
90
  end
91
91
 
92
+ def test_new_record
93
+ @resource = Post.new
94
+ assert_state 'unsubmitted'
95
+ assert @resource.new_record?, 'record should not have been persisted'
96
+ @resource.save
97
+ @resource.submit!
98
+ assert_state 'submitted.awaiting_review'
99
+ assert !@resource.new_record?, 'record should be persisted'
100
+ end
101
+
92
102
  def test_scopes
93
103
  exec "INSERT INTO posts VALUES(5, NULL, NULL, 'submitted.reviewing')"
94
104
  exec "INSERT INTO posts VALUES(6, NULL, NULL, 'submitted.reviewing')"
metadata CHANGED
@@ -1,170 +1,233 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: state_manager
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.8
4
5
  prerelease:
5
- version: 0.2.7
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Gordon Hempton
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2012-07-03 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
27
31
  name: rdoc
28
- requirement: &id002 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
29
33
  none: false
30
- requirements:
34
+ requirements:
31
35
  - - ~>
32
- - !ruby/object:Gem::Version
33
- version: "3.12"
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
34
38
  type: :development
35
39
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
38
47
  name: pry
39
- requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
40
49
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
45
54
  type: :development
46
55
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
49
63
  name: pry-doc
50
- requirement: &id004 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
51
65
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
56
70
  type: :development
57
71
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
60
79
  name: pry-remote
61
- requirement: &id005 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
62
81
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
67
86
  type: :development
68
87
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
71
95
  name: pry-nav
72
- requirement: &id006 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
73
97
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
78
102
  type: :development
79
103
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
82
111
  name: pry-stack_explorer
83
- requirement: &id007 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
84
113
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
89
118
  type: :development
90
119
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
93
127
  name: bundler
94
- requirement: &id008 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
95
129
  none: false
96
- requirements:
130
+ requirements:
97
131
  - - ~>
98
- - !ruby/object:Gem::Version
132
+ - !ruby/object:Gem::Version
99
133
  version: 1.0.0
100
134
  type: :development
101
135
  prerelease: false
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 1.0.0
142
+ - !ruby/object:Gem::Dependency
104
143
  name: jeweler
105
- requirement: &id009 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
106
145
  none: false
107
- requirements:
146
+ requirements:
108
147
  - - ~>
109
- - !ruby/object:Gem::Version
148
+ - !ruby/object:Gem::Version
110
149
  version: 1.8.3
111
150
  type: :development
112
151
  prerelease: false
113
- version_requirements: *id009
114
- - !ruby/object:Gem::Dependency
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.8.3
158
+ - !ruby/object:Gem::Dependency
115
159
  name: delayed_job_active_record
116
- requirement: &id010 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
117
161
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
122
166
  type: :development
123
167
  prerelease: false
124
- version_requirements: *id010
125
- - !ruby/object:Gem::Dependency
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
126
175
  name: activerecord
127
- requirement: &id011 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
128
177
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
133
182
  type: :development
134
183
  prerelease: false
135
- version_requirements: *id011
136
- - !ruby/object:Gem::Dependency
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
137
191
  name: sqlite3
138
- requirement: &id012 !ruby/object:Gem::Requirement
192
+ requirement: !ruby/object:Gem::Requirement
139
193
  none: false
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: "0"
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
144
198
  type: :development
145
199
  prerelease: false
146
- version_requirements: *id012
147
- - !ruby/object:Gem::Dependency
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
148
207
  name: timecop
149
- requirement: &id013 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
150
209
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: "0"
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
155
214
  type: :development
156
215
  prerelease: false
157
- version_requirements: *id013
158
- description: Finite state machine implementation that keeps logic separate from model classes and supports sub-states.
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ description: Finite state machine implementation that keeps logic separate from model
223
+ classes and supports sub-states.
159
224
  email: ghempton@gmail.com
160
225
  executables: []
161
-
162
226
  extensions: []
163
-
164
- extra_rdoc_files:
227
+ extra_rdoc_files:
165
228
  - LICENSE.txt
166
229
  - README.md
167
- files:
230
+ files:
168
231
  - .document
169
232
  - Gemfile
170
233
  - Gemfile.lock
@@ -194,34 +257,31 @@ files:
194
257
  - test/plugins/delayed_job_test.rb
195
258
  - test/transitions_test.rb
196
259
  homepage: http://github.com/ghempton/state_manager
197
- licenses:
260
+ licenses:
198
261
  - MIT
199
262
  post_install_message:
200
263
  rdoc_options: []
201
-
202
- require_paths:
264
+ require_paths:
203
265
  - lib
204
- required_ruby_version: !ruby/object:Gem::Requirement
266
+ required_ruby_version: !ruby/object:Gem::Requirement
205
267
  none: false
206
- requirements:
207
- - - ">="
208
- - !ruby/object:Gem::Version
209
- hash: 29878923233174199
210
- segments:
268
+ requirements:
269
+ - - ! '>='
270
+ - !ruby/object:Gem::Version
271
+ version: '0'
272
+ segments:
211
273
  - 0
212
- version: "0"
213
- required_rubygems_version: !ruby/object:Gem::Requirement
274
+ hash: 443953156936998846
275
+ required_rubygems_version: !ruby/object:Gem::Requirement
214
276
  none: false
215
- requirements:
216
- - - ">="
217
- - !ruby/object:Gem::Version
218
- version: "0"
277
+ requirements:
278
+ - - ! '>='
279
+ - !ruby/object:Gem::Version
280
+ version: '0'
219
281
  requirements: []
220
-
221
282
  rubyforge_project:
222
- rubygems_version: 1.8.15
283
+ rubygems_version: 1.8.23
223
284
  signing_key:
224
285
  specification_version: 3
225
- summary: "%Q{Finite state machine implementation.}"
286
+ summary: ! '%Q{Finite state machine implementation.}'
226
287
  test_files: []
227
-