comparison test/unit/.svn/text-base/time_entry_test.rb.svn-base @ 0:513646585e45

* Import Redmine trunk SVN rev 3859
author Chris Cannam
date Fri, 23 Jul 2010 15:52:44 +0100
parents
children 40f7cfd4df19
comparison
equal deleted inserted replaced
-1:000000000000 0:513646585e45
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.dirname(__FILE__) + '/../test_helper'
19
20 class TimeEntryTest < ActiveSupport::TestCase
21 fixtures :issues, :projects, :users, :time_entries
22
23 def test_hours_format
24 assertions = { "2" => 2.0,
25 "21.1" => 21.1,
26 "2,1" => 2.1,
27 "1,5h" => 1.5,
28 "7:12" => 7.2,
29 "10h" => 10.0,
30 "10 h" => 10.0,
31 "45m" => 0.75,
32 "45 m" => 0.75,
33 "3h15" => 3.25,
34 "3h 15" => 3.25,
35 "3 h 15" => 3.25,
36 "3 h 15m" => 3.25,
37 "3 h 15 m" => 3.25,
38 "3 hours" => 3.0,
39 "12min" => 0.2,
40 }
41
42 assertions.each do |k, v|
43 t = TimeEntry.new(:hours => k)
44 assert_equal v, t.hours, "Converting #{k} failed:"
45 end
46 end
47
48 def test_hours_should_default_to_nil
49 assert_nil TimeEntry.new.hours
50 end
51 end