state_machine 1.1.2 → 1.2.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.
Files changed (240) hide show
  1. data/.gitignore +7 -11
  2. data/.travis.yml +49 -7
  3. data/Appraisals +255 -87
  4. data/CHANGELOG.md +30 -0
  5. data/README.md +142 -21
  6. data/Rakefile +1 -11
  7. data/examples/Gemfile +5 -0
  8. data/examples/Gemfile.lock +14 -0
  9. data/examples/auto_shop.rb +2 -0
  10. data/examples/car.rb +2 -0
  11. data/examples/doc/AutoShop.html +2856 -0
  12. data/examples/doc/AutoShop_state.png +0 -0
  13. data/examples/doc/Car.html +919 -0
  14. data/examples/doc/Car_state.png +0 -0
  15. data/examples/doc/TrafficLight.html +2230 -0
  16. data/examples/doc/TrafficLight_state.png +0 -0
  17. data/examples/doc/Vehicle.html +7921 -0
  18. data/examples/doc/Vehicle_state.png +0 -0
  19. data/examples/doc/_index.html +136 -0
  20. data/examples/doc/class_list.html +47 -0
  21. data/examples/doc/css/common.css +1 -0
  22. data/examples/doc/css/full_list.css +55 -0
  23. data/examples/doc/css/style.css +322 -0
  24. data/examples/doc/file_list.html +46 -0
  25. data/examples/doc/frames.html +13 -0
  26. data/examples/doc/index.html +136 -0
  27. data/examples/doc/js/app.js +205 -0
  28. data/examples/doc/js/full_list.js +173 -0
  29. data/examples/doc/js/jquery.js +16 -0
  30. data/examples/doc/method_list.html +734 -0
  31. data/examples/doc/top-level-namespace.html +105 -0
  32. data/examples/rails-rest/migration.rb +1 -5
  33. data/examples/rails-rest/view__form.html.erb +34 -0
  34. data/examples/rails-rest/view_edit.html.erb +2 -21
  35. data/examples/rails-rest/view_index.html.erb +6 -4
  36. data/examples/rails-rest/view_new.html.erb +2 -11
  37. data/examples/rails-rest/view_show.html.erb +5 -3
  38. data/examples/traffic_light.rb +2 -0
  39. data/examples/vehicle.rb +2 -0
  40. data/gemfiles/active_model-3.0.0.gemfile.lock +9 -6
  41. data/gemfiles/active_model-3.0.5.gemfile.lock +10 -7
  42. data/gemfiles/active_model-3.1.1.gemfile.lock +12 -10
  43. data/gemfiles/{active_model-3.2.0.gemfile → active_model-3.2.1.gemfile} +1 -1
  44. data/gemfiles/{graphviz-0.9.0.gemfile → active_model-3.2.12.gemfile} +1 -1
  45. data/gemfiles/active_model-3.2.12.gemfile.lock +36 -0
  46. data/gemfiles/{active_record-3.2.0.gemfile → active_model-3.2.13.rc1.gemfile} +1 -2
  47. data/gemfiles/active_model-3.2.13.rc1.gemfile.lock +36 -0
  48. data/gemfiles/active_model-4.0.0.gemfile +9 -0
  49. data/gemfiles/active_model-4.0.0.gemfile.lock +78 -0
  50. data/gemfiles/active_record-2.0.0.gemfile +2 -1
  51. data/gemfiles/active_record-2.0.0.gemfile.lock +15 -6
  52. data/gemfiles/active_record-2.0.5.gemfile +2 -1
  53. data/gemfiles/active_record-2.0.5.gemfile.lock +15 -6
  54. data/gemfiles/active_record-2.1.0.gemfile +2 -1
  55. data/gemfiles/active_record-2.1.0.gemfile.lock +15 -6
  56. data/gemfiles/active_record-2.1.2.gemfile +2 -1
  57. data/gemfiles/active_record-2.1.2.gemfile.lock +15 -6
  58. data/gemfiles/active_record-2.2.3.gemfile +2 -1
  59. data/gemfiles/active_record-2.2.3.gemfile.lock +15 -6
  60. data/gemfiles/active_record-2.3.12.gemfile +2 -1
  61. data/gemfiles/active_record-2.3.12.gemfile.lock +15 -6
  62. data/gemfiles/active_record-2.3.5.gemfile +9 -0
  63. data/gemfiles/active_record-2.3.5.gemfile.lock +39 -0
  64. data/gemfiles/active_record-3.0.0.gemfile +2 -1
  65. data/gemfiles/active_record-3.0.0.gemfile.lock +18 -11
  66. data/gemfiles/active_record-3.0.5.gemfile +2 -1
  67. data/gemfiles/active_record-3.0.5.gemfile.lock +19 -12
  68. data/gemfiles/active_record-3.1.1.gemfile +2 -1
  69. data/gemfiles/active_record-3.1.1.gemfile.lock +22 -16
  70. data/gemfiles/active_record-3.2.12.gemfile +9 -0
  71. data/gemfiles/active_record-3.2.12.gemfile.lock +51 -0
  72. data/gemfiles/active_record-3.2.13.rc1.gemfile +9 -0
  73. data/gemfiles/active_record-3.2.13.rc1.gemfile.lock +51 -0
  74. data/gemfiles/active_record-4.0.0.gemfile +11 -0
  75. data/gemfiles/active_record-4.0.0.gemfile.lock +83 -0
  76. data/gemfiles/data_mapper-0.10.2.gemfile +1 -0
  77. data/gemfiles/data_mapper-0.10.2.gemfile.lock +13 -9
  78. data/gemfiles/data_mapper-0.9.11.gemfile +1 -0
  79. data/gemfiles/data_mapper-0.9.11.gemfile.lock +31 -7
  80. data/gemfiles/data_mapper-0.9.4.gemfile.lock +25 -14
  81. data/gemfiles/data_mapper-0.9.7.gemfile +1 -0
  82. data/gemfiles/data_mapper-0.9.7.gemfile.lock +27 -15
  83. data/gemfiles/data_mapper-1.0.0.gemfile.lock +20 -17
  84. data/gemfiles/data_mapper-1.0.1.gemfile.lock +20 -17
  85. data/gemfiles/data_mapper-1.0.2.gemfile.lock +20 -17
  86. data/gemfiles/data_mapper-1.1.0.gemfile.lock +19 -16
  87. data/gemfiles/data_mapper-1.2.0.gemfile.lock +19 -16
  88. data/gemfiles/default.gemfile.lock +8 -5
  89. data/gemfiles/graphviz-0.9.17.gemfile +7 -0
  90. data/gemfiles/graphviz-0.9.17.gemfile.lock +29 -0
  91. data/gemfiles/graphviz-0.9.21.gemfile.lock +7 -4
  92. data/gemfiles/graphviz-1.0.0.gemfile.lock +7 -4
  93. data/gemfiles/graphviz-1.0.3.gemfile +7 -0
  94. data/gemfiles/graphviz-1.0.3.gemfile.lock +29 -0
  95. data/gemfiles/graphviz-1.0.8.gemfile +7 -0
  96. data/gemfiles/graphviz-1.0.8.gemfile.lock +29 -0
  97. data/gemfiles/mongo_mapper-0.10.0.gemfile +1 -0
  98. data/gemfiles/mongo_mapper-0.10.0.gemfile.lock +14 -11
  99. data/gemfiles/mongo_mapper-0.11.1.gemfile +7 -0
  100. data/gemfiles/mongo_mapper-0.11.1.gemfile.lock +44 -0
  101. data/gemfiles/mongo_mapper-0.11.2.gemfile +9 -0
  102. data/gemfiles/mongo_mapper-0.11.2.gemfile.lock +48 -0
  103. data/gemfiles/mongo_mapper-0.12.0.gemfile +9 -0
  104. data/gemfiles/mongo_mapper-0.12.0.gemfile.lock +48 -0
  105. data/gemfiles/mongo_mapper-0.5.5.gemfile.lock +7 -4
  106. data/gemfiles/mongo_mapper-0.5.8.gemfile.lock +7 -4
  107. data/gemfiles/mongo_mapper-0.6.0.gemfile.lock +7 -4
  108. data/gemfiles/mongo_mapper-0.6.10.gemfile.lock +7 -4
  109. data/gemfiles/mongo_mapper-0.7.0.gemfile.lock +7 -4
  110. data/gemfiles/mongo_mapper-0.7.5.gemfile.lock +7 -4
  111. data/gemfiles/mongo_mapper-0.8.0.gemfile.lock +7 -4
  112. data/gemfiles/mongo_mapper-0.8.3.gemfile.lock +7 -4
  113. data/gemfiles/mongo_mapper-0.8.4.gemfile.lock +7 -4
  114. data/gemfiles/mongo_mapper-0.8.6.gemfile.lock +7 -4
  115. data/gemfiles/mongo_mapper-0.9.0.gemfile.lock +7 -4
  116. data/gemfiles/mongoid-2.0.0.gemfile +2 -0
  117. data/gemfiles/mongoid-2.0.0.gemfile.lock +22 -18
  118. data/gemfiles/mongoid-2.1.4.gemfile +2 -0
  119. data/gemfiles/mongoid-2.1.4.gemfile.lock +21 -17
  120. data/gemfiles/mongoid-2.2.4.gemfile +2 -0
  121. data/gemfiles/mongoid-2.2.4.gemfile.lock +21 -17
  122. data/gemfiles/mongoid-2.3.3.gemfile +2 -0
  123. data/gemfiles/mongoid-2.3.3.gemfile.lock +21 -17
  124. data/gemfiles/mongoid-2.4.0.gemfile +9 -0
  125. data/gemfiles/mongoid-2.4.0.gemfile.lock +47 -0
  126. data/gemfiles/mongoid-2.4.10.gemfile +9 -0
  127. data/gemfiles/mongoid-2.4.10.gemfile.lock +47 -0
  128. data/gemfiles/mongoid-2.5.2.gemfile +9 -0
  129. data/gemfiles/mongoid-2.5.2.gemfile.lock +47 -0
  130. data/gemfiles/mongoid-2.6.0.gemfile +9 -0
  131. data/gemfiles/mongoid-2.6.0.gemfile.lock +47 -0
  132. data/gemfiles/mongoid-3.0.0.gemfile +8 -0
  133. data/gemfiles/mongoid-3.0.0.gemfile.lock +45 -0
  134. data/gemfiles/mongoid-3.0.22.gemfile +8 -0
  135. data/gemfiles/mongoid-3.0.22.gemfile.lock +45 -0
  136. data/gemfiles/mongoid-3.1.0.gemfile +8 -0
  137. data/gemfiles/mongoid-3.1.0.gemfile.lock +45 -0
  138. data/gemfiles/sequel-2.11.0.gemfile +2 -1
  139. data/gemfiles/sequel-2.11.0.gemfile.lock +11 -6
  140. data/gemfiles/sequel-2.12.0.gemfile +2 -1
  141. data/gemfiles/sequel-2.12.0.gemfile.lock +11 -6
  142. data/gemfiles/sequel-2.8.0.gemfile +2 -1
  143. data/gemfiles/sequel-2.8.0.gemfile.lock +11 -6
  144. data/gemfiles/sequel-3.0.0.gemfile +2 -1
  145. data/gemfiles/sequel-3.0.0.gemfile.lock +11 -6
  146. data/gemfiles/sequel-3.10.0.gemfile +9 -0
  147. data/gemfiles/sequel-3.10.0.gemfile.lock +33 -0
  148. data/gemfiles/sequel-3.13.0.gemfile +2 -1
  149. data/gemfiles/sequel-3.13.0.gemfile.lock +11 -6
  150. data/gemfiles/sequel-3.14.0.gemfile +2 -1
  151. data/gemfiles/sequel-3.14.0.gemfile.lock +11 -6
  152. data/gemfiles/sequel-3.23.0.gemfile +2 -1
  153. data/gemfiles/sequel-3.23.0.gemfile.lock +11 -6
  154. data/gemfiles/sequel-3.24.0.gemfile +2 -1
  155. data/gemfiles/sequel-3.24.0.gemfile.lock +11 -6
  156. data/gemfiles/sequel-3.29.0.gemfile +2 -1
  157. data/gemfiles/sequel-3.29.0.gemfile.lock +11 -6
  158. data/gemfiles/sequel-3.34.0.gemfile +9 -0
  159. data/gemfiles/sequel-3.34.0.gemfile.lock +33 -0
  160. data/gemfiles/sequel-3.35.0.gemfile +9 -0
  161. data/gemfiles/sequel-3.35.0.gemfile.lock +33 -0
  162. data/gemfiles/sequel-3.4.0.gemfile +9 -0
  163. data/gemfiles/sequel-3.4.0.gemfile.lock +33 -0
  164. data/gemfiles/sequel-3.44.0.gemfile +9 -0
  165. data/gemfiles/sequel-3.44.0.gemfile.lock +33 -0
  166. data/lib/state_machine.rb +6 -0
  167. data/lib/state_machine/branch.rb +9 -8
  168. data/lib/state_machine/callback.rb +2 -2
  169. data/lib/state_machine/core.rb +10 -0
  170. data/lib/state_machine/core_ext.rb +1 -0
  171. data/lib/state_machine/eval_helpers.rb +5 -3
  172. data/lib/state_machine/event.rb +17 -6
  173. data/lib/state_machine/graph.rb +92 -0
  174. data/lib/state_machine/integrations.rb +13 -1
  175. data/lib/state_machine/integrations/active_model.rb +14 -20
  176. data/lib/state_machine/integrations/active_model/observer.rb +3 -3
  177. data/lib/state_machine/integrations/active_model/observer_update.rb +42 -0
  178. data/lib/state_machine/integrations/active_record.rb +52 -25
  179. data/lib/state_machine/integrations/active_record/locale.rb +1 -1
  180. data/lib/state_machine/integrations/active_record/versions.rb +1 -17
  181. data/lib/state_machine/integrations/base.rb +15 -6
  182. data/lib/state_machine/integrations/data_mapper.rb +98 -35
  183. data/lib/state_machine/integrations/data_mapper/versions.rb +46 -8
  184. data/lib/state_machine/integrations/mongo_mapper.rb +39 -12
  185. data/lib/state_machine/integrations/mongo_mapper/locale.rb +1 -1
  186. data/lib/state_machine/integrations/mongo_mapper/versions.rb +3 -20
  187. data/lib/state_machine/integrations/mongoid.rb +52 -14
  188. data/lib/state_machine/integrations/mongoid/locale.rb +1 -1
  189. data/lib/state_machine/integrations/mongoid/versions.rb +52 -26
  190. data/lib/state_machine/integrations/sequel.rb +82 -33
  191. data/lib/state_machine/integrations/sequel/versions.rb +19 -44
  192. data/lib/state_machine/machine.rb +99 -59
  193. data/lib/state_machine/machine_collection.rb +1 -2
  194. data/lib/state_machine/macro_methods.rb +29 -0
  195. data/lib/state_machine/node_collection.rb +1 -1
  196. data/lib/state_machine/state.rb +18 -10
  197. data/lib/state_machine/state_context.rb +2 -2
  198. data/lib/state_machine/transition.rb +8 -1
  199. data/lib/state_machine/transition_collection.rb +2 -1
  200. data/lib/state_machine/version.rb +1 -1
  201. data/lib/state_machine/yard.rb +8 -0
  202. data/lib/state_machine/yard/handlers.rb +12 -0
  203. data/lib/state_machine/yard/handlers/base.rb +32 -0
  204. data/lib/state_machine/yard/handlers/event.rb +25 -0
  205. data/lib/state_machine/yard/handlers/machine.rb +344 -0
  206. data/lib/state_machine/yard/handlers/state.rb +25 -0
  207. data/lib/state_machine/yard/handlers/transition.rb +47 -0
  208. data/lib/state_machine/yard/templates.rb +3 -0
  209. data/lib/state_machine/yard/templates/default/class/html/setup.rb +30 -0
  210. data/lib/state_machine/yard/templates/default/class/html/state_machines.erb +12 -0
  211. data/lib/tasks/state_machine.rb +2 -1
  212. data/lib/yard-state_machine.rb +2 -0
  213. data/state_machine.gemspec +4 -3
  214. data/test/files/switch.rb +4 -0
  215. data/test/test_helper.rb +5 -0
  216. data/test/unit/branch_test.rb +117 -36
  217. data/test/unit/callback_test.rb +5 -2
  218. data/test/unit/eval_helpers_test.rb +49 -1
  219. data/test/unit/event_collection_test.rb +3 -1
  220. data/test/unit/event_test.rb +182 -12
  221. data/test/unit/graph_test.rb +98 -0
  222. data/test/unit/integrations/active_model_test.rb +82 -12
  223. data/test/unit/integrations/active_record_test.rb +393 -37
  224. data/test/unit/integrations/base_test.rb +7 -2
  225. data/test/unit/integrations/data_mapper_test.rb +326 -72
  226. data/test/unit/integrations/mongo_mapper_test.rb +338 -44
  227. data/test/unit/integrations/mongoid_test.rb +606 -98
  228. data/test/unit/integrations/sequel_test.rb +429 -102
  229. data/test/unit/integrations_test.rb +28 -6
  230. data/test/unit/machine_collection_test.rb +6 -2
  231. data/test/unit/machine_test.rb +134 -82
  232. data/test/unit/node_collection_test.rb +2 -2
  233. data/test/unit/path_test.rb +1 -1
  234. data/test/unit/state_test.rb +65 -21
  235. data/test/unit/transition_collection_test.rb +43 -23
  236. data/test/unit/transition_test.rb +8 -2
  237. metadata +303 -221
  238. data/gemfiles/active_model-3.2.0.gemfile.lock +0 -32
  239. data/gemfiles/active_record-3.2.0.gemfile.lock +0 -43
  240. data/gemfiles/graphviz-0.9.0.gemfile.lock +0 -26
