insightly 0.1.8 → 0.2.0

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.
@@ -207,5 +207,62 @@ describe Insightly::Opportunity do
207
207
  it "should set the reason to Created by API if you create an opportunity"
208
208
 
209
209
  end
210
-
210
+ context "Links" do
211
+ before(:each) do
212
+ @opportunity = Insightly::Opportunity.new(968613)
213
+ @opportunity.links = []
214
+ @opportunity.save
215
+
216
+
217
+ @link = Insightly::Link.add_organisation(8936117, "Employeer", "Handles payment")
218
+ # @link = Insightly::Link.add_contacty(20315449,"Janitor", "Recent Hire")
219
+ end
220
+ it "should allow you to update an link" do
221
+ @opportunity.links.should == []
222
+ @opportunity.add_link(@link)
223
+
224
+ @opportunity.save
225
+ @link = @opportunity.links.first
226
+ @link.details = "Old Veteran"
227
+ @opportunity.links = [@link]
228
+ @opportunity.save
229
+ @opportunity.reload
230
+ @opportunity.links.length.should == 1
231
+ @opportunity.links.first.details.should == "Old Veteran"
232
+ end
233
+ it "should allow you to add an link" do
234
+
235
+
236
+ @opportunity.links.should == []
237
+ @opportunity.add_link(@link)
238
+ @opportunity.add_link(@link)
239
+ @opportunity.links.length.should == 2
240
+ @opportunity.save
241
+ @opportunity.reload
242
+ @opportunity.links.length.should == 1
243
+ @opportunity.links.first.details.should == "Handles payment"
244
+ end
245
+ it "should allow you to remove an link" do
246
+
247
+ @opportunity.links.should == []
248
+ @opportunity.add_link(@link)
249
+
250
+ @opportunity.save
251
+ @opportunity.links = []
252
+ @opportunity.save
253
+ @opportunity.reload
254
+ @opportunity.links.length.should == 0
255
+
256
+ end
257
+ it "should allow you to clear all links" do
258
+ @opportunity.links.should == []
259
+ @opportunity.add_link(@link)
260
+
261
+ @opportunity.save
262
+ @opportunity.links = []
263
+ @opportunity.save
264
+ @opportunity.reload
265
+ @opportunity.links.length.should == 0
266
+ end
267
+ end
211
268
  end
