blob: f5c30b8b6c6814f091d9e70e984d2f4552cf4a3f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
class TaskTest < HCl::TestCase
DAILY_ENTRY = %{<daily>
<for_day type="date">Wed, 18 Oct 2006</for_day>
<day_entries>
<day_entry>
<id type="integer">195168</id>
<client>Iridesco</client>
<project>Harvest</project>
<task>Backend Programming</task>
<hours type="float">2.06</hours>
<notes>Test api support</notes>
<timer_started_at type="datetime">
Wed, 18 Oct 2006 09:53:06 -0000
</timer_started_at>
<created_at type="datetime">Wed, 18 Oct 2006 09:53:06 -0000</created_at>
</day_entry>
</day_entries>
</daily>}
def test_add_task
task = HCl::Task.new(id:456, project:HCl::Project.new(id:123))
Date.expects(:today).returns('now')
HCl::Task.expects(:post).with('daily/add', <<-EOT).returns(DAILY_ENTRY)
<request>
<notes>hi world</notes>
<hours>0.5</hours>
<project_id type="integer">123</project_id>
<task_id type="integer">456</task_id>
<spent_at type="date">now</spent_at>
</request>
EOT
task.add note:'hi world', starting_time:0.5
end
def test_cache_file
assert_equal "#{HCl::App::HCL_DIR}/cache/tasks.yml", HCl::Task.cache_file
end
def test_cache_tasks
HCl::Task.cache_tasks(REXML::Document.new(<<-EOD))
<daily>
<projects>
<project>
<name>Click and Type</name>
<code></code>
<id type="integer">3</id>
<client>AFS</client>
<tasks>
<task>
<name>Security support</name>
<id type="integer">14</id>
<billable type="boolean">true</billable>
</task>
</tasks>
</project>
</projects>
</daily>
EOD
assert_equal 1, HCl::Task.all.size
assert_equal 'Security support', HCl::Task.all.first.name
end
end
|