@@ -2,9 +2,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../test_helper')
2
2
 
3
3
  require 'sequel'
4
4
  require 'logger'
5
+ require 'stringio'
5
6
 
6
7
  # Establish database connection
7
- DB = Sequel.connect('sqlite:///', :loggers => [Logger.new("#{File.dirname(__FILE__)}/../../sequel.log")])
8
+ DB = Sequel.connect(RUBY_PLATFORM == 'java' ? 'jdbc:sqlite::memory:' : 'sqlite:///', :loggers => [Logger.new("#{File.dirname(__FILE__)}/../../sequel.log")])
8
9
 
9
10
  module SequelTest
10
11
  class BaseTestCase < Test::Unit::TestCase
@@ -14,10 +15,11 @@ module SequelTest
14
15
  protected
15
16
  # Creates a new Sequel model (and the associated table)
16
17
  def new_model(create_table = :foo, &block)
17
- table_name = create_table || :foo
18
- table_identifier = ::Sequel::SQL::Identifier.new(table_name)
18
+ name = create_table || :foo
19
+ table_name = "#{name}_#{rand(1000000)}"
20
+ table_identifier = Sequel::SQL::Identifier.new(table_name)
19
21
 
20
- if !defined?(Sequel::VERSION) || Gem::Version.new(::Sequel::VERSION) <= Gem::Version.new('3.26.0')
22
+ if !defined?(Sequel::VERSION) || Gem::Version.new(Sequel::VERSION) <= Gem::Version.new('3.26.0')
21
23
  class << table_identifier
