#367 invalid
mark

interference with dm-timestamps and dm-validations

Reported by mark | June 11th, 2008 @ 03:44 AM

It seems that when I include both dm-timestamps and dm-validations, my DataMapper models continue to save even when they are invalid.

I have confirmed this by disabling dm-timestamps (and disabled my tests that rely on dm-timestamps), then all tests work as expected.

The following test was used to narrow down this problem:

it "should require a name" do

@person = Person.new

@person.should_not be_valid

@person.errors.on(:name).size.should == 1

@person.errors.on(:name).should include("Name must not be blank")

Person.all.size.should == 0

@person.save

Person.all.size.should == 0

end

When dm-timestamps is disabled, the test passes. When dm-timestamps is included, the test fails on the last assertion (Person.all.size.should == 0) as the model saves, ignoring the validations.

My setup:

merb* 0.9.3

addressable 1.0.4

rspec 1.1.4

data_objects 0.9.1

do_mysql 0.9.1

dm-core 0.9.1

dm-more 0.9.1

Side Note:

It seems the order I include the dependencies is important. In my config/init.rb (merb config file), I have the following:

dependency 'dm-timestamps'

dependency 'dm-validations'

If I reverse the order of the dependencies, I generate numerous errors in my tests, eg:

"super: no superclass method `save'"

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages