Skip to content
Browse files

fix initializer to keep existing options (originating from superclass)

  • Loading branch information...
1 parent 383a36d commit 1acf14fc3c2701b6a14768c15f1f265893895776 Pascal Zumkehr committed Apr 2, 2012
Showing with 12 additions and 3 deletions.
  1. +2 −2 lib/aasm/base.rb
  2. +3 −0 spec/models/sub_classing.rb
  3. +7 −1 spec/unit/state_transition_spec.rb
View
4 lib/aasm/base.rb
@@ -7,13 +7,13 @@ def initialize(clazz, options={}, &block)
if options.key?(:whiny_transitions)
sm.config.whiny_transitions = options[:whiny_transitions]
- else
+ elsif sm.config.whiny_transitions.nil?
sm.config.whiny_transitions = true # this is the default, so let's cry
end
if options.key?(:skip_validation_on_save)
sm.config.skip_validation_on_save = options[:skip_validation_on_save]
- else
+ elsif sm.config.skip_validation_on_save.nil?
sm.config.skip_validation_on_save = false # this is the default, so don't store any new state if the model is invalid
end
end
View
3 spec/models/sub_classing.rb
@@ -0,0 +1,3 @@
+class SubClassing < Silencer
+
+end
View
8 spec/unit/state_transition_spec.rb
@@ -8,12 +8,18 @@
process.should be_sleeping
end
- it 'should not raise an exception when whiny' do
+ it 'should not raise an exception when not whiny' do
silencer = Silencer.new
silencer.smile!.should be_false
silencer.should be_silent
end
+ it 'should not raise an exception when superclass not whiny' do
+ sub = SubClassing.new
+ sub.smile!.should be_false
+ sub.should be_silent
+ end
+
end
describe AASM::SupportingClasses::StateTransition do

0 comments on commit 1acf14f

Please sign in to comment.
Something went wrong with that request. Please try again.