22
24
  alias_method :original_to_s, :to_s
23
25
  def to_s(*args); args.empty? ? inspect : original_to_s(*args); end
@@ -28,12 +30,16 @@ module SequelTest
28
30
  primary_key :id
29
31
  column :state, :string
30
32
  end if create_table
31
- model = Class.new(Sequel::Model(DB[table_identifier])) do
33
+ model = Class.new(Sequel::Model) do
32
34
  self.raise_on_save_failure = false
33
35
  (class << self; self; end).class_eval do
34
- define_method(:name) { "SequelTest::#{table_name.to_s.capitalize}" }
36
+ define_method(:name) { "SequelTest::#{name.to_s.capitalize}" }
37
+ define_method(:table_identifier) { table_identifier }
35
38
  end
39
+
40
+ set_dataset(DB[table_identifier])
36
41
  end
42
+ model.set_dataset(DB[table_identifier])
37
43
  model.class_eval(&block) if block_given?
38
44
  model
39
45
  end
@@ -57,7 +63,7 @@ module SequelTest
57
63
  end
58
64
 
59
65
  def test_should_have_defaults
60
- assert_equal e = {:action => :save}, StateMachine::Integrations::Sequel.defaults
66
+ assert_equal({:action => :save}, StateMachine::Integrations::Sequel.defaults)
61
67
  end
