class DataMapperTest::MachineWithDirtyAttributeAndStateEventsTest
Public Instance Methods
setup()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 684 def setup @resource = new_resource @machine = StateMachine::Machine.new(@resource, :initial => :parked) @machine.event :ignite @record = @resource.create @record.state_event = 'ignite' end
test_should_include_state_in_changed_attributes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 693 def test_should_include_state_in_changed_attributes assert_equal e = {@resource.properties[:state] => 'parked'}, @record.dirty_attributes end
test_should_not_include_state_in_changed_attributes_if_nil()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 719 def test_should_not_include_state_in_changed_attributes_if_nil @record = @resource.create @record.state_event = nil assert_equal e = {}, @record.dirty_attributes end
test_should_not_reset_changes_on_multiple_changes()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 707 def test_should_not_reset_changes_on_multiple_changes @record.state_event = 'ignite' if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.3') assert_equal e = {@resource.properties[:state] => 'parked'}, @record.original_attributes elsif Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0') assert_equal e = {@resource.properties[:state] => 'parked-ignored'}, @record.original_attributes else assert_equal e = {:state => 'parked-ignored'}, @record.original_values end end
test_should_track_attribute_change()
click to toggle source
# File test/unit/integrations/data_mapper_test.rb, line 697 def test_should_track_attribute_change if Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.3') assert_equal e = {@resource.properties[:state] => 'parked'}, @record.original_attributes elsif Gem::Version.new(::DataMapper::VERSION) >= Gem::Version.new('0.10.0') assert_equal e = {@resource.properties[:state] => 'parked-ignored'}, @record.original_attributes else assert_equal e = {:state => 'parked-ignored'}, @record.original_values end end