summaryrefslogtreecommitdiffstats
path: root/test/task_test.rb
diff options
context:
space:
mode:
authorZack Hobson2013-12-22 23:28:00 -0800
committerZack Hobson2013-12-22 23:28:00 -0800
commit11310cefb8206487337b8040f9ceb70e570a06f7 (patch)
treef9b3624e4210616e48108ff650fa229c125d894d /test/task_test.rb
parentd315a241dbd6c959085b26a413fc5e40683d63f0 (diff)
parentb8d0ef7022541999c2267fc7937f2a60e0da602c (diff)
downloadhcl-11310cefb8206487337b8040f9ceb70e570a06f7.tar.bz2
Merge pull request #46 from zenhob/faraday
Switch to a Faraday-based JSON API client for Harvest.
Diffstat (limited to 'test/task_test.rb')
-rw-r--r--test/task_test.rb63
1 files changed, 11 insertions, 52 deletions
diff --git a/test/task_test.rb b/test/task_test.rb
index f5c30b8..bbdce89 100644
--- a/test/task_test.rb
+++ b/test/task_test.rb
@@ -1,61 +1,20 @@
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
+ def test_cache_tasks_hash
+ HCl::Task.cache_tasks_hash({ projects: [{
+ name: "Click and Type",
+ id: 3,
+ client: "AFS",
+ tasks: [{
+ name: "Security support",
+ id: 14,
+ billable: true
+ }]
+ }]})
assert_equal 1, HCl::Task.all.size
assert_equal 'Security support', HCl::Task.all.first.name
end