~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activerecord/test/cases/date_time_test.rb

  • Committer: Michael Forrest
  • Date: 2010-10-15 16:28:50 UTC
  • Revision ID: michael.forrest@canonical.com-20101015162850-tj2vchanv0kr0dun
refrozeĀ gems

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require "cases/helper"
 
2
require 'models/topic'
 
3
require 'models/task'
 
4
 
 
5
class DateTimeTest < ActiveRecord::TestCase
 
6
  def test_saves_both_date_and_time
 
7
    time_values = [1807, 2, 10, 15, 30, 45]
 
8
    now = DateTime.civil(*time_values)
 
9
 
 
10
    task = Task.new
 
11
    task.starting = now
 
12
    task.save!
 
13
 
 
14
    # check against Time.local_time, since some platforms will return a Time instead of a DateTime
 
15
    assert_equal Time.local_time(*time_values), Task.find(task.id).starting
 
16
  end
 
17
 
 
18
  def test_assign_empty_date_time
 
19
    task = Task.new
 
20
    task.starting = ''
 
21
    task.ending = nil
 
22
    assert_nil task.starting
 
23
    assert_nil task.ending
 
24
  end
 
25
 
 
26
  def test_assign_empty_date
 
27
    topic = Topic.new
 
28
    topic.last_read = ''
 
29
    assert_nil topic.last_read
 
30
  end
 
31
 
 
32
  def test_assign_empty_time
 
33
    topic = Topic.new
 
34
    topic.bonus_time = ''
 
35
    assert_nil topic.bonus_time
 
36
  end
 
37
end