aiaio-harvest 0.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/harvest/base.rb +3 -2
- data/test/integration/project_integration.rb +19 -0
- data/test/unit/base_test.rb +13 -0
- metadata +4 -1
data/README.rdoc
CHANGED
@@ -19,7 +19,7 @@ All calls to the Harvest API will originate from a Harvest object. Initialize it
|
|
19
19
|
:sub_domain => "joeandcompany",
|
20
20
|
:headers => {"User-Agent" => "MyCompany"})
|
21
21
|
|
22
|
-
The _headers_ argument is optional.
|
22
|
+
The _headers_ argument is optional. Use <b>:ssl => true</b> if your account requires HTTPS.
|
23
23
|
|
24
24
|
=== Clients
|
25
25
|
|
data/lib/harvest/base.rb
CHANGED
@@ -4,12 +4,13 @@ module Harvest
|
|
4
4
|
# Requires a sub_domain, email, and password.
|
5
5
|
# Specifying headers is optional, but useful for setting a user agent.
|
6
6
|
def initialize(options={})
|
7
|
-
options.assert_valid_keys(:email, :password, :sub_domain, :headers)
|
7
|
+
options.assert_valid_keys(:email, :password, :sub_domain, :headers, :ssl)
|
8
8
|
options.assert_required_keys(:email, :password, :sub_domain)
|
9
9
|
@email = options[:email]
|
10
10
|
@password = options[:password]
|
11
11
|
@sub_domain = options[:sub_domain]
|
12
12
|
@headers = options[:headers]
|
13
|
+
@ssl = options[:ssl]
|
13
14
|
configure_base_resource
|
14
15
|
end
|
15
16
|
|
@@ -54,7 +55,7 @@ module Harvest
|
|
54
55
|
# Configure resource base class so that
|
55
56
|
# inherited classes can access the api.
|
56
57
|
def configure_base_resource
|
57
|
-
HarvestResource.site = "http://#{@sub_domain}.#{Harvest::ApiDomain}"
|
58
|
+
HarvestResource.site = "http#{'s' if @ssl}://#{@sub_domain}.#{Harvest::ApiDomain}"
|
58
59
|
HarvestResource.user = @email
|
59
60
|
HarvestResource.password = @password
|
60
61
|
HarvestResource.headers.update(@headers) if @headers.is_a?(Hash)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ProjectIntegration < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def test_should_create_and_update_a_new_project
|
4
|
+
# create
|
5
|
+
project = $harvest.projects.new
|
6
|
+
project.name = "HarvestGem Project"
|
7
|
+
project.active = false
|
8
|
+
project.bill_by = "None"
|
9
|
+
project.client_id = $test_client.id
|
10
|
+
project.save
|
11
|
+
|
12
|
+
# update
|
13
|
+
$test_project = $harvest.projects.find(:all).detect {|c| c.name == "HarvestGem Project"}
|
14
|
+
project.active = true
|
15
|
+
project.save
|
16
|
+
assert $harvest.projects.find($test_project.id).active?
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/test/unit/base_test.rb
CHANGED
@@ -66,6 +66,19 @@ class BaseTest < Test::Unit::TestCase
|
|
66
66
|
assert_equal Harvest::Resources::Task, @harvest.tasks
|
67
67
|
end
|
68
68
|
|
69
|
+
context "with SSL enabled" do
|
70
|
+
setup do
|
71
|
+
@harvest = Harvest::Base.new(:email => @email,
|
72
|
+
:password => @password,
|
73
|
+
:sub_domain => @sub_domain,
|
74
|
+
:headers => @headers,
|
75
|
+
:ssl => true)
|
76
|
+
end
|
77
|
+
|
78
|
+
should "have https in URL" do
|
79
|
+
assert_equal "https://bond.harvestapp.com", Harvest::HarvestResource.site.to_s
|
80
|
+
end
|
81
|
+
end
|
69
82
|
end
|
70
83
|
|
71
84
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aiaio-harvest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Banker
|
@@ -15,6 +15,7 @@ default_executable:
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activeresource
|
18
|
+
type: :runtime
|
18
19
|
version_requirement:
|
19
20
|
version_requirements: !ruby/object:Gem::Requirement
|
20
21
|
requirements:
|
@@ -24,6 +25,7 @@ dependencies:
|
|
24
25
|
version:
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: aiaio-active_resource_throttle
|
28
|
+
type: :runtime
|
27
29
|
version_requirement:
|
28
30
|
version_requirements: !ruby/object:Gem::Requirement
|
29
31
|
requirements:
|
@@ -99,6 +101,7 @@ test_files:
|
|
99
101
|
- test/integration/client_integration.rb
|
100
102
|
- test/integration/task_integration.rb
|
101
103
|
- test/integration/expense_category_integration.rb
|
104
|
+
- test/integration/project_integration.rb
|
102
105
|
- test/integration/harvest_integration_test.rb
|
103
106
|
- test/integration/client_teardown.rb
|
104
107
|
- test/integration/expense_category_teardown.rb
|