62
68
 
63
69
  def test_should_not_have_a_locale_path
@@ -122,7 +128,7 @@ module SequelTest
122
128
 
123
129
  class MachineWithStaticInitialStateTest < BaseTestCase
124
130
  def setup
125
- @model = new_model do
131
+ @model = new_model(:vehicle) do
126
132
  attr_accessor :value
127
133
  end
128
134
  @machine = StateMachine::Machine.new(@model, :initial => :parked)
@@ -133,17 +139,6 @@ module SequelTest
133
139
  assert_equal 'parked', record.state
134
140
  end
135
141
 
136
- def test_should_set_initial_state_with_nil_attributes
137
- @model.class_eval do
138
- def set(hash)
139
- super(hash || {})
140
- end
141
- end
142
-
143
- record = @model.new(nil)
144
- assert_equal 'parked', record.state
145
- end
146
-
147
142
  def test_should_still_set_attributes
148
143
  record = @model.new(:value => 1)
149
144
  assert_equal 1, record.value
@@ -160,7 +155,7 @@ module SequelTest
160
155
 
161
156
  def test_should_set_attributes_prior_to_initialize_block
162
157
  state = nil
163
- record = @model.new do |record|
158
+ @model.new do |record|
164
159
  state = record.state
165
160
  end
166
161
 
@@ -182,6 +177,7 @@ module SequelTest
182
177
  @model.class_eval do
183
178
  attr_accessor :state_during_setter
184
179
 
180
+ remove_method :value=
185
181
  define_method(:value=) do |value|
186
182
  self.state_during_setter = state
187
183
  end
@@ -200,6 +196,20 @@ module SequelTest
200
196
  assert_equal 'idling', record.state
201
197
  end
202
198
 
199
+ def test_should_persist_initial_state
200
+ record = @model.new
201
+ record.save
202
+ record.reload
203
+ assert_equal 'parked', record.state
204
+ end
205
+
206
+ def test_should_persist_initial_state_on_dup
207
+ record = @model.create.dup
208
+ record.save
209
+ record.reload
210
+ assert_equal 'parked', record.state
211
+ end
212
+
203
213
  def test_should_use_stored_values_when_loading_from_database
204
214
  @machine.state :idling
205
215
 
@@ -213,6 +223,77 @@ module SequelTest
213
223
  record = @model[@model.create(:state => nil).id]
214
224
  assert_nil record.state
215
225
  end
226
+
227
+ def test_should_use_stored_values_when_loading_for_many_association
228
+ @machine.state :idling
229
+
230
+ DB.alter_table(@model.table_identifier) do
231
+ add_column :owner_id, :integer
232
+ end
233
+ @model.class_eval { get_db_schema(true) }
234
+ SequelTest.const_set('Vehicle', @model)
235
+
236
+ owner_model = new_model(:owner) do
237
+ one_to_many :vehicles, :class_name => 'SequelTest::Vehicle'
238
+ end
239
+ SequelTest.const_set('Owner', owner_model)
240
+
241
+ owner = owner_model.create
242
+ record = @model.create(:state => 'idling', :owner_id => owner.id)
243
+ assert_equal 'idling', owner.vehicles[0].state
244
+ end
245
+
246
+ if defined?(Sequel::VERSION) && Gem::Version.new(Sequel::VERSION) >= Gem::Version.new('3.10.0')
247
+ def test_should_use_stored_values_when_loading_for_one_association
248
+ @machine.state :idling
249
+
250
+ DB.alter_table(@model.table_identifier) do
251
+ add_column :owner_id, :integer
252
+ end
253
+ @model.class_eval { get_db_schema(true) }
254
+ SequelTest.const_set('Vehicle', @model)
255
+
256
+ owner_model = new_model(:owner) do
257
+ one_to_one :vehicle, :class_name => 'SequelTest::Vehicle'
258
+ end
259
+ SequelTest.const_set('Owner', owner_model)
260
+
261
+ owner = owner_model.create
262
+ record = @model.create(:state => 'idling', :owner_id => owner.id)
263
+ owner.reload
264
+ assert_equal 'idling', owner.vehicle.state
265
+ end
266
+ end
267
+
268
+ def test_should_use_stored_values_when_loading_for_belongs_to_association
269
+ @machine.state :idling
270
+
271
+ SequelTest.const_set('Vehicle', @model)
272
+
273
+ driver_model = new_model(:driver) do
274
+ DB.alter_table(table_identifier) do
275
+ add_column :vehicle_id, :integer
276
+ end
277
+ get_db_schema(true)
278
+
279
+ many_to_one :vehicle, :class_name => 'SequelTest::Vehicle'
280
+ end
281
+
282
+ SequelTest.const_set('Driver', driver_model)
283
+
284
+ record = @model.create(:state => 'idling')
285
+ driver = driver_model.create(:vehicle_id => record.id)
286
+ assert_equal 'idling', driver.vehicle.state
287
+ end
288
+
289
+ def teardown
290
+ SequelTest.class_eval do
291
+ remove_const('Vehicle') if defined?(SequelTest::Vehicle)
292
+ remove_const('Owner') if defined?(SequelTest::Owner)
293
+ remove_const('Driver') if defined?(SequelTest::Driver)
294
+ end
295
+ super
296
+ end
216
297
  end
