Mercurial > hg > soundsoftware-site
comparison test/unit/time_entry_test.rb @ 524:1248a47e81b3 feature_36
Merge from branch "luisf"
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 25 Jul 2011 14:39:38 +0100 |
parents | 07fa8a8b56a8 |
children | cbb26bc654de |
comparison
equal
deleted
inserted
replaced
519:3be6bc3c2a17 | 524:1248a47e81b3 |
---|---|
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 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 | 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. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 require File.dirname(__FILE__) + '/../test_helper' | 18 require File.expand_path('../../test_helper', __FILE__) |
19 | 19 |
20 class TimeEntryTest < ActiveSupport::TestCase | 20 class TimeEntryTest < ActiveSupport::TestCase |
21 fixtures :issues, :projects, :users, :time_entries | 21 fixtures :issues, :projects, :users, :time_entries |
22 | 22 |
23 def test_hours_format | 23 def test_hours_format |
45 end | 45 end |
46 end | 46 end |
47 | 47 |
48 def test_hours_should_default_to_nil | 48 def test_hours_should_default_to_nil |
49 assert_nil TimeEntry.new.hours | 49 assert_nil TimeEntry.new.hours |
50 end | |
51 | |
52 def test_spent_on_with_blank | |
53 c = TimeEntry.new | |
54 c.spent_on = '' | |
55 assert_nil c.spent_on | |
56 end | |
57 | |
58 def test_spent_on_with_nil | |
59 c = TimeEntry.new | |
60 c.spent_on = nil | |
61 assert_nil c.spent_on | |
62 end | |
63 | |
64 def test_spent_on_with_string | |
65 c = TimeEntry.new | |
66 c.spent_on = "2011-01-14" | |
67 assert_equal Date.parse("2011-01-14"), c.spent_on | |
68 end | |
69 | |
70 def test_spent_on_with_invalid_string | |
71 c = TimeEntry.new | |
72 c.spent_on = "foo" | |
73 assert_nil c.spent_on | |
74 end | |
75 | |
76 def test_spent_on_with_date | |
77 c = TimeEntry.new | |
78 c.spent_on = Date.today | |
79 assert_equal Date.today, c.spent_on | |
80 end | |
81 | |
82 def test_spent_on_with_time | |
83 c = TimeEntry.new | |
84 c.spent_on = Time.now | |
85 assert_equal Date.today, c.spent_on | |
50 end | 86 end |
51 | 87 |
52 context "#earilest_date_for_project" do | 88 context "#earilest_date_for_project" do |
53 setup do | 89 setup do |
54 User.current = nil | 90 User.current = nil |