insightly 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +9 -1
- data/lib/insightly/contact.rb +2 -0
- data/lib/insightly/country.rb +22 -0
- data/lib/insightly/currency.rb +23 -0
- data/lib/insightly/custom_field.rb +21 -0
- data/lib/insightly/opportunity.rb +1 -1
- data/lib/insightly/opportunity_category.rb +15 -0
- data/lib/insightly/organisation.rb +2 -0
- data/lib/insightly/relationship.rb +16 -0
- data/lib/insightly/tag.rb +44 -0
- data/lib/insightly/tag_helper.rb +15 -0
- data/lib/insightly/task_category.rb +15 -0
- data/lib/insightly/team_member.rb +13 -0
- data/lib/insightly/user.rb +46 -0
- data/lib/insightly/version.rb +1 -1
- data/lib/insightly.rb +10 -0
- data/spec/unit/contact_spec.rb +226 -162
- data/spec/unit/country_spec.rb +49 -0
- data/spec/unit/currency_spec.rb +53 -0
- data/spec/unit/custom_field_spec.rb +46 -0
- data/spec/unit/opportunity_category_spec.rb +50 -0
- data/spec/unit/opportunity_spec.rb +152 -90
- data/spec/unit/organisation_spec.rb +234 -171
- data/spec/unit/relationship_spec.rb +42 -0
- data/spec/unit/tag_spec.rb +70 -0
- data/spec/unit/task_category_spec.rb +52 -0
- data/spec/unit/team_member_spec.rb +36 -0
- data/spec/unit/user_spec.rb +165 -0
- metadata +62 -43
data/spec/unit/contact_spec.rb
CHANGED
@@ -61,195 +61,259 @@ describe Insightly::Contact do
|
|
61
61
|
# @new_contact = Insightly::Contact.new(@contact.remote_id)
|
62
62
|
# @new_contact.last_name.should == @contact.last_name
|
63
63
|
#end
|
64
|
-
context "
|
64
|
+
context "connections" do
|
65
65
|
before(:each) do
|
66
|
-
@contact = Insightly::Contact.new(20315449)
|
67
|
-
@contact.addresses = []
|
68
|
-
@contact.save
|
69
|
-
|
70
|
-
@address = Insightly::Address.new
|
71
|
-
@address.address_type = "Work"
|
72
|
-
@address.street = "123 Main St"
|
73
|
-
@address.city = "Indianpolis"
|
74
|
-
@address.state = "IN"
|
75
|
-
@address.postcode = "46112"
|
76
|
-
@address.country = "US"
|
77
|
-
end
|
78
|
-
it "should allow you to update an address" do
|
79
|
-
@contact.addresses.should == []
|
80
|
-
@contact.add_address(@address)
|
81
|
-
|
82
|
-
@contact.save
|
83
|
-
@address = @contact.addresses.first
|
84
|
-
@address.state = "TX"
|
85
|
-
@contact.addresses = [@address]
|
86
|
-
@contact.addresses.length.should == 1
|
87
|
-
|
88
|
-
@contact.save
|
89
|
-
|
90
|
-
@contact.reload
|
91
|
-
|
92
|
-
@contact.addresses.length.should == 1
|
93
|
-
@contact.addresses.first.state.should == "TX"
|
94
|
-
end
|
95
|
-
it "should allow you to add an address" do
|
96
|
-
|
97
|
-
|
98
|
-
@contact.addresses.should == []
|
99
|
-
@contact.add_address(@address)
|
100
|
-
|
101
|
-
@contact.save
|
102
|
-
@contact.reload
|
103
|
-
@contact.addresses.length.should == 1
|
104
|
-
@contact.addresses.first.street.should == "123 Main St"
|
105
|
-
end
|
106
|
-
it "should allow you to remove an address" do
|
107
66
|
|
108
|
-
@contact.addresses.should == []
|
109
|
-
@contact.add_address(@address)
|
110
67
|
|
111
|
-
@contact.
|
112
|
-
@contact.addresses = []
|
113
|
-
@contact.save
|
114
|
-
@contact.reload
|
115
|
-
@contact.addresses.length.should == 0
|
116
|
-
|
117
|
-
end
|
118
|
-
it "should allow you to clear all addresses" do
|
119
|
-
@contact.addresses.should == []
|
120
|
-
@contact.add_address(@address)
|
68
|
+
@contact = Insightly::Contact.new(20315449)
|
121
69
|
|
122
|
-
@contact.
|
70
|
+
@contact.contact_infos = []
|
71
|
+
@contact.links = []
|
72
|
+
@contact.tags = []
|
123
73
|
@contact.addresses = []
|
124
74
|
@contact.save
|
125
|
-
@contact.reload
|
126
|
-
@contact.addresses.length.should == 0
|
127
75
|
end
|
128
76
|
|
129
|
-
it "should not add an address if the same address is already on the organization" do
|
130
77
|
|
131
|
-
|
132
|
-
|
78
|
+
context "addresses" do
|
79
|
+
before(:each) do
|
133
80
|
|
134
|
-
@contact.add_address(@address)
|
135
|
-
@contact.addresses.length.should == 1
|
136
|
-
end
|
137
|
-
end
|
138
|
-
context "contact_infos" do
|
139
|
-
before(:each) do
|
140
|
-
@contact = Insightly::Contact.new(20315449)
|
141
|
-
@contact.contact_infos = []
|
142
|
-
@contact.save
|
143
81
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
82
|
+
@address = Insightly::Address.new
|
83
|
+
@address.address_type = "Work"
|
84
|
+
@address.street = "123 Main St"
|
85
|
+
@address.city = "Indianpolis"
|
86
|
+
@address.state = "IN"
|
87
|
+
@address.postcode = "46112"
|
88
|
+
@address.country = "US"
|
89
|
+
end
|
90
|
+
it "should allow you to update an address" do
|
91
|
+
@contact.addresses.should == []
|
92
|
+
@contact.add_address(@address)
|
149
93
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
94
|
+
@contact.save
|
95
|
+
@address = @contact.addresses.first
|
96
|
+
@address.state = "TX"
|
97
|
+
@contact.addresses = [@address]
|
98
|
+
@contact.addresses.length.should == 1
|
154
99
|
|
155
|
-
|
156
|
-
@contact_info.detail = "bobroberts@aol.com"
|
157
|
-
@contact.contact_infos = [@contact_info]
|
158
|
-
@contact.save
|
159
|
-
@contact.reload
|
160
|
-
@contact.contact_infos.length.should == 1
|
161
|
-
@contact.contact_infos.first.detail.should == "bobroberts@aol.com"
|
162
|
-
end
|
163
|
-
it "should allow you to add an contact_info" do
|
100
|
+
@contact.save
|
164
101
|
|
102
|
+
@contact.reload
|
165
103
|
|
166
|
-
|
167
|
-
|
104
|
+
@contact.addresses.length.should == 1
|
105
|
+
@contact.addresses.first.state.should == "TX"
|
106
|
+
end
|
107
|
+
it "should allow you to add an address" do
|
168
108
|
|
169
|
-
@contact.save
|
170
|
-
@contact.reload
|
171
|
-
@contact.contact_infos.length.should == 1
|
172
|
-
@contact.contact_infos.first.detail.should == "bob@aol.com"
|
173
|
-
end
|
174
|
-
it "should allow you to remove an contact_info" do
|
175
109
|
|
176
|
-
|
177
|
-
|
110
|
+
@contact.addresses.should == []
|
111
|
+
@contact.add_address(@address)
|
178
112
|
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
113
|
+
@contact.save
|
114
|
+
@contact.reload
|
115
|
+
@contact.addresses.length.should == 1
|
116
|
+
@contact.addresses.first.street.should == "123 Main St"
|
117
|
+
end
|
118
|
+
it "should allow you to remove an address" do
|
184
119
|
|
185
|
-
|
186
|
-
|
187
|
-
@contact.contact_infos.should == []
|
188
|
-
@contact.add_contact_info(@contact_info)
|
120
|
+
@contact.addresses.should == []
|
121
|
+
@contact.add_address(@address)
|
189
122
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
end
|
196
|
-
end
|
197
|
-
context "Links" do
|
198
|
-
before(:each) do
|
199
|
-
@contact = Insightly::Contact.new(20315449)
|
200
|
-
@contact.links = []
|
201
|
-
@contact.save
|
123
|
+
@contact.save
|
124
|
+
@contact.addresses = []
|
125
|
+
@contact.save
|
126
|
+
@contact.reload
|
127
|
+
@contact.addresses.length.should == 0
|
202
128
|
|
129
|
+
end
|
130
|
+
it "should allow you to clear all addresses" do
|
131
|
+
@contact.addresses.should == []
|
132
|
+
@contact.add_address(@address)
|
203
133
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
134
|
+
@contact.save
|
135
|
+
@contact.addresses = []
|
136
|
+
@contact.save
|
137
|
+
@contact.reload
|
138
|
+
@contact.addresses.length.should == 0
|
139
|
+
end
|
210
140
|
|
211
|
-
|
212
|
-
@link = @contact.links.first
|
213
|
-
@link.details = "Old Veteran"
|
214
|
-
@contact.links = [@link]
|
215
|
-
@contact.save
|
216
|
-
@contact.reload
|
217
|
-
@contact.links.length.should == 1
|
218
|
-
@contact.links.first.details.should == "Old Veteran"
|
219
|
-
end
|
220
|
-
it "should allow you to add an link" do
|
141
|
+
it "should not add an address if the same address is already on the organization" do
|
221
142
|
|
143
|
+
@contact.addresses.should == []
|
144
|
+
@contact.add_address(@address)
|
222
145
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
@contact.links.length.should == 2
|
227
|
-
@contact.save
|
228
|
-
@contact.reload
|
229
|
-
@contact.links.length.should == 1
|
230
|
-
@contact.links.first.details.should == "Handles payment"
|
146
|
+
@contact.add_address(@address)
|
147
|
+
@contact.addresses.length.should == 1
|
148
|
+
end
|
231
149
|
end
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
150
|
+
context "contact_infos" do
|
151
|
+
before(:each) do
|
152
|
+
|
153
|
+
@contact_info = Insightly::ContactInfo.new
|
154
|
+
@contact_info.type = "PHONE"
|
155
|
+
@contact_info.label = "Work"
|
156
|
+
@contact_info.subtype = nil
|
157
|
+
@contact_info.detail = "bob@aol.com"
|
158
|
+
|
159
|
+
end
|
160
|
+
it "should allow you to update an contact_info" do
|
161
|
+
@contact.contact_infos.should == []
|
162
|
+
@contact.add_contact_info(@contact_info)
|
163
|
+
|
164
|
+
@contact.save
|
165
|
+
@contact_info.detail = "bobroberts@aol.com"
|
166
|
+
@contact.contact_infos = [@contact_info]
|
167
|
+
@contact.save
|
168
|
+
@contact.reload
|
169
|
+
@contact.contact_infos.length.should == 1
|
170
|
+
@contact.contact_infos.first.detail.should == "bobroberts@aol.com"
|
171
|
+
end
|
172
|
+
it "should allow you to add an contact_info" do
|
173
|
+
|
174
|
+
|
175
|
+
@contact.contact_infos.should == []
|
176
|
+
@contact.add_contact_info(@contact_info)
|
177
|
+
|
178
|
+
@contact.save
|
179
|
+
@contact.reload
|
180
|
+
@contact.contact_infos.length.should == 1
|
181
|
+
@contact.contact_infos.first.detail.should == "bob@aol.com"
|
182
|
+
end
|
183
|
+
it "should allow you to remove an contact_info" do
|
184
|
+
|
185
|
+
@contact.contact_infos.should == []
|
186
|
+
@contact.add_contact_info(@contact_info)
|
187
|
+
|
188
|
+
@contact.save
|
189
|
+
@contact.contact_infos = []
|
190
|
+
@contact.save
|
191
|
+
@contact.reload
|
192
|
+
@contact.contact_infos.length.should == 0
|
193
|
+
|
194
|
+
end
|
195
|
+
it "should allow you to clear all contact_infos" do
|
196
|
+
@contact.contact_infos.should == []
|
197
|
+
@contact.add_contact_info(@contact_info)
|
198
|
+
|
199
|
+
@contact.save
|
200
|
+
@contact.contact_infos = []
|
201
|
+
@contact.save
|
202
|
+
@contact.reload
|
203
|
+
@contact.contact_infos.length.should == 0
|
204
|
+
end
|
243
205
|
end
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
206
|
+
context "Links" do
|
207
|
+
before(:each) do
|
208
|
+
|
209
|
+
|
210
|
+
@link = Insightly::Link.add_organisation(8936117, "Employeer", "Handles payment")
|
211
|
+
# @link = Insightly::Link.add_opportunity(968613,"Janitor", "Recent Hire")
|
212
|
+
end
|
213
|
+
it "should allow you to update an link" do
|
214
|
+
@contact.links.should == []
|
215
|
+
@contact.add_link(@link)
|
216
|
+
|
217
|
+
@contact.save
|
218
|
+
@link = @contact.links.first
|
219
|
+
@link.details = "Old Veteran"
|
220
|
+
@contact.links = [@link]
|
221
|
+
@contact.save
|
222
|
+
@contact.reload
|
223
|
+
@contact.links.length.should == 1
|
224
|
+
@contact.links.first.details.should == "Old Veteran"
|
225
|
+
end
|
226
|
+
it "should allow you to add an link" do
|
227
|
+
|
228
|
+
|
229
|
+
@contact.links.should == []
|
230
|
+
@contact.add_link(@link)
|
231
|
+
@contact.add_link(@link)
|
232
|
+
@contact.links.length.should == 2
|
233
|
+
@contact.save
|
234
|
+
@contact.reload
|
235
|
+
@contact.links.length.should == 1
|
236
|
+
@contact.links.first.details.should == "Handles payment"
|
237
|
+
end
|
238
|
+
it "should allow you to remove an link" do
|
239
|
+
|
240
|
+
@contact.links.should == []
|
241
|
+
@contact.add_link(@link)
|
242
|
+
|
243
|
+
@contact.save
|
244
|
+
@contact.links = []
|
245
|
+
@contact.save
|
246
|
+
@contact.reload
|
247
|
+
@contact.links.length.should == 0
|
248
|
+
|
249
|
+
end
|
250
|
+
it "should allow you to clear all links" do
|
251
|
+
@contact.links.should == []
|
252
|
+
@contact.add_link(@link)
|
253
|
+
|
254
|
+
@contact.save
|
255
|
+
@contact.links = []
|
256
|
+
@contact.save
|
257
|
+
@contact.reload
|
258
|
+
@contact.links.length.should == 0
|
259
|
+
end
|
260
|
+
end
|
261
|
+
context "Tags" do
|
262
|
+
before(:each) do
|
263
|
+
|
264
|
+
@tag = Insightly::Tag.build("Paying Customer")
|
265
|
+
@tag2 = Insightly::Tag.build("Freebie")
|
266
|
+
|
267
|
+
end
|
268
|
+
it "should allow you to update an tag" do
|
269
|
+
@contact.tags.should == []
|
270
|
+
@contact.add_tag(@tag)
|
271
|
+
@tags = @contact.tags
|
272
|
+
|
273
|
+
@contact.save
|
274
|
+
@tag = @contact.tags.first
|
275
|
+
@tag.tag_name = "Old Veteran"
|
276
|
+
@contact.tags = [@tag]
|
277
|
+
@contact.save
|
278
|
+
@contact.reload
|
279
|
+
@contact.tags.length.should == 1
|
280
|
+
@contact.tags.first.tag_name.should == "Old Veteran"
|
281
|
+
end
|
282
|
+
it "should allow you to add an tag" do
|
283
|
+
|
284
|
+
|
285
|
+
@contact.tags.should == []
|
286
|
+
@contact.add_tag(@tag)
|
287
|
+
@contact.add_tag(@tag)
|
288
|
+
@contact.tags.length.should == 2
|
289
|
+
@contact.save
|
290
|
+
@contact.reload
|
291
|
+
@contact.tags.length.should == 1
|
292
|
+
@contact.tags.first.tag_name.should == "Paying Customer"
|
293
|
+
end
|
294
|
+
it "should allow you to remove an tag" do
|
295
|
+
|
296
|
+
@contact.tags.should == []
|
297
|
+
@contact.add_tag(@tag)
|
298
|
+
|
299
|
+
@contact.save
|
300
|
+
@contact.tags = []
|
301
|
+
@contact.save
|
302
|
+
@contact.reload
|
303
|
+
@contact.tags.length.should == 0
|
304
|
+
|
305
|
+
end
|
306
|
+
it "should allow you to clear all tags" do
|
307
|
+
@contact.tags.should == []
|
308
|
+
@contact.add_tag(@tag)
|
309
|
+
|
310
|
+
@contact.save
|
311
|
+
@contact.tags = []
|
312
|
+
@contact.save
|
313
|
+
@contact.reload
|
314
|
+
@contact.tags.length.should == 0
|
315
|
+
end
|
253
316
|
end
|
254
317
|
end
|
318
|
+
|
255
319
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Insightly::Country do
|
4
|
+
before(:each) do
|
5
|
+
Insightly::Configuration.api_key = INSIGHTLY_API_KEY
|
6
|
+
Insightly::Configuration.logger = Insightly::Configuration._debug_logger
|
7
|
+
@country = Insightly::Country.build({"COUNTRY_NAME" => "United States"})
|
8
|
+
@country2 = Insightly::Country.build({"COUNTRY_NAME" => "Canada"})
|
9
|
+
@all_countries = [@country, @country2]
|
10
|
+
end
|
11
|
+
it "should have a url base" do
|
12
|
+
Insightly::Country.new.url_base.should == "Countries"
|
13
|
+
end
|
14
|
+
it "should be able to fetch all of the countries" do
|
15
|
+
|
16
|
+
Insightly::Country.any_instance.stub(:get_collection).and_return(@all_countries.collect { |x| x.remote_data })
|
17
|
+
Insightly::Country.all.should == @all_countries
|
18
|
+
|
19
|
+
end
|
20
|
+
it "should allow you to build a coutnry from a string" do
|
21
|
+
@country = Insightly::Country.build("India")
|
22
|
+
@country.country_name.should == "India"
|
23
|
+
@country.remote_data.should == {"COUNTRY_NAME" => "India"}
|
24
|
+
end
|
25
|
+
it "should be able to retrieve the data as an array" do
|
26
|
+
@country.remote_data["COUNTRY_NAME"].should == "United States"
|
27
|
+
end
|
28
|
+
it "should be able to convert to json" do
|
29
|
+
@country.to_json.should == @country.remote_data.to_json
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should know if two countries are equal" do
|
33
|
+
@country2 = Insightly::Country.build(@country.remote_data.clone)
|
34
|
+
@country2.should == @country
|
35
|
+
@country.country_name = "Bob"
|
36
|
+
@country2.should_not == @country
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have accessor for country_name" do
|
40
|
+
@country.country_name = "Will"
|
41
|
+
@country.country_name.should == "Will"
|
42
|
+
end
|
43
|
+
it "should have a US standard object" do
|
44
|
+
Insightly::Country.us.country_name.should == "United States"
|
45
|
+
end
|
46
|
+
it "should have a Canada standard object" do
|
47
|
+
Insightly::Country.canada.country_name.should == "Canada"
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Insightly::Currency do
|
4
|
+
before(:each) do
|
5
|
+
Insightly::Configuration.api_key = INSIGHTLY_API_KEY
|
6
|
+
Insightly::Configuration.logger = Insightly::Configuration._debug_logger
|
7
|
+
@currency = Insightly::Currency.build({"CURRENCY_CODE" => "USD", "CURRENCY_SYMBOL" => "$"})
|
8
|
+
@currency2 = Insightly::Currency.build({"CURRENCY_CODE" => "CAD", "CURRENCY_SYMBOL" => "$"})
|
9
|
+
|
10
|
+
@all_currencies = [@currency, @currency2]
|
11
|
+
end
|
12
|
+
it "should have a url base" do
|
13
|
+
Insightly::Currency.new.url_base.should == "Currencies"
|
14
|
+
end
|
15
|
+
it "should be able to fetch all of the currencies" do
|
16
|
+
|
17
|
+
Insightly::Country.any_instance.stub(:get_collection).and_return(@all_currencies.collect { |x| x.remote_data })
|
18
|
+
Insightly::Country.all.should == @all_currencies
|
19
|
+
|
20
|
+
end
|
21
|
+
it "should allow you to build a currency from a string" do
|
22
|
+
@currency = Insightly::Currency.build("USD")
|
23
|
+
@currency.currency_code.should == "USD"
|
24
|
+
@currency.currency_symbol.should == "$"
|
25
|
+
@currency.remote_data.should == {"CURRENCY_CODE" => "USD", "CURRENCY_SYMBOL" => "$" }
|
26
|
+
end
|
27
|
+
it "should be able to retrieve the data as an array" do
|
28
|
+
@currency.remote_data["CURRENCY_CODE"].should == "USD"
|
29
|
+
end
|
30
|
+
it "should be able to convert to json" do
|
31
|
+
@currency.to_json.should == @currency.remote_data.to_json
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should know if two currencies are equal" do
|
35
|
+
@currency2 = Insightly::Currency.build(@currency.remote_data.clone)
|
36
|
+
@currency2.should == @currency
|
37
|
+
@currency.currency_code = "Bob"
|
38
|
+
@currency2.should_not == @currency
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have accessor for currency_code" do
|
42
|
+
@currency.currency_code = "Will"
|
43
|
+
@currency.currency_code.should == "Will"
|
44
|
+
end
|
45
|
+
it "should have a US standard object" do
|
46
|
+
Insightly::Currency.us.currency_code.should == "USD"
|
47
|
+
Insightly::Currency.us.currency_symbol.should == "$"
|
48
|
+
end
|
49
|
+
it "should have a Canada standard object" do
|
50
|
+
Insightly::Currency.canada.currency_code.should == "CAD"
|
51
|
+
Insightly::Currency.canada.currency_symbol.should == "$"
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Insightly::OpportunityStateReason do
|
4
|
+
before(:each) do
|
5
|
+
Insightly::Configuration.api_key = INSIGHTLY_API_KEY
|
6
|
+
Insightly::Configuration.logger = Insightly::Configuration._debug_logger
|
7
|
+
|
8
|
+
|
9
|
+
@custom_field = Insightly::CustomField.build({
|
10
|
+
"CUSTOM_FIELD_ID" => "OPPORTUNITY_FIELD_1",
|
11
|
+
"FIELD_NAME" => "Type of Customer",
|
12
|
+
"FIELD_HELP_TEXT" => "Are they a supplier or something else",
|
13
|
+
"CUSTOM_FIELD_OPTIONS" => [],
|
14
|
+
"ORDER_ID" => 1,
|
15
|
+
"FIELD_TYPE" => "TEXT",
|
16
|
+
"FIELD_FOR" => "OPPORTUNITY"
|
17
|
+
})
|
18
|
+
@custom_field2 = Insightly::CustomField.build({
|
19
|
+
"CUSTOM_FIELD_ID" => "OPPORTUNITY_FIELD_1",
|
20
|
+
"FIELD_NAME" => "Source of Customer",
|
21
|
+
"FIELD_HELP_TEXT" => "How did they find us",
|
22
|
+
"CUSTOM_FIELD_OPTIONS" => [{"OPTION_ID" => 1,
|
23
|
+
"OPTION_VALUE" => "Magazine",
|
24
|
+
"OPTION_DEFAULT" => true},
|
25
|
+
{"OPTION_ID" => 2,
|
26
|
+
"OPTION_VALUE" => "Web",
|
27
|
+
"OPTION_DEFAULT" => false}],
|
28
|
+
"ORDER_ID" => 2,
|
29
|
+
"FIELD_TYPE" => "DROPDOWN",
|
30
|
+
"FIELD_FOR" => "OPPORTUNITY"
|
31
|
+
})
|
32
|
+
|
33
|
+
@all_custom_fields = [@custom_field, @custom_field2]
|
34
|
+
end
|
35
|
+
it "should have a url base" do
|
36
|
+
Insightly::CustomField.new.url_base.should == "CustomFields"
|
37
|
+
|
38
|
+
end
|
39
|
+
it "should get the custom_field id" do
|
40
|
+
@custom_field.custom_field_id.should == 1
|
41
|
+
end
|
42
|
+
it "should have a remote id" do
|
43
|
+
@custom_field.remote_id.should == @custom_field.custom_field_id
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Insightly::OpportunityCategory do
|
4
|
+
before(:each) do
|
5
|
+
Insightly::Configuration.api_key = INSIGHTLY_API_KEY
|
6
|
+
Insightly::Configuration.logger = Insightly::Configuration._debug_logger
|
7
|
+
|
8
|
+
@opportunity_category = Insightly::OpportunityCategory.build({ "CATEGORY_ID" => 1,
|
9
|
+
"ACTIVE" => true,
|
10
|
+
"BACKGROUND_COLOR" => '019301',
|
11
|
+
"CATEGORY_NAME" => "Referral"})
|
12
|
+
|
13
|
+
@opportunity_category2 = Insightly::OpportunityCategory.build({ "CATEGORY_ID" => 2,
|
14
|
+
"ACTIVE" => true,
|
15
|
+
"BACKGROUND_COLOR" => '019301',
|
16
|
+
"CATEGORY_NAME" => "Other"})
|
17
|
+
@all_opportunity_categories = [@opportunity_category, @opportunity_category2]
|
18
|
+
end
|
19
|
+
it "should have a url base" do
|
20
|
+
Insightly::OpportunityCategory.new.url_base.should == "OpportunityCategories"
|
21
|
+
end
|
22
|
+
it "should be able to fetch all of the opportunity_categories" do
|
23
|
+
|
24
|
+
Insightly::OpportunityCategory.any_instance.stub(:get_collection).and_return(@all_opportunity_categories.collect { |x| x.remote_data })
|
25
|
+
Insightly::OpportunityCategory.all.should == @all_opportunity_categories
|
26
|
+
|
27
|
+
end
|
28
|
+
it "should have a remote id" do
|
29
|
+
@opportunity_category.remote_id.should == @opportunity_category.category_id
|
30
|
+
end
|
31
|
+
it "should be able to retrieve the data as an array" do
|
32
|
+
@opportunity_category.remote_data["CATEGORY_NAME"].should == "Referral"
|
33
|
+
end
|
34
|
+
it "should be able to convert to json" do
|
35
|
+
@opportunity_category.to_json.should == @opportunity_category.remote_data.to_json
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should know if two opportunity_categories are equal" do
|
39
|
+
@opportunity_category2 = Insightly::OpportunityCategory.build(@opportunity_category.remote_data.clone)
|
40
|
+
@opportunity_category2.should == @opportunity_category
|
41
|
+
@opportunity_category.category_name = "Bob"
|
42
|
+
@opportunity_category2.should_not == @opportunity_category
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should have accessor forcategory_name" do
|
46
|
+
@opportunity_category.category_name = "Will"
|
47
|
+
@opportunity_category.category_name.should == "Will"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|