Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed issue caused by Harvest API change

  • Loading branch information...
commit 1b5a311d871adbecd25332c1f0dd38e989978004 1 parent 1fd7445
Jim Mulholland authored
14 README.rdoc
View
@@ -1,22 +1,10 @@
-= Harvest Plugin For Redmine
-
-==Overview
-
-The object of this plugin is to sync timesheet data from {Harvest}[http://www.getharvest.com/] with individual projects within Redmine. When activated, this plugin will include a new "Harvest" tab and a "Harvest Time" section on the issue detail page with a summed up total of hours tied to a Redmine issue. Harvest time entries are tied to Redmine issues by included #ticket_no (ie #1234) in the text portion of the timesheet entry.
-
-Currently, data is automatically imported for the past week's worth of data every time a user goes to the "Harvest" tab of a particular Redmine project.
+= harvest
==Installation
- Install the plugin as described at: http://www.redmine.org/wiki/redmine/Plugins, according to the way you've obtained the plugin (this plugin does not require a plugin database migration)
-- Install the {Harvestr}[http://github.com/squeejee/harvestr] plugin
- Restart Redmine
-- Create a "config/harvest.yml" file with the following:
- domain: <Harvest subdomain>
- email: <Harvest email address>
- password: <Harvest password>
-
==Global setup
Before you can actually use the plugin within the preferred projects some setup has to be done first.
BIN  app/.DS_Store
View
Binary file not shown
12 app/models/harvest_time.rb
View
@@ -40,7 +40,17 @@ def self.import_time(project)
ht = HarvestTime.find_or_create_by_id(entry.id)
- ht.update_attributes(entry.to_hash)
+ # Key names from the Harvest API
+ harvest_keys = entry.to_hash.keys
+
+ # Column names of HarvestTime
+ harvest_time_keys = HarvestTime.column_names
+
+ # These keys are not in our db, so do not try to include with the insert / update
+ excess_keys = harvest_keys - harvest_time_keys
+ entry_hash = entry.to_hash.reject {|k,v| excess_keys.include?(k)}
+
+ ht.update_attributes(entry_hash)
end if harvest_entries
end
2  init.rb
View
@@ -15,7 +15,7 @@
name 'Redmine Harvest plugin'
author 'Jim Mulholland'
description 'This is a plugin for Redmine to import project timesheet data from Harvest.'
- version '0.0.1'
+ version '0.0.2'
# This plugin contains settings
settings :default => {
31 test/fixtures/harvest_project_entries_extra_attr.xml
View
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<day-entries type="array">
+ <day-entry>
+ <created-at type="datetime">2009-08-01T02:21:32Z</created-at>
+ <hours type="decimal">4.5</hours>
+ <id type="integer">14316565</id>
+ <is-billed type="boolean">false</is-billed>
+ <is-closed type="boolean">false</is-closed>
+ <notes>This is a test</notes>
+ <project-id type="integer">408960</project-id>
+ <spent-at type="date">2009-07-31</spent-at>
+ <task-id type="integer">333865</task-id>
+ <timer-started-at type="datetime" nil="true"></timer-started-at>
+ <user-id type="integer">86342</user-id>
+ <new-attr>New attribute added to api</new-attr>
+ </day-entry>
+ <day-entry>
+ <created-at type="datetime">2009-08-01T02:21:46Z</created-at>
+ <hours type="decimal">2.0</hours>
+ <id type="integer">14316569</id>
+ <is-billed type="boolean">false</is-billed>
+ <is-closed type="boolean">false</is-closed>
+ <notes>Ticket #1234 - Working on stuff</notes>
+ <project-id type="integer">408960</project-id>
+ <spent-at type="date">2009-07-31</spent-at>
+ <task-id type="integer">333867</task-id>
+ <timer-started-at type="datetime" nil="true"></timer-started-at>
+ <user-id type="integer">86342</user-id>
+ <new-attr>New attribute added to api</new-attr>
+ </day-entry>
+</day-entries>
8 test/unit/harvest_times_test.rb
View
@@ -32,5 +32,13 @@ class HarvestTimesTest < ActiveSupport::TestCase
should "extract out integers prepended by # and store as issue_id" do
assert HarvestTime.find(14316569).issue_id == 1234
end
+
+ should "be successful if attributes are added to Harvest api" do
+ url = /http:\/\/test%40example.com:OU812@testing.harvestapp.com\/projects\/408960\/entries.*/
+ stub_get url, 'harvest_project_entries_extra_attr.xml'
+ project = Project.first
+ assert HarvestTime.import_time(project)
+ end
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.