217
298
 
218
299
  class MachineWithDynamicInitialStateTest < BaseTestCase
@@ -250,7 +331,7 @@ module SequelTest
250
331
 
251
332
  def test_should_set_attributes_prior_to_initialize_block
252
333
  state = nil
253
- record = @model.new do |record|
334
+ @model.new do |record|
254
335
  state = record.state
255
336
  end
256
337
 
@@ -272,6 +353,7 @@ module SequelTest
272
353
  @model.class_eval do
273
354
  attr_accessor :state_during_setter
274
355
 
356
+ remove_method :value=
275
357
  define_method(:value=) do |value|
276
358
  self.state_during_setter = state || 'nil'
277
359
  end
@@ -290,6 +372,20 @@ module SequelTest
290
372
  assert_equal 'idling', record.state
291
373
  end
292
374
 
375
+ def test_should_persist_initial_state
376
+ record = @model.new
377
+ record.save
378
+ record.reload
379
+ assert_equal 'parked', record.state
380
+ end
381
+
382
+ def test_should_persist_initial_state_on_dup
383
+ record = @model.create.dup
384
+ record.save
385
+ record.reload
386
+ assert_equal 'parked', record.state
387
+ end
388
+
293
389
  def test_should_use_stored_values_when_loading_from_database
294
390
  @machine.state :idling
295
391
 
@@ -317,13 +413,19 @@ module SequelTest
317
413
  end
318
414
  end
319
415
 
320
- class MachineWithColumnDefaultTest < BaseTestCase
416
+ class MachineWithSameColumnDefaultTest < BaseTestCase
321
417
  def setup
322
- @model = new_model
323
- DB.alter_table :foo do
324
- add_column :status, :string, :default => 'idling'
418
+ @original_stderr, $stderr = $stderr, StringIO.new
419
+
420
+ @model = new_model(false)
421
+ DB.create_table!(@model.table_identifier) do
422
+ primary_key :id
423
+ column :status, :string, :default => 'parked'
424
+ end
425
+ @model.class_eval do
426
+ set_dataset(DB[table_identifier])
427
+ get_db_schema(true)
325
428
  end
326
- @model.class_eval { get_db_schema(true) }
327
429
 
328
430
  @machine = StateMachine::Machine.new(@model, :status, :initial => :parked)
329
431
  @record = @model.new
@@ -332,6 +434,77 @@ module SequelTest
332
434
  def test_should_use_machine_default
333
435
  assert_equal 'parked', @record.status
334
436
  end
437
+
438
+ def test_should_not_generate_a_warning
439
+ assert_no_match(/have defined a different default/, $stderr.string)
440
+ end
441
+
442
+ def teardown
443
+ $stderr = @original_stderr
444
+ end
445
+ end
446
+
447
+ class MachineWithDifferentColumnDefaultTest < BaseTestCase
448
+ def setup
449
+ @original_stderr, $stderr = $stderr, StringIO.new
450
+
451
+ @model = new_model(false)
452
+ DB.create_table!(@model.table_identifier) do
453
+ primary_key :id
454
+ column :status, :string, :default => 'idling'
455
+ end
456
+ @model.class_eval do
457
+ set_dataset(DB[table_identifier])
458
+ get_db_schema(true)
459
+ end
460
+
461
+ @machine = StateMachine::Machine.new(@model, :status, :initial => :parked)
462
+ @record = @model.new
463
+ end
464
+
465
+ def test_should_use_machine_default
466
+ assert_equal 'parked', @record.status
467
+ end
468
+
469
+ def test_should_generate_a_warning
470
+ assert_match(/Both SequelTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, $stderr.string)
471
+ end
472
+
473
+ def teardown
474
+ $stderr = @original_stderr
475
+ end
476
+ end
477
+
478
+ class MachineWithDifferentIntegerColumnDefaultTest < BaseTestCase
479
+ def setup
480
+ @original_stderr, $stderr = $stderr, StringIO.new
481
+
482
+ @model = new_model(false)
483
+ DB.create_table!(@model.table_identifier) do
484
+ primary_key :id
485
+ column :status, :integer, :default => 0
486
+ end
487
+ @model.class_eval do
488
+ set_dataset(DB[table_identifier])
489
+ get_db_schema(true)
490
+ end
491
+
492
+ @machine = StateMachine::Machine.new(@model, :status, :initial => :parked)
493
+ @machine.state :parked, :value => 1
494
+ @record = @model.new
495
+ end
496
+
497
+ def test_should_use_machine_default
498
+ assert_equal 1, @record.status
499
+ end
500
+
501
+ def test_should_generate_a_warning
502
+ assert_match(/Both SequelTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, $stderr.string)
503
+ end
504
+
505
+ def teardown
506
+ $stderr = @original_stderr
507
+ end
335
508
  end
336
509
 
337
510
  class MachineWithConflictingPredicateTest < BaseTestCase
@@ -377,8 +550,7 @@ module SequelTest
377
550
  end
378
551
 
379
552
  def test_should_raise_exception_for_predicate_without_parameters
380
- exception = assert_raise(ArgumentError) { @record.state? }
381
- assert_equal 'wrong number of arguments (1 for 2)', exception.message
553
+ assert_raise(ArgumentError) { @record.state? }
382
554
  end
383
555
 
384
556
  def test_should_return_false_for_predicate_if_does_not_match_current_value
@@ -492,8 +664,8 @@ module SequelTest
492
664
  class MachineMultipleTest < BaseTestCase
493
665
  def setup
494
666
  @model = new_model
495
- DB.alter_table :foo do
496
- add_column :status, :string, :default => 'idling'
667
+ DB.alter_table(@model.table_identifier) do
668
+ add_column :status, :string
497
669
  end
