Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…te_time@74 20afb1e0-9c0e-0410-9884-91ed27886737
  • Loading branch information
jonathan committed Jun 30, 2006
1 parent 1c1b2f0 commit d23eda2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions Rakefile
@@ -0,0 +1,22 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the validates_date_time plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the validates_date_time plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'validates_date_time'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
4 changes: 3 additions & 1 deletion lib/validates_date_time.rb
Expand Up @@ -104,7 +104,9 @@ def validates_#{validator}(*attr_names)
validates_each(attr_names, configuration) do |record, attr_name, value|
value_to_parse = record.send("\#{attr_name}_before_type_cast")
unless value_to_parse.blank? && allow_nil
if value_to_parse.blank? && allow_nil
record.send("\#{attr_name}=", nil)
else
value_to_parse = parse_date_time(value_to_parse) rescue value_to_parse
begin
Expand Down
2 changes: 1 addition & 1 deletion test/time_test.rb
Expand Up @@ -57,6 +57,6 @@ def test_before

def test_blank
assert p.update_attributes(:time_of_birth => "")
assert_nil p.time_of_birth, 'require Rails >= r4327 to pass'
assert_nil p.time_of_birth
end
end

0 comments on commit d23eda2

Please sign in to comment.