class DataMapperTest::MachineWithDirtyAttributesAndCustomAttributeTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 616 def setup @resource = new_resource do property :status, String, :default => 'idling' end @machine = StateMachine::Machine.new(@resource, :status, :initial => :parked) @machine.event :ignite @machine.state :idling @record = @resource.create @transition = StateMachine::Transition.new(@record, @machine, :ignite, :parked, :idling) @transition.perform(false) end
test_should_include_state_in_changed_attributes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 630 def test_should_include_state_in_changed_attributes assert_equal e = {@resource.properties[:status] => 'idling'}, @record.dirty_attributes end
test_should_not_reset_changes_on_multiple_transitions()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 642 def test_should_not_reset_changes_on_multiple_transitions transition = StateMachine::Transition.new(@record, @machine, :ignite, :idling, :idling) transition.perform(false) if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0') assert_equal e = {@resource.properties[:status] => 'parked'}, @record.original_attributes else assert_equal e = {:status => 'parked'}, @record.original_values end end
test_should_track_attribute_change()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 634 def test_should_track_attribute_change if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0') assert_equal e = {@resource.properties[:status] => 'parked'}, @record.original_attributes else assert_equal e = {:status => 'parked'}, @record.original_values end end