freeagent_api 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/README.rdoc +194 -22
- data/Rakefile +4 -5
- data/VERSION +1 -1
- data/freeagent_api.gemspec +46 -17
- data/lib/freeagent_api.rb +78 -135
- data/test/authentication_test.rb +13 -0
- data/test/company_test.rb +33 -0
- data/test/contact_test.rb +62 -0
- data/test/invoice_item_test.rb +66 -0
- data/test/invoice_test.rb +70 -0
- data/test/project_test.rb +106 -0
- data/test/stubs/company/invoice_timeline +91 -0
- data/test/stubs/company/tax_timeline +28 -0
- data/test/stubs/contacts/find_all +391 -0
- data/test/stubs/contacts/find_single +29 -0
- data/test/stubs/http/200 +3 -0
- data/test/stubs/http/201 +4 -0
- data/test/stubs/invoice_items/find_all +40 -0
- data/test/stubs/invoice_items/find_single +15 -0
- data/test/stubs/invoices/find_all +239 -0
- data/test/stubs/invoices/find_single +57 -0
- data/test/stubs/projects/find_all +92 -0
- data/test/stubs/projects/find_single +22 -0
- data/test/stubs/projects/invoices +92 -0
- data/test/stubs/projects/timeslips +223 -0
- data/test/stubs/tasks/find_all +42 -0
- data/test/stubs/tasks/find_single +10 -0
- data/test/stubs/timeslips/find_all +52 -0
- data/test/stubs/timeslips/find_single +14 -0
- data/test/task_test.rb +60 -0
- data/test/test_helper.rb +83 -0
- data/test/timeslip_test.rb +62 -0
- metadata +41 -19
- data/test/freeagent_api_test.rb +0 -7
@@ -0,0 +1,223 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Status: 200
|
3
|
+
Content-Type: application/xml; charset=utf-8
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<timeslips type="array">
|
7
|
+
<timeslip>
|
8
|
+
<comment></comment>
|
9
|
+
<dated-on type="datetime">2009-09-09T00:00:00Z</dated-on>
|
10
|
+
<hours type="decimal">3.75</hours>
|
11
|
+
<id type="integer">74814</id>
|
12
|
+
<task-id type="integer">13161</task-id>
|
13
|
+
<updated-at type="datetime">2009-09-14T19:56:37Z</updated-at>
|
14
|
+
<user-id type="integer">5193</user-id>
|
15
|
+
</timeslip>
|
16
|
+
<timeslip>
|
17
|
+
<comment></comment>
|
18
|
+
<dated-on type="datetime">2009-09-09T00:00:00Z</dated-on>
|
19
|
+
<hours type="decimal">3.75</hours>
|
20
|
+
<id type="integer">74815</id>
|
21
|
+
<task-id type="integer">12684</task-id>
|
22
|
+
<updated-at type="datetime">2009-09-14T19:56:37Z</updated-at>
|
23
|
+
<user-id type="integer">5193</user-id>
|
24
|
+
</timeslip>
|
25
|
+
<timeslip>
|
26
|
+
<comment></comment>
|
27
|
+
<dated-on type="datetime">2009-09-10T00:00:00Z</dated-on>
|
28
|
+
<hours type="decimal">3.75</hours>
|
29
|
+
<id type="integer">75967</id>
|
30
|
+
<task-id type="integer">12683</task-id>
|
31
|
+
<updated-at type="datetime">2009-09-14T19:56:36Z</updated-at>
|
32
|
+
<user-id type="integer">5193</user-id>
|
33
|
+
</timeslip>
|
34
|
+
<timeslip>
|
35
|
+
<comment></comment>
|
36
|
+
<dated-on type="datetime">2009-09-10T00:00:00Z</dated-on>
|
37
|
+
<hours type="decimal">3.75</hours>
|
38
|
+
<id type="integer">75966</id>
|
39
|
+
<task-id type="integer">13161</task-id>
|
40
|
+
<updated-at type="datetime">2009-09-14T19:56:37Z</updated-at>
|
41
|
+
<user-id type="integer">5193</user-id>
|
42
|
+
</timeslip>
|
43
|
+
<timeslip>
|
44
|
+
<comment></comment>
|
45
|
+
<dated-on type="datetime">2009-09-11T00:00:00Z</dated-on>
|
46
|
+
<hours type="decimal">7.5</hours>
|
47
|
+
<id type="integer">75968</id>
|
48
|
+
<task-id type="integer">13161</task-id>
|
49
|
+
<updated-at type="datetime">2009-09-14T19:56:37Z</updated-at>
|
50
|
+
<user-id type="integer">5193</user-id>
|
51
|
+
</timeslip>
|
52
|
+
<timeslip>
|
53
|
+
<comment></comment>
|
54
|
+
<dated-on type="datetime">2009-09-14T00:00:00Z</dated-on>
|
55
|
+
<hours type="decimal">7.5</hours>
|
56
|
+
<id type="integer">76010</id>
|
57
|
+
<task-id type="integer">13161</task-id>
|
58
|
+
<updated-at type="datetime">2009-09-14T22:33:55Z</updated-at>
|
59
|
+
<user-id type="integer">5193</user-id>
|
60
|
+
</timeslip>
|
61
|
+
<timeslip>
|
62
|
+
<comment></comment>
|
63
|
+
<dated-on type="datetime">2009-09-15T00:00:00Z</dated-on>
|
64
|
+
<hours type="decimal">3.75</hours>
|
65
|
+
<id type="integer">76292</id>
|
66
|
+
<task-id type="integer">13161</task-id>
|
67
|
+
<updated-at type="datetime">2009-09-15T20:13:10Z</updated-at>
|
68
|
+
<user-id type="integer">5193</user-id>
|
69
|
+
</timeslip>
|
70
|
+
<timeslip>
|
71
|
+
<comment></comment>
|
72
|
+
<dated-on type="datetime">2009-09-16T00:00:00Z</dated-on>
|
73
|
+
<hours type="decimal">7.5</hours>
|
74
|
+
<id type="integer">78004</id>
|
75
|
+
<task-id type="integer">12683</task-id>
|
76
|
+
<updated-at type="datetime">2009-09-20T11:39:39Z</updated-at>
|
77
|
+
<user-id type="integer">5193</user-id>
|
78
|
+
</timeslip>
|
79
|
+
<timeslip>
|
80
|
+
<comment></comment>
|
81
|
+
<dated-on type="datetime">2009-09-17T00:00:00Z</dated-on>
|
82
|
+
<hours type="decimal">7.5</hours>
|
83
|
+
<id type="integer">78005</id>
|
84
|
+
<task-id type="integer">12683</task-id>
|
85
|
+
<updated-at type="datetime">2009-09-20T11:39:47Z</updated-at>
|
86
|
+
<user-id type="integer">5193</user-id>
|
87
|
+
</timeslip>
|
88
|
+
<timeslip>
|
89
|
+
<comment></comment>
|
90
|
+
<dated-on type="datetime">2009-09-18T00:00:00Z</dated-on>
|
91
|
+
<hours type="decimal">7.5</hours>
|
92
|
+
<id type="integer">78006</id>
|
93
|
+
<task-id type="integer">12683</task-id>
|
94
|
+
<updated-at type="datetime">2009-09-20T11:39:55Z</updated-at>
|
95
|
+
<user-id type="integer">5193</user-id>
|
96
|
+
</timeslip>
|
97
|
+
<timeslip>
|
98
|
+
<comment></comment>
|
99
|
+
<dated-on type="datetime">2009-09-21T00:00:00Z</dated-on>
|
100
|
+
<hours type="decimal">7.5</hours>
|
101
|
+
<id type="integer">78793</id>
|
102
|
+
<task-id type="integer">12683</task-id>
|
103
|
+
<updated-at type="datetime">2009-09-22T15:52:37Z</updated-at>
|
104
|
+
<user-id type="integer">5193</user-id>
|
105
|
+
</timeslip>
|
106
|
+
<timeslip>
|
107
|
+
<comment></comment>
|
108
|
+
<dated-on type="datetime">2009-09-22T00:00:00Z</dated-on>
|
109
|
+
<hours type="decimal">3.75</hours>
|
110
|
+
<id type="integer">78794</id>
|
111
|
+
<task-id type="integer">12683</task-id>
|
112
|
+
<updated-at type="datetime">2009-09-22T15:52:46Z</updated-at>
|
113
|
+
<user-id type="integer">5193</user-id>
|
114
|
+
</timeslip>
|
115
|
+
<timeslip>
|
116
|
+
<comment></comment>
|
117
|
+
<dated-on type="datetime">2009-09-23T00:00:00Z</dated-on>
|
118
|
+
<hours type="decimal">7.5</hours>
|
119
|
+
<id type="integer">79115</id>
|
120
|
+
<task-id type="integer">12683</task-id>
|
121
|
+
<updated-at type="datetime">2009-09-23T19:12:53Z</updated-at>
|
122
|
+
<user-id type="integer">5193</user-id>
|
123
|
+
</timeslip>
|
124
|
+
<timeslip>
|
125
|
+
<comment></comment>
|
126
|
+
<dated-on type="datetime">2009-09-24T00:00:00Z</dated-on>
|
127
|
+
<hours type="decimal">7.5</hours>
|
128
|
+
<id type="integer">79691</id>
|
129
|
+
<task-id type="integer">12683</task-id>
|
130
|
+
<updated-at type="datetime">2009-09-24T18:58:44Z</updated-at>
|
131
|
+
<user-id type="integer">5193</user-id>
|
132
|
+
</timeslip>
|
133
|
+
<timeslip>
|
134
|
+
<comment></comment>
|
135
|
+
<dated-on type="datetime">2009-09-25T00:00:00Z</dated-on>
|
136
|
+
<hours type="decimal">7.5</hours>
|
137
|
+
<id type="integer">80083</id>
|
138
|
+
<task-id type="integer">12684</task-id>
|
139
|
+
<updated-at type="datetime">2009-09-25T17:45:32Z</updated-at>
|
140
|
+
<user-id type="integer">5193</user-id>
|
141
|
+
</timeslip>
|
142
|
+
<timeslip>
|
143
|
+
<comment></comment>
|
144
|
+
<dated-on type="datetime">2009-09-28T00:00:00Z</dated-on>
|
145
|
+
<hours type="decimal">7.5</hours>
|
146
|
+
<id type="integer">82076</id>
|
147
|
+
<task-id type="integer">12684</task-id>
|
148
|
+
<updated-at type="datetime">2009-10-01T18:59:36Z</updated-at>
|
149
|
+
<user-id type="integer">5193</user-id>
|
150
|
+
</timeslip>
|
151
|
+
<timeslip>
|
152
|
+
<comment></comment>
|
153
|
+
<dated-on type="datetime">2009-09-29T00:00:00Z</dated-on>
|
154
|
+
<hours type="decimal">3.75</hours>
|
155
|
+
<id type="integer">82077</id>
|
156
|
+
<task-id type="integer">12684</task-id>
|
157
|
+
<updated-at type="datetime">2009-10-01T18:59:44Z</updated-at>
|
158
|
+
<user-id type="integer">5193</user-id>
|
159
|
+
</timeslip>
|
160
|
+
<timeslip>
|
161
|
+
<comment></comment>
|
162
|
+
<dated-on type="datetime">2009-09-29T00:00:00Z</dated-on>
|
163
|
+
<hours type="decimal">3.75</hours>
|
164
|
+
<id type="integer">82078</id>
|
165
|
+
<task-id type="integer">12683</task-id>
|
166
|
+
<updated-at type="datetime">2009-10-01T18:59:55Z</updated-at>
|
167
|
+
<user-id type="integer">5193</user-id>
|
168
|
+
</timeslip>
|
169
|
+
<timeslip>
|
170
|
+
<comment></comment>
|
171
|
+
<dated-on type="datetime">2009-09-30T00:00:00Z</dated-on>
|
172
|
+
<hours type="decimal">7.5</hours>
|
173
|
+
<id type="integer">82079</id>
|
174
|
+
<task-id type="integer">12683</task-id>
|
175
|
+
<updated-at type="datetime">2009-10-01T19:00:08Z</updated-at>
|
176
|
+
<user-id type="integer">5193</user-id>
|
177
|
+
</timeslip>
|
178
|
+
<timeslip>
|
179
|
+
<comment></comment>
|
180
|
+
<dated-on type="datetime">2009-10-01T00:00:00Z</dated-on>
|
181
|
+
<hours type="decimal">7.5</hours>
|
182
|
+
<id type="integer">82080</id>
|
183
|
+
<task-id type="integer">12683</task-id>
|
184
|
+
<updated-at type="datetime">2009-10-01T19:00:15Z</updated-at>
|
185
|
+
<user-id type="integer">5193</user-id>
|
186
|
+
</timeslip>
|
187
|
+
<timeslip>
|
188
|
+
<comment></comment>
|
189
|
+
<dated-on type="datetime">2009-10-02T00:00:00Z</dated-on>
|
190
|
+
<hours type="decimal">7.5</hours>
|
191
|
+
<id type="integer">82575</id>
|
192
|
+
<task-id type="integer">12684</task-id>
|
193
|
+
<updated-at type="datetime">2009-10-04T00:47:46Z</updated-at>
|
194
|
+
<user-id type="integer">5193</user-id>
|
195
|
+
</timeslip>
|
196
|
+
<timeslip>
|
197
|
+
<comment></comment>
|
198
|
+
<dated-on type="datetime">2009-10-05T00:00:00Z</dated-on>
|
199
|
+
<hours type="decimal">7.5</hours>
|
200
|
+
<id type="integer">84445</id>
|
201
|
+
<task-id type="integer">12683</task-id>
|
202
|
+
<updated-at type="datetime">2009-10-08T15:29:30Z</updated-at>
|
203
|
+
<user-id type="integer">5193</user-id>
|
204
|
+
</timeslip>
|
205
|
+
<timeslip>
|
206
|
+
<comment></comment>
|
207
|
+
<dated-on type="datetime">2009-10-06T00:00:00Z</dated-on>
|
208
|
+
<hours type="decimal">7.5</hours>
|
209
|
+
<id type="integer">84446</id>
|
210
|
+
<task-id type="integer">15291</task-id>
|
211
|
+
<updated-at type="datetime">2009-10-08T15:29:47Z</updated-at>
|
212
|
+
<user-id type="integer">5193</user-id>
|
213
|
+
</timeslip>
|
214
|
+
<timeslip>
|
215
|
+
<comment></comment>
|
216
|
+
<dated-on type="datetime">2009-10-08T00:00:00Z</dated-on>
|
217
|
+
<hours type="decimal">3.75</hours>
|
218
|
+
<id type="integer">84447</id>
|
219
|
+
<task-id type="integer">12683</task-id>
|
220
|
+
<updated-at type="datetime">2009-10-08T15:29:59Z</updated-at>
|
221
|
+
<user-id type="integer">5193</user-id>
|
222
|
+
</timeslip>
|
223
|
+
</timeslips>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Status: 200
|
3
|
+
Content-Type: application/xml; charset=utf-8
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<tasks type="array">
|
7
|
+
<task>
|
8
|
+
<id type="integer">12683</id>
|
9
|
+
<name>Back end development</name>
|
10
|
+
<project-id type="integer">17820</project-id>
|
11
|
+
</task>
|
12
|
+
<task>
|
13
|
+
<id type="integer">12685</id>
|
14
|
+
<name>Briefing and research</name>
|
15
|
+
<project-id type="integer">17820</project-id>
|
16
|
+
</task>
|
17
|
+
<task>
|
18
|
+
<id type="integer">15291</id>
|
19
|
+
<name>Documentation</name>
|
20
|
+
<project-id type="integer">17820</project-id>
|
21
|
+
</task>
|
22
|
+
<task>
|
23
|
+
<id type="integer">12684</id>
|
24
|
+
<name>Front end development</name>
|
25
|
+
<project-id type="integer">17820</project-id>
|
26
|
+
</task>
|
27
|
+
<task>
|
28
|
+
<id type="integer">12921</id>
|
29
|
+
<name>Photography project</name>
|
30
|
+
<project-id type="integer">17820</project-id>
|
31
|
+
</task>
|
32
|
+
<task>
|
33
|
+
<id type="integer">12841</id>
|
34
|
+
<name>Game website development</name>
|
35
|
+
<project-id type="integer">17820</project-id>
|
36
|
+
</task>
|
37
|
+
<task>
|
38
|
+
<id type="integer">13161</id>
|
39
|
+
<name>Mobile website development</name>
|
40
|
+
<project-id type="integer">17820</project-id>
|
41
|
+
</task>
|
42
|
+
</tasks>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Status: 200
|
3
|
+
Content-Type: application/xml; charset=utf-8
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<task>
|
7
|
+
<id type="integer">13161</id>
|
8
|
+
<name>Mobile website development</name>
|
9
|
+
<project-id type="integer">17820</project-id>
|
10
|
+
</task>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Status: 200
|
3
|
+
Content-Type: application/xml; charset=utf-8
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<timeslips type="array">
|
7
|
+
<timeslip>
|
8
|
+
<comment></comment>
|
9
|
+
<dated-on type="datetime">2009-10-01T00:00:00Z</dated-on>
|
10
|
+
<hours type="decimal">7.5</hours>
|
11
|
+
<id type="integer">82080</id>
|
12
|
+
<task-id type="integer">12683</task-id>
|
13
|
+
<updated-at type="datetime">2009-10-01T19:00:15Z</updated-at>
|
14
|
+
<user-id type="integer">5193</user-id>
|
15
|
+
</timeslip>
|
16
|
+
<timeslip>
|
17
|
+
<comment></comment>
|
18
|
+
<dated-on type="datetime">2009-10-02T00:00:00Z</dated-on>
|
19
|
+
<hours type="decimal">7.5</hours>
|
20
|
+
<id type="integer">82575</id>
|
21
|
+
<task-id type="integer">12684</task-id>
|
22
|
+
<updated-at type="datetime">2009-10-04T00:47:46Z</updated-at>
|
23
|
+
<user-id type="integer">5193</user-id>
|
24
|
+
</timeslip>
|
25
|
+
<timeslip>
|
26
|
+
<comment></comment>
|
27
|
+
<dated-on type="datetime">2009-10-05T00:00:00Z</dated-on>
|
28
|
+
<hours type="decimal">7.5</hours>
|
29
|
+
<id type="integer">84445</id>
|
30
|
+
<task-id type="integer">12683</task-id>
|
31
|
+
<updated-at type="datetime">2009-10-08T15:29:30Z</updated-at>
|
32
|
+
<user-id type="integer">5193</user-id>
|
33
|
+
</timeslip>
|
34
|
+
<timeslip>
|
35
|
+
<comment></comment>
|
36
|
+
<dated-on type="datetime">2009-10-06T00:00:00Z</dated-on>
|
37
|
+
<hours type="decimal">7.5</hours>
|
38
|
+
<id type="integer">84446</id>
|
39
|
+
<task-id type="integer">15291</task-id>
|
40
|
+
<updated-at type="datetime">2009-10-08T15:29:47Z</updated-at>
|
41
|
+
<user-id type="integer">5193</user-id>
|
42
|
+
</timeslip>
|
43
|
+
<timeslip>
|
44
|
+
<comment></comment>
|
45
|
+
<dated-on type="datetime">2009-10-08T00:00:00Z</dated-on>
|
46
|
+
<hours type="decimal">3.75</hours>
|
47
|
+
<id type="integer">84447</id>
|
48
|
+
<task-id type="integer">12683</task-id>
|
49
|
+
<updated-at type="datetime">2009-10-08T15:29:59Z</updated-at>
|
50
|
+
<user-id type="integer">5193</user-id>
|
51
|
+
</timeslip>
|
52
|
+
</timeslips>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Status: 200
|
3
|
+
Content-Type: application/xml; charset=utf-8
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
6
|
+
<timeslip>
|
7
|
+
<comment></comment>
|
8
|
+
<dated-on type="datetime">2009-10-05T00:00:00Z</dated-on>
|
9
|
+
<hours type="decimal">7.5</hours>
|
10
|
+
<id type="integer">84445</id>
|
11
|
+
<task-id type="integer">12683</task-id>
|
12
|
+
<updated-at type="datetime">2009-10-08T15:29:30Z</updated-at>
|
13
|
+
<user-id type="integer">5193</user-id>
|
14
|
+
</timeslip>
|
data/test/task_test.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TaskTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Task class" do
|
6
|
+
should "have correct collection path" do
|
7
|
+
assert_equal '/projects/1000/tasks.xml', Task.collection_path(:project_id => 1000)
|
8
|
+
end
|
9
|
+
should "have correct element path" do
|
10
|
+
assert_equal '/projects/1000/tasks/first.xml', Task.element_path(:first, :project_id => 1000)
|
11
|
+
assert_equal '/projects/1000/tasks/1000.xml', Task.element_path(1000, :project_id => 1000)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "Tasks" do
|
16
|
+
setup do
|
17
|
+
@tasks = Task.find :all, :params => {:project_id => 17820}
|
18
|
+
end
|
19
|
+
should "return an array" do
|
20
|
+
assert @tasks.is_a? Array
|
21
|
+
end
|
22
|
+
should "return Tasks" do
|
23
|
+
assert_equal 7, @tasks.size
|
24
|
+
assert @tasks.first.is_a? Task
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "Task" do
|
29
|
+
setup do
|
30
|
+
@task = Task.find 13161, :params => {:project_id => 17820}
|
31
|
+
end
|
32
|
+
should "return a Invoice" do
|
33
|
+
assert @task.is_a? Task
|
34
|
+
end
|
35
|
+
should "update and save" do
|
36
|
+
@task.name = 'Development'
|
37
|
+
assert @task.save
|
38
|
+
end
|
39
|
+
should "be destroyed" do
|
40
|
+
assert @task.destroy
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
#TODO - Add test for invalid resource
|
45
|
+
# Need support from fakeweb in order to achieve this
|
46
|
+
|
47
|
+
context "New Task" do
|
48
|
+
setup do
|
49
|
+
params = {
|
50
|
+
:project_id => '17820',
|
51
|
+
:name => 'Creative design'
|
52
|
+
}
|
53
|
+
@task = Task.new params
|
54
|
+
end
|
55
|
+
should "validate and save" do
|
56
|
+
assert @task.save_with_validation
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,10 +1,93 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
+
require 'fakeweb'
|
5
|
+
require 'pp'
|
4
6
|
|
5
7
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
8
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
9
|
+
|
7
10
|
require 'freeagent_api'
|
11
|
+
include Freeagent
|
12
|
+
|
13
|
+
Freeagent.authenticate({
|
14
|
+
:domain => 'testuser.freeagentcentral.com',
|
15
|
+
:username => 'testuser',
|
16
|
+
:password => 'testpass'})
|
17
|
+
|
18
|
+
FakeWeb.allow_net_connect = false
|
19
|
+
|
20
|
+
def stub_file(path)
|
21
|
+
File.join(File.dirname(__FILE__), 'stubs', path)
|
22
|
+
end
|
23
|
+
|
24
|
+
def fake_it_all
|
25
|
+
FakeWeb.clean_registry
|
26
|
+
|
27
|
+
site_url = 'https://testuser:testpass@testuser.freeagentcentral.com'
|
28
|
+
|
29
|
+
# GET URLs
|
30
|
+
{ '/company/invoice_timeline.xml' => File.join('company', 'invoice_timeline'),
|
31
|
+
'/company/tax_timeline.xml' => File.join('company', 'tax_timeline'),
|
32
|
+
'/contacts.xml' => File.join('contacts', 'find_all'),
|
33
|
+
'/contacts/27309.xml' => File.join('contacts', 'find_single'),
|
34
|
+
'/projects.xml' => File.join('projects', 'find_all'),
|
35
|
+
'/projects/17820.xml' => File.join('projects', 'find_single'),
|
36
|
+
'/projects/17820/tasks.xml' => File.join('tasks', 'find_all'),
|
37
|
+
'/projects/17820/tasks/13161.xml' => File.join('tasks', 'find_single'),
|
38
|
+
'/invoices.xml' => File.join('invoices', 'find_all'),
|
39
|
+
'/invoices/73867.xml' => File.join('invoices', 'find_single'),
|
40
|
+
'/projects/17820/invoices.xml' => File.join('projects', 'invoices'),
|
41
|
+
'/invoices/73867/invoice_items.xml' => File.join('invoice_items', 'find_all'),
|
42
|
+
'/invoices/73867/invoice_items/169399.xml' => File.join('invoice_items', 'find_single'),
|
43
|
+
'/timeslips.xml?view=2009-10-01_2009-10-10' => File.join('timeslips', 'find_all'),
|
44
|
+
'/timeslips/84445.xml' => File.join('timeslips', 'find_single'),
|
45
|
+
'/projects/17820/timeslips.xml' => File.join('projects', 'timeslips'),
|
46
|
+
}.each do |path, stub|
|
47
|
+
FakeWeb.register_uri(:get, site_url+path, :response => stub_file(stub))
|
48
|
+
end
|
49
|
+
|
50
|
+
# POST URLs
|
51
|
+
{ '/contacts.xml' => File.join('http', '201'),
|
52
|
+
'/projects.xml' => File.join('http', '201'),
|
53
|
+
'/projects/17820/tasks.xml' => File.join('http', '201'),
|
54
|
+
'/invoices.xml' => File.join('http', '201'),
|
55
|
+
'/invoices/73867/invoice_items.xml' => File.join('http', '201'),
|
56
|
+
'/timeslips.xml' => File.join('http', '201'),
|
57
|
+
}.each do |path, stub|
|
58
|
+
FakeWeb.register_uri(:post, site_url+path, :response => stub_file(stub))
|
59
|
+
end
|
60
|
+
|
61
|
+
# PUT URLs
|
62
|
+
{ '/contacts/27309.xml' => File.join('http', '200'),
|
63
|
+
'/projects/17820.xml' => File.join('http', '200'),
|
64
|
+
'/projects/17820/tasks/13161.xml' => File.join('http', '200'),
|
65
|
+
'/invoices/73867.xml' => File.join('http', '200'),
|
66
|
+
'/invoices/73867/mark_as_draft.xml' => File.join('http', '200'),
|
67
|
+
'/invoices/73867/mark_as_sent.xml' => File.join('http', '200'),
|
68
|
+
'/invoices/73867/mark_as_cancelled.xml' => File.join('http', '200'),
|
69
|
+
'/invoices/66913.xml' => File.join('http', '200'),
|
70
|
+
'/invoices/73867/invoice_items/169399.xml' => File.join('http', '200'),
|
71
|
+
'/timeslips/84445.xml' => File.join('http', '200'),
|
72
|
+
'/timeslips/74814.xml' => File.join('http', '200'),
|
73
|
+
}.each do |path, stub|
|
74
|
+
FakeWeb.register_uri(:put, site_url+path, :response => stub_file(stub))
|
75
|
+
end
|
76
|
+
|
77
|
+
# DELETE URLs
|
78
|
+
{ '/contacts/27309.xml' => File.join('http', '200'),
|
79
|
+
'/projects/17820.xml' => File.join('http', '200'),
|
80
|
+
'/projects/17820/tasks/13161.xml' => File.join('http', '200'),
|
81
|
+
'/invoices/73867.xml' => File.join('http', '200'),
|
82
|
+
'/invoices/66913.xml' => File.join('http', '200'),
|
83
|
+
'/invoices/73867/invoice_items/169399.xml' => File.join('http', '200'),
|
84
|
+
'/timeslips/84445.xml' => File.join('http', '200'),
|
85
|
+
'/timeslips/74814.xml' => File.join('http', '200'),
|
86
|
+
}.each do |path, stub|
|
87
|
+
FakeWeb.register_uri(:delete, site_url+path, :response => stub_file(stub))
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
8
91
|
|
9
92
|
class Test::Unit::TestCase
|
10
93
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TimeslipTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "Timeslip class" do
|
6
|
+
should "have correct collection path" do
|
7
|
+
assert_equal '/timeslips.xml', Timeslip.collection_path
|
8
|
+
end
|
9
|
+
should "have correct element path" do
|
10
|
+
assert_equal '/timeslips/first.xml', Timeslip.element_path(:first)
|
11
|
+
assert_equal '/timeslips/1000.xml', Timeslip.element_path(1000)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "Timeslips" do
|
16
|
+
setup do
|
17
|
+
@timeslips = Timeslip.find :all, :params => {:from => '2009-10-01', :to => '2009-10-10'}
|
18
|
+
end
|
19
|
+
should "return an array" do
|
20
|
+
assert @timeslips.is_a? Array
|
21
|
+
end
|
22
|
+
should "return Timeslips" do
|
23
|
+
assert_equal 5, @timeslips.size
|
24
|
+
assert @timeslips.first.is_a? Timeslip
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "Timeslip" do
|
29
|
+
setup do
|
30
|
+
@timeslip = Timeslip.find 84445
|
31
|
+
end
|
32
|
+
should "return a Invoice" do
|
33
|
+
assert @timeslip.is_a? Timeslip
|
34
|
+
end
|
35
|
+
should "update and save" do
|
36
|
+
@timeslip.hours = '10'
|
37
|
+
assert @timeslip.save
|
38
|
+
end
|
39
|
+
should "be destroyed" do
|
40
|
+
assert @timeslip.destroy
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
#TODO - Add test for invalid resource
|
45
|
+
# Need support from fakeweb in order to achieve this
|
46
|
+
|
47
|
+
context "New Timeslip" do
|
48
|
+
setup do
|
49
|
+
params = {
|
50
|
+
:user_id => '5193',
|
51
|
+
:hours => '4',
|
52
|
+
:dated_on => '2009-10-05T00:00:00Z',
|
53
|
+
:task_id => '12683',
|
54
|
+
}
|
55
|
+
@timeslip = Timeslip.new params
|
56
|
+
end
|
57
|
+
should "validate and save" do
|
58
|
+
assert @timeslip.save_with_validation
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freeagent_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Russell
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-27 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -23,18 +23,8 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
type: :
|
28
|
-
version_requirement:
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: nokogiri
|
37
|
-
type: :runtime
|
26
|
+
name: fakeweb
|
27
|
+
type: :development
|
38
28
|
version_requirement:
|
39
29
|
version_requirements: !ruby/object:Gem::Requirement
|
40
30
|
requirements:
|
@@ -43,7 +33,7 @@ dependencies:
|
|
43
33
|
version: "0"
|
44
34
|
version:
|
45
35
|
- !ruby/object:Gem::Dependency
|
46
|
-
name:
|
36
|
+
name: activeresource
|
47
37
|
type: :runtime
|
48
38
|
version_requirement:
|
49
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,7 +42,7 @@ dependencies:
|
|
52
42
|
- !ruby/object:Gem::Version
|
53
43
|
version: "0"
|
54
44
|
version:
|
55
|
-
description: This is an
|
45
|
+
description: "This is an ActiveResource Ruby wrapper for the Freeagent API. Currently supports the following API resources: Company, Contacts, Projects, Tasks, Invoices, Invoice Items, Timeslips (more will follow)."
|
56
46
|
email: aaron@gc4.co.uk
|
57
47
|
executables: []
|
58
48
|
|
@@ -70,8 +60,33 @@ files:
|
|
70
60
|
- VERSION
|
71
61
|
- freeagent_api.gemspec
|
72
62
|
- lib/freeagent_api.rb
|
73
|
-
- test/
|
63
|
+
- test/authentication_test.rb
|
64
|
+
- test/company_test.rb
|
65
|
+
- test/contact_test.rb
|
66
|
+
- test/invoice_item_test.rb
|
67
|
+
- test/invoice_test.rb
|
68
|
+
- test/project_test.rb
|
69
|
+
- test/stubs/company/invoice_timeline
|
70
|
+
- test/stubs/company/tax_timeline
|
71
|
+
- test/stubs/contacts/find_all
|
72
|
+
- test/stubs/contacts/find_single
|
73
|
+
- test/stubs/http/200
|
74
|
+
- test/stubs/http/201
|
75
|
+
- test/stubs/invoice_items/find_all
|
76
|
+
- test/stubs/invoice_items/find_single
|
77
|
+
- test/stubs/invoices/find_all
|
78
|
+
- test/stubs/invoices/find_single
|
79
|
+
- test/stubs/projects/find_all
|
80
|
+
- test/stubs/projects/find_single
|
81
|
+
- test/stubs/projects/invoices
|
82
|
+
- test/stubs/projects/timeslips
|
83
|
+
- test/stubs/tasks/find_all
|
84
|
+
- test/stubs/tasks/find_single
|
85
|
+
- test/stubs/timeslips/find_all
|
86
|
+
- test/stubs/timeslips/find_single
|
87
|
+
- test/task_test.rb
|
74
88
|
- test/test_helper.rb
|
89
|
+
- test/timeslip_test.rb
|
75
90
|
has_rdoc: true
|
76
91
|
homepage: http://github.com/aaronrussell/freeagent_api
|
77
92
|
licenses: []
|
@@ -99,7 +114,14 @@ rubyforge_project:
|
|
99
114
|
rubygems_version: 1.3.5
|
100
115
|
signing_key:
|
101
116
|
specification_version: 3
|
102
|
-
summary:
|
117
|
+
summary: ActiveResource Ruby wrapper for the Freeagent Central API.
|
103
118
|
test_files:
|
104
|
-
- test/
|
119
|
+
- test/authentication_test.rb
|
120
|
+
- test/company_test.rb
|
121
|
+
- test/contact_test.rb
|
122
|
+
- test/invoice_item_test.rb
|
123
|
+
- test/invoice_test.rb
|
124
|
+
- test/project_test.rb
|
125
|
+
- test/task_test.rb
|
105
126
|
- test/test_helper.rb
|
127
|
+
- test/timeslip_test.rb
|