498
670
  @model.class_eval { get_db_schema(true) }
499
671
 
@@ -544,7 +716,7 @@ module SequelTest
544
716
  end
545
717
  end
546
718
 
547
- DB.alter_table :foo do
719
+ DB.alter_table(@model.table_identifier) do
548
720
  add_column :updated_at, :datetime
549
721
  end
550
722
  @model.class_eval { get_db_schema(true) }
@@ -607,8 +779,8 @@ module SequelTest
607
779
  class MachineWithDirtyAttributesAndCustomAttributeTest < BaseTestCase
608
780
  def setup
609
781
  @model = new_model
610
- DB.alter_table :foo do
611
- add_column :status, :string, :default => 'idling'
782
+ DB.alter_table(@model.table_identifier) do
783
+ add_column :status, :string
612
784
  end
613
785
  @model.class_eval { get_db_schema(true) }
614
786
 
@@ -630,8 +802,8 @@ module SequelTest
630
802
  class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestCase
631
803
  def setup
632
804
  @model = new_model
633
- DB.alter_table :foo do
634
- add_column :status, :string, :default => 'idling'
805
+ DB.alter_table(@model.table_identifier) do
806
+ add_column :status, :string
635
807
  end
636
808
  @model.class_eval { get_db_schema(true) }
637
809
 
@@ -790,12 +962,22 @@ module SequelTest
790
962
 
791
963
  def test_should_run_around_callbacks
792
964
  before_called = false
793
- after_called = [false]
794
- @machine.around_transition {|block| before_called = true; block.call; after_called[0] = true}
965
+ after_called = false
966
+ ensure_called = 0
967
+ @machine.around_transition do |block|
968
+ before_called = true
969
+ begin
970
+ block.call
971
+ ensure
972
+ ensure_called += 1
973
+ end
974
+ after_called = true
975
+ end
795
976
 
796
977
  @transition.perform
797
978
  assert before_called
798
- assert after_called[0]
979
+ assert after_called
980
+ assert_equal ensure_called, 1
799
981
  end
800
982
 
801
983
  def test_should_run_around_callbacks_with_the_context_of_the_record
@@ -830,6 +1012,33 @@ module SequelTest
830
1012
 
831
1013
  assert_equal [1, 2, 3], @record.callback_result
832
1014
  end
1015
+
1016
+ def test_should_run_in_expected_order
1017
+ expected = [
1018
+ :before_transition, :before_validation, :after_validation,
1019
+ :before_save, :before_create, :after_create, :after_save,
1020
+ :after_transition
1021
+ ]
1022
+
1023
+ callbacks = []
1024
+ @model.before_validation { callbacks << :before_validation }
1025
+ @model.after_validation { callbacks << :after_validation }
1026
+ @model.before_save { callbacks << :before_save }
1027
+ @model.before_create { callbacks << :before_create }
1028
+ @model.after_create { callbacks << :after_create }
1029
+ @model.after_save { callbacks << :after_save }
1030
+ if @model.respond_to?(:after_commit)
1031
+ @model.after_commit { callbacks << :after_commit }
1032
+ expected << :after_commit
1033
+ end
1034
+
1035
+ @machine.before_transition { callbacks << :before_transition }
1036
+ @machine.after_transition { callbacks << :after_transition }
1037
+
1038
+ @transition.perform
1039
+
1040
+ assert_equal expected, callbacks
1041
+ end
833
1042
  end
834
1043
 
835
1044
  class MachineWithFailedBeforeCallbacksTest < BaseTestCase
@@ -869,12 +1078,50 @@ module SequelTest
869
1078
  end
870
1079
  end
871
1080
 
1081
+ class MachineNestedActionTest < BaseTestCase
1082
+ def setup
1083
+ @callbacks = []
1084
+
1085
+ @model = new_model
1086
+ @machine = StateMachine::Machine.new(@model)
1087
+ @machine.event :ignite do
1088
+ transition :parked => :idling
1089
+ end
1090
+
1091
+ @record = @model.new(:state => 'parked')
1092
+ end
1093
+
1094
+ def test_should_allow_transition_prior_to_creation_if_skipping_action
1095
+ record = @record
1096
+ @model.before_create { record.ignite(false) }
1097
+ result = @record.save
1098
+
1099
+ assert result
1100
+ assert_equal "idling", @record.state
1101
+ @record.reload
1102
+ assert_equal "idling", @record.state
1103
+ end
1104
+
1105
+ if !defined?(Sequel::VERSION) || !%w(2.10.0 2.11.0).include?(Sequel::VERSION)
1106
+ def test_should_allow_transition_after_creation
1107
+ record = @record
1108
+ @model.after_create { record.ignite }
1109
+ result = @record.save
1110
+
1111
+ assert result
1112
+ assert_equal "idling", @record.state
1113
+ @record.reload
1114
+ assert_equal "idling", @record.state
1115
+ end
1116
+ end
1117
+ end
1118
+
872
1119
  class MachineWithFailedActionTest < BaseTestCase
873
1120
  def setup
874
1121
  @model = new_model do
875
- plugin(:validation_class_methods) if respond_to?(:plugin)
876
- validates_each :state do |object, attribute, value|
877
- object.errors[attribute] << 'is invalid' unless %w(first_gear).include?(value)
1122
+ def validate
1123
+ super
1124
+ errors[:state] << 'is invalid' unless %w(first_gear).include?(state)
878
1125
  end
879
1126
  end
880
1127
 
@@ -913,7 +1160,7 @@ module SequelTest
913
1160
  end
914
1161
 
915
1162
  class MachineWithFailedAfterCallbacksTest < BaseTestCase
916
- def setup
1163
+ def setup
917
1164
  callbacks = []
918
1165
 
919
1166
  @model = new_model
@@ -1042,7 +1289,10 @@ module SequelTest
1042
1289
 
1043
1290
  @machine = StateMachine::Machine.new(@model)
1044
1291
  @machine.state :first_gear do
1045
- validates_presence_of :seatbelt
1292
+ def validate
1293
+ super if defined?(super)
1294
+ errors[:seatbelt] << 'is not present' if seatbelt.nil?
1295
+ end
1046
1296
  end
1047
1297
  @machine.other_states :parked
1048
1298
  end
@@ -1104,7 +1354,11 @@ module SequelTest
1104
1354
  ran_callback = false