@@ -0,0 +1,239 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+
3
+ describe Insightly::Organisation do
4
+ before(:each) do
5
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
+
7
+ @organisation = Insightly::Organisation.build(
8
+ {
9
+ "ORGANISATION_ID" => 4567891,
10
+ "ORGANISATION_NAME" => "OrganisationTest.com",
11
+ "BACKGROUND" => "Organisation Description",
12
+ "ORGANISATION_FIELD_1" => "Organisation Field No 1",
13
+ "ORGANISATION_FIELD_2" => "2011-10-28 12:00:00",
14
+ "ORGANISATION_FIELD_3" => "f3frfrewq",
15
+ "ORGANISATION_FIELD_4" => nil,
16
+ "ORGANISATION_FIELD_5" => nil,
17
+ "ORGANISATION_FIELD_6" => nil,
18
+ "ORGANISATION_FIELD_7" => nil,
19
+ "ORGANISATION_FIELD_8" => nil,
20
+ "ORGANISATION_FIELD_9" => nil,
21
+ "ORGANISATION_FIELD_10" => nil,
22
+ "OWNER_USER_ID" => 12345,
23
+ "DATE_CREATED_UTC" => "2011-07-15 02:20:00",
24
+ "DATE_UPDATED_UTC" => "2011-10-10 08:51:19",
25
+ "VISIBLE_TO" => "EVERYONE",
26
+ "VISIBLE_TEAM_ID" => nil
27
+ }
28
+
29
+ )
30
+ # @task_links = Insightly::TaskLink.all
31
+ # d = 1
32
+ end
33
+ it " should have a url base " do
34
+ Insightly::Organisation.new.url_base.should == "Organisations"
35
+ end
36
+ it " should know the organisation id " do
37
+ @organisation.organisation_id.should == 4567891
38
+ end
39
+ it "should know the remote id " do
40
+ @organisation.remote_id.should == @organisation.organisation_id
41
+ end
42
+ #it "should be able to create an organisation" do
43
+ # @organisation = Insightly::Organisation.new
44
+ #
45
+ # @organisation.visible_to = "EVERYONE"
46
+ # @organisation.organisation_name = "000 Dummy Test Org"
47
+ # @organisation.background = "This organisation was created for test purposes and can be deleted."
48
+ #
49
+ # @organisation.save
50
+ #
51
+ # @new_organisation = Insightly::Organisation.new(@organisation.remote_id)
52
+ # @new_organisation.organisation_name.should == @organisation.organisation_name
53
+ #end
54
+ context "addresses" do
55
+ before(:each) do
56
+ @org = Insightly::Organisation.new(8936117)
57
+ @org.addresses = []
58
+ @org.save
59
+
60
+ @address = Insightly::Address.new
61
+ @address.address_type = "Work"
62
+ @address.street = "123 Main St"
63
+ @address.city = "Indianpolis"
64
+ @address.state = "IN"
65
+ @address.postcode = "46112"
66
+ @address.country = "US"
67
+ end
68
+ it "should allow you to update an address" do
69
+ @org.addresses.should == []
70
+ @org.add_address(@address)
71
+
72
+ @org.save
73
+ @address.state = "TX"
74
+ @org.addresses = [@address]
75
+ @org.save
76
+ @org.reload
77
+ @org.addresses.length.should == 1
78
+ @org.addresses.first.state.should == "TX"
79
+ end
80
+ it "should allow you to add an address" do
81
+
82
+
83
+ @org.addresses.should == []
84
+ @org.add_address(@address)
85
+
86
+ @org.save
87
+ @org.reload
88
+ @org.addresses.length.should == 1
89
+ @org.addresses.first.street.should == "123 Main St"
90
+ end
91
+ it "should allow you to remove an address" do
92
+
93
+ @org.addresses.should == []
94
+ @org.add_address(@address)
95
+
96
+ @org.save
97
+ @org.addresses = []
98
+ @org.save
99
+ @org.reload
100
+ @org.addresses.length.should == 0
101
+
102
+ end
103
+ it "should allow you to clear all addresses" do
104
+ @org.addresses.should == []
105
+ @org.add_address(@address)
106
+
107
+ @org.save
108
+ @org.addresses = []
109
+ @org.save
110
+ @org.reload
111
+ @org.addresses.length.should == 0
112
+ end
113
+
114
+ it "should not add an address if the same address is already on the organization" do
115
+
116
+ @org.addresses.should == []
117
+ @org.add_address(@address)
118
+
119
+ @org.add_address(@address)
120
+ @org.addresses.length.should == 1
121
+ end
122
+ end
123
+
124
+ context "contact_infos" do
125
+ before(:each) do
126
+ @org = Insightly::Organisation.new(8936117)
127
+ @org.contact_infos = []
128
+ @org.save
129
+
130
+ @contact_info = Insightly::ContactInfo.new
131
+ @contact_info.type = "PHONE"
132
+ @contact_info.label = "Work"
133
+ @contact_info.subtype = nil
134
+ @contact_info.detail = "bob@aol.com"
135
+
136
+ end
137
+ it "should allow you to update an contact_info" do
138
+ @org.contact_infos.should == []
139
+ @org.add_contact_info(@contact_info)
140
+
141
+ @org.save
142
+ @contact_info.detail = "bobroberts@aol.com"
143
+ @org.contact_infos = [@contact_info]
144
+ @org.save
145
+ @org.reload
146
+ @org.contact_infos.length.should == 1
147
+ @org.contact_infos.first.detail.should == "bobroberts@aol.com"
148
+ end
149
+ it "should allow you to add an contact_info" do
150
+
151
+
152
+ @org.contact_infos.should == []
153
+ @org.add_contact_info(@contact_info)
154
+
155
+ @org.save
156
+ @org.reload
157
+ @org.contact_infos.length.should == 1
158
+ @org.contact_infos.first.detail.should == "bob@aol.com"
159
+ end
160
+ it "should allow you to remove an contact_info" do
161
+
162
+ @org.contact_infos.should == []
163
+ @org.add_contact_info(@contact_info)
164
+
165
+ @org.save
166
+ @org.contact_infos = []
167
+ @org.save
168
+ @org.reload
169
+ @org.contact_infos.length.should == 0
170
+
171
+ end
172
+ it "should allow you to clear all contact_infos" do
173
+ @org.contact_infos.should == []
174
+ @org.add_contact_info(@contact_info)
175
+
176
+ @org.save
177
+ @org.contact_infos = []
178
+ @org.save
179
+ @org.reload
180
+ @org.contact_infos.length.should == 0
181
+ end
182
+ end
183
+ context "Links" do
184
+ before(:each) do
185
+ @org = Insightly::Organisation.new(8936117)
186
+ @org.links = []
187
+ @org.save
188
+
189
+ @link = Insightly::Link.add_contact(2982194,"Janitor", "Recent Hire")
190
+ # @link = Insightly::Link.add_opportunity(968613,"Janitor", "Recent Hire")
191
+ end
192
+ it "should allow you to update an link" do
193
+ @org.links.should == []
194
+ @org.add_link(@link)
195
+
196
+ @org.save
197
+ @link = @org.links.first
198
+ @link.details = "Old Veteran"
199
+ @org.links = [@link]
200
+ @org.save
201
+ @org.reload
202
+ @org.links.length.should == 1
203
+ @org.links.first.details.should == "Old Veteran"
204
+ end
205
+ it "should allow you to add an link" do
206
+
207
+
208
+ @org.links.should == []
209
+ @org.add_link(@link)
210
+
211
+ @org.save
212
+ @org.reload
213
+ @org.links.length.should == 1
214
+ @org.links.first.details.should == "Recent Hire"
215
+ end
216
+ it "should allow you to remove an link" do
217
+
218
+ @org.links.should == []
219
+ @org.add_link(@link)
220
+
221
+ @org.save
222
+ @org.links = []
223
+ @org.save
224
+ @org.reload
225
+ @org.links.length.should == 0
226
+
227
+ end
228
+ it "should allow you to clear all links" do
229
+ @org.links.should == []
230
+ @org.add_link(@link)
231
+
232
+ @org.save
233
+ @org.links = []
234
+ @org.save
235
+ @org.reload
236
+ @org.links.length.should == 0
237
+ end
238
+ end
239
+ end
@@ -44,4 +44,5 @@ describe Insightly::TaskLink do
44
44
  Insightly::TaskLink.search_by_opportunity_id(@tl2.opportunity_id).should == [@tl2]
