Reputation: 11098
Say for instance I have a datefield or 3 select fields for day month and yea..
How does the final selection of date get sent to the database? or in what format doesn't it get sent?
20110803 ?
2011-08-03 ?
What I want to do is:
I know an idea of how to write these tests but not sure what actually gets sent to the database What actually appears before save and in what format. String? Integer?
Thanks in advance for responses.
Upvotes: 2
Views: 3470
Reputation: 40333
The gets sent to the database as the database expects it. Each database and configuration will yield a different format for a date but this will not make any difference to you as the field is configured to be Date and it will also be a Date on Rails, so you should not care about the format.
While testing, there are many ways you can validate, but you will not be using neither integer or string, you're using Date objects. Here's an example of how you could write the first one:
it 'should find a model today' do
@date = Date.today
@model = Model.create!(:date => @date)
Model.first( :conditions => {:date => @date}).should == @model
end
Upvotes: 4