1105
1355
  @machine.around_transition {|block| ran_callback = true; block.call }
1106
1356
 
1107
- @record.valid?
1357
+ begin
1358
+ @record.valid?
1359
+ rescue ArgumentError
1360
+ raise if StateMachine::Transition.pause_supported?
1361
+ end
1108
1362
  assert ran_callback
1109
1363
  end
1110
1364
 
@@ -1124,7 +1378,10 @@ module SequelTest
1124
1378
  def test_should_not_run_after_callbacks_with_failures_disabled_if_validation_fails
1125
1379
  @model.class_eval do
1126
1380
  attr_accessor :seatbelt
1127
- validates_presence_of :seatbelt
1381
+ def validate
1382
+ super
1383
+ errors[:seatbelt] << 'is not present' if seatbelt.nil?
1384
+ end
1128
1385
  end
1129
1386
 
1130
1387
  ran_callback = false
@@ -1137,7 +1394,10 @@ module SequelTest
1137
1394
  def test_should_run_failure_callbacks_if_validation_fails
1138
1395
  @model.class_eval do
1139
1396
  attr_accessor :seatbelt
1140
- validates_presence_of :seatbelt
1397
+ def validate
1398
+ super
1399
+ errors[:seatbelt] << 'is not present' if seatbelt.nil?
1400
+ end
1141
1401
  end
1142
1402
 
1143
1403
  ran_callback = false
@@ -1151,20 +1411,31 @@ module SequelTest
1151
1411
  ran_callback = [false]
1152
1412
  @machine.around_transition {|block| block.call; ran_callback[0] = true }
1153
1413
 
1154
- @record.valid?
1414
+ begin
1415
+ @record.valid?
1416
+ rescue ArgumentError
1417
+ raise if StateMachine::Transition.pause_supported?
1418
+ end
1155
1419
  assert !ran_callback[0]
1156
1420
  end
1157
1421
 
1158
1422
  def test_should_not_run_around_callbacks_after_yield_with_failures_disabled_if_validation_fails
1159
1423
  @model.class_eval do
1160
1424
  attr_accessor :seatbelt
1161
- validates_presence_of :seatbelt
1425
+ def validate
1426
+ super
1427
+ errors[:seatbelt] << 'is not present' if seatbelt.nil?
1428
+ end
1162
1429
  end
1163
1430
 
1164
1431
  ran_callback = [false]
1165
1432
  @machine.around_transition {|block| block.call; ran_callback[0] = true }
1166
1433
 
1167
- @record.valid?
1434
+ begin
1435
+ @record.valid?
1436
+ rescue ArgumentError
1437
+ raise if StateMachine::Transition.pause_supported?
1438
+ end
1168
1439
  assert !ran_callback[0]
1169
1440
  end
1170
1441
 
@@ -1282,29 +1553,17 @@ module SequelTest
1282
1553
  assert !ran_callback
1283
1554
  end
1284
1555
 
1285
- if defined?(Sequel::MAJOR) && Sequel::MAJOR >= 3 && Sequel::MINOR >= 7
1286
- def test_should_not_run_failure_callbacks_if_fails
1287
- @model.before_create {|record| false}
1288
-
1289
- ran_callback = false
1290
- @machine.after_failure { ran_callback = true }
1291
-
1292
- @record.save
1293
- assert !ran_callback
1294
- end
1295
- else
1296
- def test_should_run_failure_callbacks_if_fails
1297
- @model.before_create {|record| false}
1298
-
1299
- ran_callback = false
1300
- @machine.after_failure { ran_callback = true }
1301
-
1302
- @record.save
1303
- assert ran_callback
1304
- end
1556
+ def test_should_run_failure_callbacks_if_fails
1557
+ @model.before_create {|record| false}
1558
+
1559
+ ran_callback = false
1560
+ @machine.after_failure { ran_callback = true }
1561
+
1562
+ @record.save
1563
+ assert ran_callback
1305
1564
  end
1306
1565
 
1307
- def test_should_not_run_before_transitions_within_transaction
1566
+ def test_should_run_before_transitions_within_transaction
1308
1567
  @machine.before_transition { self.class.create; raise Sequel::Error::Rollback }
1309
1568
 
1310
1569
  begin
@@ -1312,7 +1571,7 @@ module SequelTest
1312
1571
  rescue Sequel::Error::Rollback
1313
1572
  end
1314
1573
 
1315
- assert_equal 1, @model.count
1574
+ assert_equal 0, @model.count
1316
1575
  end
1317
1576
 
1318
1577
  def test_should_not_run_around_callbacks_with_failures_disabled_if_fails
@@ -1333,43 +1592,111 @@ module SequelTest
1333
1592
  assert ran_callback[0]
1334
1593
  end
1335
1594
 
1336
- if defined?(Sequel::MAJOR) && (Sequel::MAJOR >= 3 || Sequel::MAJOR == 2 && Sequel::MINOR == 12)
1337
- def test_should_run_after_transitions_within_transaction
1338
- @machine.after_transition { self.class.create; raise Sequel::Error::Rollback }
1595
+ def test_should_run_after_transitions_within_transaction
1596
+ @machine.after_transition { self.class.create; raise Sequel::Error::Rollback }
1597
+
1598
+ @record.save
1599
+
1600
+ assert_equal 0, @model.count
1601
+ end
1602
+
1603
+ def test_should_run_around_transition_within_transaction
1604
+ @machine.around_transition {|block| block.call; self.class.create; raise Sequel::Error::Rollback }
1605
+
1606
+ @record.save
1607
+
1608
+ assert_equal 0, @model.count
1609
+ end
1610
+
1611
+ def test_should_allow_additional_transitions_to_new_state_in_after_transitions
1612
+ @machine.event :park do
1613
+ transition :idling => :parked
1614
+ end
1615
+
1616
+ @machine.after_transition(:on => :ignite) { park }
1617
+
1618
+ @record.save
1619
+ assert_equal 'parked', @record.state
1620
+
1621
+ @record.reload
1622
+ assert_equal 'parked', @record.state
1623
+ end
1624
+
1625
+ def test_should_allow_additional_transitions_to_previous_state_in_after_transitions
1626
+ @machine.event :shift_up do
1627
+ transition :idling => :first_gear
1628
+ end
1629
+
1630
+ @machine.after_transition(:on => :ignite) { shift_up }
1631
+
1632
+ @record.save
1633
+ assert_equal 'first_gear', @record.state
1634
+
1635
+ @record.reload
1636
+ assert_equal 'first_gear', @record.state
1637
+ end
1638
+
1639
+ def test_should_return_nil_on_manual_rollback
1640
+ @machine.before_transition { raise Sequel::Error::Rollback }
1641
+
1642
+ assert_equal nil, @record.save
1643
+ end
1644
+ end
1645
+
1646
+ if defined?(Sequel::VERSION) && Gem::Version.new(Sequel::VERSION) >= Gem::Version.new('3.4.0')
1647
+ class MachineWithEventAttributesOnAutosaveTest < BaseTestCase
1648
+ def setup
1649
+ @vehicle_model = new_model(:vehicle)
1650
+ DB.alter_table(@vehicle_model.table_identifier) do
1651
+ add_column :owner_id, :integer
1652
+ end
1653
+ @vehicle_model.class_eval { get_db_schema(true) }
1654
+ SequelTest.const_set('Vehicle', @vehicle_model)
1339
1655
 