45
45
  end
46
46
 
47
+
47
48
  end
@@ -132,4 +132,100 @@ describe Insightly::Task do
132
132
 
133
133
 
134
134
  end
135
+ it "should be able to link a task to an opportunity" do
136
+ @opportunity = Insightly::Opportunity.build({
137
+
138
+ "VISIBLE_TO" => "EVERYONE",
139
+ "BID_TYPE" => "Fixed Bid",
140
+ "ACTUAL_CLOSE_DATE" => nil,
141
+ "BID_CURRENTY" => "USD",
142
+ "OPPORTUNITY_STATE" => "Open",
143
+ "OPPORTUNITY_NAME" => "Linkable Opportunity",
144
+ "OPPORTUNITY_DETAILS" => "This is a description."
145
+ })
146
+
147
+ @task = Insightly::Task.new.build({
148
+
149
+
150
+ "PUBLICLY_VISIBLE" => true,
151
+ "RESPONSIBLE_USER_ID" => "226277" ,
152
+ "OWNER_USER_ID" => "226277" ,
153
+ "DETAILS" => "This proves we can link them",
154
+
155
+ "TITLE" => "Linkable Task"
156
+ })
157
+ # @opportunity.save
158
+ @opportunity = Insightly::Opportunity.new(968613)
159
+ @task.save
160
+ #"TASKLINKS" => {"OPPORTUNITY_ID" => 955454,
161
+ # "TASK_LINK_ID" => 2744236,
162
+ # "PROJECT_ID" => nil,
163
+ # "CONTACT_ID" => nil,
164
+ # "TASK_ID" => nil,
165
+ # "ORGANIZATION_ID" => nil
166
+ # },
167
+ @task_link = Insightly::TaskLink.build("OPPORTUNITY_ID" => @opportunity.opportunity_id.to_s,
168
+ "TASK_ID" => @task.task_id.to_s
169
+ )
170
+ @task.tasklinks = [@task_link.remote_data]
171
+ @task.save
172
+ end
173
+
174
+ context "TaskLinks" do
175
+ before(:each) do
176
+ @task = Insightly::Task.new(3263739)
177
+ @task.task_links = []
178
+ @task.save
179
+
180
+
181
+ @link = Insightly::TaskLink.add_organisation(8936117)
182
+ @link2 = Insightly::TaskLink.add_opportunity(968613)
183
+ end
184
+ it "should allow you to update an link" do
185
+ @task.task_links.should == []
186
+ @task.add_task_link(@link)
187
+
188
+ @task.save
189
+ @link = @task.task_links.first
190
+ @link2.task_link_id = @link.task_link_id
191
+ @task.task_links = [@link2]
192
+ @task.save
193
+ @task.reload
194
+ @task.task_links.length.should == 1
195
+ @task.task_links.first.opportunity_id.should == 968613
196
+ end
197
+ it "should allow you to add an link" do
198
+
199
+
200
+ @task.task_links.should == []
201
+ @task.add_task_link(@link)
202
+
203
+ @task.save
204
+ @task.reload
205
+ @task.task_links.length.should == 1
206
+ @task.task_links.first.organisation_id.should == 8936117
207
+ end
208
+ it "should allow you to remove an link" do
209
+
210
+ @task.task_links.should == []
211
+ @task.add_task_link(@link)
212
+
213
+ @task.save
214
+ @task.task_links = []
215
+ @task.save
216
+ @task.reload
217
+ @task.task_links.length.should == 0
218
+
219
+ end
220
+ it "should allow you to clear all links" do
221
+ @task.task_links.should == []
222
+ @task.add_task_link(@link)
223
+
224
+ @task.save
225
+ @task.task_links = []
226
+ @task.save
227
+ @task.reload
228
+ @task.task_links.length.should == 0
229
+ end
230
+ end
135
231
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insightly
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 8
10
- version: 0.1.8
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dirk Elmendorf
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-09-11 00:00:00 Z
19
+ date: 2012-09-13 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: builder
@@ -123,22 +123,36 @@ files:
123
123
  - LICENSE
