@@ -0,0 +1,24 | |||||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |||
|
2 | <projectDescription> | |||
|
3 | <name>1.1-stable</name> | |||
|
4 | <comment></comment> | |||
|
5 | <projects> | |||
|
6 | </projects> | |||
|
7 | <buildSpec> | |||
|
8 | <buildCommand> | |||
|
9 | <name>org.rubypeople.rdt.core.rubybuilder</name> | |||
|
10 | <arguments> | |||
|
11 | </arguments> | |||
|
12 | </buildCommand> | |||
|
13 | <buildCommand> | |||
|
14 | <name>com.aptana.ide.core.unifiedBuilder</name> | |||
|
15 | <arguments> | |||
|
16 | </arguments> | |||
|
17 | </buildCommand> | |||
|
18 | </buildSpec> | |||
|
19 | <natures> | |||
|
20 | <nature>com.aptana.ide.project.nature.web</nature> | |||
|
21 | <nature>org.rubypeople.rdt.core.rubynature</nature> | |||
|
22 | <nature>org.radrails.rails.core.railsnature</nature> | |||
|
23 | </natures> | |||
|
24 | </projectDescription> |
@@ -66,6 +66,9 class TimeEntry < ActiveRecord::Base | |||||
66 | # these attributes make time aggregations easier |
|
66 | # these attributes make time aggregations easier | |
67 | def spent_on=(date) |
|
67 | def spent_on=(date) | |
68 | super |
|
68 | super | |
|
69 | if spent_on.is_a?(Time) | |||
|
70 | self.spent_on = spent_on.to_date | |||
|
71 | end | |||
69 | self.tyear = spent_on ? spent_on.year : nil |
|
72 | self.tyear = spent_on ? spent_on.year : nil | |
70 | self.tmonth = spent_on ? spent_on.month : nil |
|
73 | self.tmonth = spent_on ? spent_on.month : nil | |
71 | self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil |
|
74 | self.tweek = spent_on ? Date.civil(spent_on.year, spent_on.month, spent_on.day).cweek : nil |
@@ -49,6 +49,42 class TimeEntryTest < ActiveSupport::TestCase | |||||
49 | assert_nil TimeEntry.new.hours |
|
49 | assert_nil TimeEntry.new.hours | |
50 | end |
|
50 | end | |
51 |
|
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 | |||
|
86 | end | |||
|
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 |
General Comments 0
You need to be logged in to leave comments.
Login now