1340
- @record.save
1656
+ @owner_model = new_model(:owner) do
1657
+ plugin :nested_attributes
1658
+ end
1659
+ SequelTest.const_set('Owner', @owner_model)
1341
1660
 
1342
- assert_equal 0, @model.count
1661
+ machine = StateMachine::Machine.new(@vehicle_model)
1662
+ machine.event :ignite do
1663
+ transition :parked => :idling
1664
+ end
1665
+
1666
+ @owner = @owner_model.create
1667
+ @vehicle = @vehicle_model.create(:state => 'parked', :owner_id => @owner.id)
1343
1668
  end
1344
1669
 
1345
- def test_should_run_around_transition_within_transaction
1346
- @machine.around_transition {|block| block.call; self.class.create; raise Sequel::Error::Rollback }
1670
+ def test_should_persist_many_association
1671
+ @owner_model.one_to_many :vehicles, :class_name => 'SequelTest::Vehicle'
1672
+ @owner_model.nested_attributes :vehicles
1347
1673
 
1348
- @record.save
1674
+ @owner.vehicles_attributes = [{:id => @vehicle.id, :state_event => 'ignite'}]
1675
+ @owner.save
1349
1676
 
1350
- assert_equal 0, @model.count
1677
+ @vehicle.reload
1678
+ assert_equal 'idling', @vehicle.state
1351
1679
  end
1352
- else
1353
- def test_should_not_run_after_transitions_within_transaction
1354
- @machine.after_transition { self.class.create; raise Sequel::Error::Rollback }
1355
-
1356
- begin
1357
- @record.save
1358
- rescue Sequel::Error::Rollback
1680
+
1681
+ if Gem::Version.new(Sequel::VERSION) >= Gem::Version.new('3.10.0')
1682
+ def test_should_persist_one_association
1683
+ @owner_model.one_to_one :vehicle, :class_name => 'SequelTest::Vehicle'
1684
+ @owner_model.nested_attributes :vehicle
1685
+
1686
+ @owner.vehicle_attributes = {:id => @vehicle.id, :state_event => 'ignite'}
1687
+ @owner.save
1688
+
1689
+ @vehicle.reload
1690
+ assert_equal 'idling', @vehicle.state
1359
1691
  end
1360
-
1361
- assert_equal 2, @model.count
1362
1692
  end
1363
1693
 
1364
- def test_should_not_run_around_transition_within_transaction
1365
- @machine.around_transition {|block| block.call; self.class.create; raise Sequel::Error::Rollback }
1366
-
1367
- begin
1368
- @record.save
1369
- rescue Sequel::Error::Rollback
1694
+ def teardown
1695
+ SequelTest.class_eval do
1696
+ remove_const('Vehicle')
1697
+ remove_const('Owner')
1370
1698
  end
1371
-
1372
- assert_equal 2, @model.count
1699
+ super
1373
1700
  end
1374
1701
  end
1375
1702
  end
@@ -1422,7 +1749,7 @@ module SequelTest
1422
1749
 
1423
1750
  def test_should_only_include_records_with_state_in_singular_with_scope
1424
1751
  parked = @model.create :state => 'parked'
1425
- idling = @model.create :state => 'idling'
1752
+ @model.create :state => 'idling'
1426
1753
 
1427
1754
  assert_equal [parked], @model.with_state(:parked).all
1428
1755
  end
@@ -1482,7 +1809,7 @@ module SequelTest
1482
1809
  @machine.state :idling, :value => lambda {'idling'}
1483
1810
 
1484
1811
  parked = @model.create :state => 'parked'
1485
- idling = @model.create :state => 'idling'
1812
+ @model.create :state => 'idling'
1486
1813
 
1487
1814
  assert_equal [parked], @model.with_state(:parked).all
1488
1815
  end
@@ -1537,7 +1864,7 @@ module SequelTest
1537
1864
  @vehicle = new_model(:vehicle) do
1538
1865
  many_to_one :company, :class => SequelTest::Company
1539
1866
  end
1540
- DB.alter_table :vehicle do
1867
+ DB.alter_table(@vehicle.table_identifier) do
1541
1868
  add_column :company_id, :integer
1542
1869
  end
1543
1870
  @vehicle.class_eval { get_db_schema(true) }
@@ -1552,11 +1879,11 @@ module SequelTest
1552
1879
  end
1553
1880
 
1554
1881
  def test_should_find_records_in_with_scope
1555
- assert_equal [@mustang], @vehicle.with_states(:parked).join(:company, :id => :company_id).filter(:company__state => 'active').select(:vehicle.*).all
1882
+ assert_equal [@mustang], @vehicle.with_states(:parked).join(@company.table_identifier.value, :id => :company_id).filter(:"#{@company.table_identifier.value}__state" => 'active').select(@vehicle.table_identifier.value.to_sym.*).all
1556
1883
  end
1557
1884
 
1558
1885
  def test_should_find_records_in_without_scope
1559
- assert_equal [@mustang], @vehicle.without_states(:idling).join(:company, :id => :company_id).filter(:company__state => 'active').select(:vehicle.*).all
1886
+ assert_equal [@mustang], @vehicle.without_states(:idling).join(@company.table_identifier.value, :id => :company_id).filter(:"#{@company.table_identifier.value}__state" => 'active').select(@vehicle.table_identifier.value.to_sym.*).all
1560
1887
  end
1561
1888
 
1562
1889
  def teardown