124
124
  - lib/insightly/read_write.rb
125
125
  - lib/insightly/task.rb
126
+ - lib/insightly/link_helper.rb
126
127
  - lib/insightly/opportunity.rb
128
+ - lib/insightly/contact_info.rb
127
129
  - lib/insightly/read_only.rb
130
+ - lib/insightly/contact_info_helper.rb
131
+ - lib/insightly/task_link_helper.rb
128
132
  - lib/insightly/configuration.rb
129
133
  - lib/insightly/version.rb
134
+ - lib/insightly/link.rb
130
135
  - lib/insightly/task_link.rb
131
136
  - lib/insightly/comment.rb
137
+ - lib/insightly/organisation.rb
138
+ - lib/insightly/contact.rb
139
+ - lib/insightly/address_helper.rb
140
+ - lib/insightly/base_data.rb
132
141
  - lib/insightly/opportunity_state_reason.rb
133
142
  - lib/insightly/base.rb
143
+ - lib/insightly/address.rb
134
144
  - lib/insightly.rb
135
145
  - spec/unit/task_link_spec.rb
146
+ - spec/unit/organisation_spec.rb
136
147
  - spec/unit/base_spec.rb
137
148
  - spec/unit/comment_spec.rb
138
149
  - spec/unit/opportunity_spec.rb
139
150
  - spec/unit/opportunity_state_reason_spec.rb
151
+ - spec/unit/contact_spec.rb
152
+ - spec/unit/link_spec.rb
140
153
  - spec/unit/configuration_spec.rb
141
154
  - spec/unit/task_spec.rb
155
+ - spec/unit/address_spec.rb
142
156
  - spec/spec_helper.rb
143
157
  - insightly.gemspec
144
158
  homepage: https://github.com/r26D/insightly