insightly 0.2.8 → 0.2.9

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.
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::Configuration do
4
5
  #customer_user_agent
5
6
  #endpoint
@@ -13,12 +14,12 @@ describe Insightly::Configuration do
13
14
  it "should provide a default user agent" do
14
15
 
15
16
  Insightly::Configuration.instantiate.custom_user_agent.should be_nil
16
- Insightly::Configuration.instantiate.user_agent.should == "Insightly Ruby Gem 0.1.0"
17
+ Insightly::Configuration.instantiate.user_agent.should == "Insightly Ruby Gem #{Insightly::Version::String}"
17
18
  end
18
19
  it "should allow you to override the user agent" do
19
20
 
20
21
  Insightly::Configuration.custom_user_agent = "Bob"
21
- Insightly::Configuration.instantiate.user_agent.should == "Insightly Ruby Gem 0.1.0 (Bob)"
22
+ Insightly::Configuration.instantiate.user_agent.should == "Insightly Ruby Gem #{Insightly::Version::String} (Bob)"
22
23
  end
23
24
  it "should provide a default endpoint" do
24
25
  Insightly::Configuration.instantiate.endpoint.should == "https://api.insight.ly/v1"
@@ -59,4 +60,4 @@ describe Insightly::Configuration do
59
60
  Insightly::Configuration.custom_fields_for_organisations(:rank, :branch_of_service)
60
61
 
61
62
  end
62
- end
63
+ end
@@ -135,4 +135,4 @@ describe Insightly::ContactInfo do
135
135
  end
136
136
 
137
137
 
138
- end
138
+ end
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ #METODO Convert to VCR
2
3
 
3
4
  describe Insightly::Contact do
4
5
  before(:each) do
@@ -64,14 +65,19 @@ describe Insightly::Contact do
64
65
  context "connections" do
65
66
  before(:each) do
66
67
 
68
+ VCR.use_cassette('create connectable contact') do
69
+ @contact = Insightly::Contact.new
70
+ @contact.first_name = "00 Test"
71
+ @contact.last_name = "Contact"
72
+ @contact.visible_to = "Owner"
67
73
 
68
- @contact = Insightly::Contact.new(20315449)
69
74
 
70
- @contact.contact_infos = []
71
- @contact.links = []
72
- @contact.tags = []
73
- @contact.addresses = []
74
- @contact.save
75
+ @contact.contact_infos = []
76
+ @contact.links = []
77
+ @contact.tags = []
78
+ @contact.addresses = []
79
+ @contact.save
80
+ end
75
81
  end
76
82
 
77
83
 
@@ -88,63 +94,70 @@ describe Insightly::Contact do
88
94
  @address.country = "US"
89
95
  end
90
96
  it "should allow you to update an address" do
91
- @contact.addresses.should == []
92
- @contact.add_address(@address)
97
+ VCR.use_cassette('update address for contact') do
98
+ @contact.addresses.should == []
99
+ @contact.add_address(@address)
93
100
 
94
- @contact.save
95
- @address = @contact.addresses.first
96
- @address.state = "TX"
97
- @contact.addresses = [@address]
98
- @contact.addresses.length.should == 1
101
+ @contact.save
102
+ @address = @contact.addresses.first
103
+ @address.state = "TX"
104
+ @contact.addresses = [@address]
105
+ @contact.addresses.length.should == 1
99
106
 
100
- @contact.save
107
+ @contact.save
101
108
 
102
- @contact.reload
109
+ @contact.reload
110
+
111
+ @contact.addresses.length.should == 1
112
+ @contact.addresses.first.state.should == "TX"
113
+ end
103
114
 
104
- @contact.addresses.length.should == 1
105
- @contact.addresses.first.state.should == "TX"
106
115
  end
107
116
  it "should allow you to add an address" do
117
+ VCR.use_cassette('add address to contact') do
108
118
 
119
+ @contact.addresses.should == []
120
+ @contact.add_address(@address)
109
121
 
110
- @contact.addresses.should == []
111
- @contact.add_address(@address)
112
-
113
- @contact.save
114
- @contact.reload
115
- @contact.addresses.length.should == 1
116
- @contact.addresses.first.street.should == "123 Main St"
122
+ @contact.save
123
+ @contact.reload
124
+ @contact.addresses.length.should == 1
125
+ @contact.addresses.first.street.should == "123 Main St"
126
+ end
117
127
  end
118
128
  it "should allow you to remove an address" do
119
-
120
- @contact.addresses.should == []
121
- @contact.add_address(@address)
122
-
123
- @contact.save
124
- @contact.addresses = []
125
- @contact.save
126
- @contact.reload
127
- @contact.addresses.length.should == 0
128
-
129
+ VCR.use_cassette('remove address from contact') do
130
+ @contact.addresses.should == []
131
+ @contact.add_address(@address)
132
+
133
+ @contact.save
134
+ @contact.addresses = []
135
+ @contact.save
136
+ @contact.reload
137
+ @contact.addresses.length.should == 0
138
+ end
129
139
  end
130
140
  it "should allow you to clear all addresses" do
131
- @contact.addresses.should == []
132
- @contact.add_address(@address)
133
-
134
- @contact.save
135
- @contact.addresses = []
136
- @contact.save
137
- @contact.reload
138
- @contact.addresses.length.should == 0
141
+ VCR.use_cassette('clear address from contact') do
142
+ @contact.addresses.should == []
143
+ @contact.add_address(@address)
144
+
145
+ @contact.save
146
+ @contact.addresses = []
147
+ @contact.save
148
+ @contact.reload
149
+ @contact.addresses.length.should == 0
150
+ end
139
151
  end
140
152
 
141
153
  it "should not add an address if the same address is already on the organization" do
154
+ VCR.use_cassette('only add an addres once to a contact') do
155
+ @contact.addresses.should == []
156
+ @contact.add_address(@address)
142
157
 
143
- @contact.addresses.should == []
144
- @contact.add_address(@address)
145
-
146
- @contact.add_address(@address)
147
- @contact.addresses.length.should == 1
158
+ @contact.add_address(@address)
159
+ @contact.addresses.length.should == 1
160
+ end
148
161
  end
149
162
  end
150
163
  context "contact_infos" do
@@ -316,4 +329,4 @@ describe Insightly::Contact do
316
329
  end
317
330
  end
318
331
 
319
- end
332
+ end
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::CustomField do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
@@ -43,4 +44,4 @@ describe Insightly::CustomField do
43
44
  @custom_field.remote_id.should == @custom_field.custom_field_id
44
45
  end
45
46
 
46
- end
47
+ end
@@ -95,4 +95,4 @@ describe Insightly::Link do
95
95
  @link.opportunity_id.should be_nil
96
96
 
97
97
  end
98
- end
98
+ end
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::OpportunityCategory do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ #METODO Convert to VCR
2
3
 
3
4
  describe Insightly::Opportunity do
4
5
  before(:each) do
@@ -81,8 +82,28 @@ describe Insightly::Opportunity do
81
82
  it "should know the opportunity id" do
82
83
  @opportunity.opportunity_id.should == 957168
83
84
  end
84
- it "should know that the remote id and the opportunity id are the same" do
85
- @opportunity.remote_id.should == @opportunity.opportunity_id
85
+
86
+ context "remote id" do
87
+ it "should know if the remote id is set" do
88
+ @opportunity.remote_id = nil
89
+ @opportunity.remote_id?.should be_false
90
+ @opportunity.remote_id = ""
91
+ @opportunity.remote_id?.should be_false
92
+ @opportunity.remote_id = 1
93
+ @opportunity.remote_id?.should be_true
94
+ @opportunity.remote_id = "1"
95
+ @opportunity.remote_id?.should be_true
96
+ end
97
+ it "should know that the remote id and the opportunity id are the same" do
98
+ @opportunity.remote_id.should == @opportunity.opportunity_id
99
+ end
100
+ it "should allow you to set the remote id" do
101
+ @opportunity.remote_id = 12
102
+ @opportunity.opportunity_id.should == 12
103
+ end
104
+ it "should know the correct remote field" do
105
+ @opportunity.remote_id_field.should == "opportunity_id"
106
+ end
86
107
  end
87
108
  it "should allow you to load based on an id"
88
109
  it "should allow you to build an object from a hash" do
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::OpportunityStateReason do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
@@ -29,7 +30,7 @@ describe Insightly::OpportunityStateReason do
29
30
  Insightly::OpportunityStateReason.new.url_base.should == "OpportunityStateReasons"
30
31
  end
31
32
  it "should know the opportunity state" do
32
- @open_state.state.should == "Open"
33
+ @open_state.for_opportunity_state.should == "Open"
33
34
  end
34
35
  context "remote query" do
35
36
  before(:each) do
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
+ #METODO Convert to VCR
2
3
 
3
4
  describe Insightly::Organisation do
4
5
  before(:each) do
@@ -27,9 +28,31 @@ describe Insightly::Organisation do
27
28
  }
28
29
 
29
30
  )
30
- # @task_links = Insightly::TaskLink.all
31
- # d = 1
31
+
32
32
  end
33
+ context "remote id" do
34
+ it "should know if the remote id is set" do
35
+ @organisation.remote_id = nil
36
+ @organisation.remote_id?.should be_false
37
+ @organisation.remote_id = ""
38
+ @organisation.remote_id?.should be_false
39
+ @organisation.remote_id = 1
40
+ @organisation.remote_id?.should be_true
41
+ @organisation.remote_id = "1"
42
+ @organisation.remote_id?.should be_true
43
+ end
44
+ it "should know that the remote id and the organisation id are the same" do
45
+ @organisation.remote_id.should == @organisation.organisation_id
46
+ end
47
+ it "should allow you to set the remote id" do
48
+ @organisation.remote_id = 12
49
+ @organisation.organisation_id.should == 12
50
+ end
51
+ it "should know the correct remote field" do
52
+ @organisation.remote_id_field.should == "organisation_id"
53
+ end
54
+ end
55
+
33
56
  it " should have a url base " do
34
57
  Insightly::Organisation.new.url_base.should == "Organisations"
35
58
  end
@@ -203,6 +226,12 @@ describe Insightly::Organisation do
203
226
  @link = Insightly::Link.add_contact(2982194, "Janitor", "Recent Hire")
204
227
  # @link = Insightly::Link.add_opportunity(968613,"Janitor", "Recent Hire")
205
228
  end
229
+ it "should provide a list of contact_ids"
230
+ it "should provide a list of opportunity_ids"
231
+ it "should provide a list of organisation_ids"
232
+ it "should provide a list of contacts"
233
+ it "should provide a list of opportunities"
234
+ it "should provide a list of organisations"
206
235
  it "should let you set it to nil" do
207
236
  @org.links = nil
208
237
  @org.links.should == []
@@ -315,4 +344,4 @@ describe Insightly::Organisation do
315
344
  end
316
345
  end
317
346
  end
318
- end
347
+ end
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::Relationship do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
@@ -30,19 +30,19 @@ describe Insightly::Tag do
30
30
  end
31
31
  it "should allow you to see tags by organisations" do
32
32
  Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Organisations").and_return([@tag.remote_data])
33
- Insightly::Tag.contact_tags.should == [@tag]
33
+ Insightly::Tag.organisation_tags.should == [@tag]
34
34
  end
35
35
  it "should allow you to see tags by opportunites" do
36
36
  Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Opportunities").and_return([@tag.remote_data])
37
- Insightly::Tag.contact_tags.should == [@tag]
37
+ Insightly::Tag.opportunity_tags.should == [@tag]
38
38
  end
39
39
  it "should allow you to see tags by projects" do
40
40
  Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Projects").and_return([@tag.remote_data])
41
- Insightly::Tag.contact_tags.should == [@tag]
41
+ Insightly::Tag.project_tags.should == [@tag]
42
42
  end
43
43
  it "should allow you to see tags by emails" do
44
44
  Insightly::Tag.any_instance.stub(:get_collection).with("#{@tag.url_base}/Emails").and_return([@tag.remote_data])
45
- Insightly::Tag.contact_tags.should == [@tag]
45
+ Insightly::Tag.email_tags.should == [@tag]
46
46
  end
47
47
  it "should allow you to build a tag from a string" do
48
48
  @tag = Insightly::Tag.build("Happy")
@@ -67,4 +67,4 @@ describe Insightly::Tag do
67
67
  @tag.tag_name = "Will"
68
68
  @tag.tag_name.should == "Will"
69
69
  end
70
- end
70
+ end
@@ -1,11 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::TaskCategory do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
7
  Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
8
 
8
- @all = Insightly::TaskCategory.all
9
+ # @all = Insightly::TaskCategory.all
9
10
 
10
11
  @task_category = Insightly::TaskCategory.build({ "CATEGORY_ID" => 1,
11
12
  "ACTIVE" => true,
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
2
 
3
+
3
4
  describe Insightly::TaskLink do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
@@ -1,237 +1,708 @@
1
+ #METODO Refactor the link tests
1
2
  require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
2
3
 
3
4
  describe Insightly::Task do
4
5
  before(:each) do
5
6
  Insightly::Configuration.api_key = INSIGHTLY_API_KEY
6
7
  Insightly::Configuration.logger = Insightly::Configuration._debug_logger
7
- @task = Insightly::Task.new.build({
8
- "TASKLINKS" => {"OPPORTUNITY_ID" => 955454,
9
- "TASK_LINK_ID" => 2744236,
10
- "PROJECT_ID" => nil,
11
- "CONTACT_ID" => nil,
12
- "TASK_ID" => nil,
13
- "ORGANIZATION_ID" => nil
14
- },
15
- "STATUS" => "NOT STARTED",
16
- "OWNER_USER_ID" => 226277,
17
- "RESPONSIBLE_USER_ID" => 226277,
18
- "PUBLICLY_VISIBLE" => true,
19
- "PARENT_TASK_ID" => nil,
20
- "COMPLETED_DATE_UTC" => nil,
21
- "CATEGORY_ID" => 125618,
22
- "PERCENT_COMPLETE" => 0,
23
- "START_DATE" => 0,
24
- "PRIORITY" => 2,
25
- "DETAILS" => "Make sure you log into the app to set the flag.",
26
- "DUE_DATE" => "2012-09-05 16:12:20",
27
- "PROJECT_ID" => nil,
28
- "COMPLETED" => false,
29
- "TASK_ID" => 3216775,
30
- "DATE_CREATED_UTC" => "2012-09-05 16:12:20",
31
- "TITLE" => "Flag the Customer"
32
- })
33
-
34
- # @task = Insightly::Task.new(3216775)
35
- end
36
- it "should be able to create a task" do
37
- end
38
- it "should have a url base" do
39
- @task.url_base.should == "Tasks"
40
- end
41
- it "should know the task id" do
42
- @task.task_id.should == 3216775
43
- end
44
- it "should know that the remote id and the task id are the same" do
45
- @task.remote_id.should == @task.task_id
46
- end
47
- it "should allow you to load based on an id"
48
- it "should allow you to build an object from a hash" do
49
- task = Insightly::Task.new.build({"TITLE" => "Other"})
50
- task.remote_data.should == {"TITLE" => "Other"}
51
- end
52
- it "should know the status of the task" do
53
- @task.status.should == "NOT STARTED"
8
+
9
+
54
10
  end
55
- context "comments" do
11
+ context "without network" do
56
12
  before(:each) do
57
- #@task = Insightly::Task.new(3216775)
58
- @comment = Insightly::Comment.new.build({
59
- "COMMENT_ID" => 132456,
60
- "BODY" => "test comment",
61
- "OWNER_USER_ID" => 12345,
62
- "DATE_CREATED_UTC" => "2012-03-09 11:59:19",
63
- "DATE_UPDATED_UTC" => "2012-03-09 11:59:19",
64
- "FILE_ATTACHMENTS" =>
65
- {
66
- "FILE_ID" => 4567899,
67
- "FILE_NAME" => "test.docx",
68
- "CONTENT_TYPE" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
69
- "FILE_SIZE" => 2489,
70
- "FILE_CATEGORY_ID" => nil,
71
- "OWNER_USER_ID" => 12345,
72
- "DATE_CREATED_UTC" => "2012-03-09 11:59:20",
73
- "DATE_UPDATED_UTC" => "2012-03-09 11:59:20",
74
- "URL" => "/api/fileattachments/4567899"
75
- }
76
- }
77
- )
13
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
14
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
15
+
16
+ @task = Insightly::Task.new.build({
17
+ "TASKLINKS" => {"OPPORTUNITY_ID" => 955454,
18
+ "TASK_LINK_ID" => 2744236,
19
+ "PROJECT_ID" => nil,
20
+ "CONTACT_ID" => nil,
21
+ "TASK_ID" => nil,
22
+ "ORGANIZATION_ID" => nil
23
+ },
24
+ "STATUS" => "NOT STARTED",
25
+ "OWNER_USER_ID" => 226277,
26
+ "RESPONSIBLE_USER_ID" => 226277,
27
+ "PUBLICLY_VISIBLE" => true,
28
+ "PARENT_TASK_ID" => nil,
29
+ "COMPLETED_DATE_UTC" => nil,
30
+ "CATEGORY_ID" => 125618,
31
+ "PERCENT_COMPLETE" => 0,
32
+ "START_DATE" => 0,
33
+ "PRIORITY" => 2,
34
+ "DETAILS" => "Make sure you log into the app to set the flag.",
35
+ "DUE_DATE" => "2012-09-05 16:12:20",
36
+ "PROJECT_ID" => nil,
37
+ "COMPLETED" => false,
38
+ "TASK_ID" => 3216775,
39
+ "DATE_CREATED_UTC" => "2012-09-05 16:12:20",
40
+ "TITLE" => "Flag the Customer"
41
+ })
42
+
78
43
 
79
44
  end
80
- it "should be able to fetch the comments" do
81
- Insightly::Task.any_instance.should_receive(:get_collection).with("Tasks/#{@task.task_id}/comments").and_return([@comment.remote_data])
82
- comments = @task.comments
83
- comments.length.should == 1
84
- comments.first.body.should == "test comment"
45
+ it "should provide today's date if none if provided" do
46
+ date = Date.today
47
+ Insightly::Task.date_to_insightly.should == date.strftime("%Y-%m-%d 00:00:00")
85
48
  end
86
- it "should be able to post a new comment" do
87
- value= "Test Comment #{Time.now}"
88
- @comment.body = value
89
- incoming_comment = Insightly::Comment.new.build({"BODY" => value})
90
- Insightly::Task.any_instance.should_receive(:post_collection).with("Tasks/#{@task.task_id}/comments", incoming_comment.remote_data.to_json).and_return(@comment.remote_data)
91
- #@task = Insightly::Task.new(3216775)
92
-
93
- result = @task.comment_on(value)
94
- result.comment_id.should_not be_nil
95
- result.body.should == value
49
+ it "should be able to convert a date to the insightly format" do
50
+ date = Date.today
51
+ Insightly::Task.date_to_insightly(date).should == date.strftime("%Y-%m-%d 00:00:00")
96
52
  end
97
- end
98
- context "Status query" do
99
- before(:each) do
100
- @statuses = ["NOT STARTED", "IN PROGRESS", "WAITING", "COMPLETED", "DEFERRED"]
53
+ it "should be able to convert a Date Time to the insightly format" do
54
+ time = Time.now
55
+ Insightly::Task.date_to_insightly(time).should == time.strftime("%Y-%m-%d %H:%M:%S")
101
56
  end
102
- it "should know that is it not started" do
103
- @statuses.each do |s|
104
- @task.status = s
105
- s == "NOT STARTED" ? (@task.should be_not_started) : (@task.should_not be_not_started)
57
+
58
+ context "remote id" do
59
+ it "should know if the remote id is set" do
60
+ @task.remote_id = nil
61
+ @task.remote_id?.should be_false
62
+ @task.remote_id = ""
63
+ @task.remote_id?.should be_false
64
+ @task.remote_id = 1
65
+ @task.remote_id?.should be_true
66
+ @task.remote_id = "1"
67
+ @task.remote_id?.should be_true
68
+ end
69
+ it "should know that the remote id and the task id are the same" do
70
+ @task.remote_id.should == @task.task_id
71
+ end
72
+ it "should allow you to set the remote id" do
73
+ @task.remote_id = 12
74
+ @task.task_id.should == 12
75
+ end
76
+ it "should know the correct remote field" do
77
+ @task.remote_id_field.should == "task_id"
78
+ end
79
+ end
80
+
81
+ it "should be able to create a task" do
82
+ end
83
+ it "should have a url base" do
84
+ @task.url_base.should == "Tasks"
85
+ end
86
+ it "should know the task id" do
87
+ @task.task_id.should == 3216775
88
+ end
89
+
90
+ it "should allow you to build an object from a hash" do
91
+ task = Insightly::Task.new.build({"TITLE" => "Other"})
92
+ task.remote_data.should == {"TITLE" => "Other"}
93
+ end
94
+ it "should know the status of the task" do
95
+ @task.status.should == "NOT STARTED"
96
+ end
97
+ context "comments" do
98
+ before(:each) do
99
+
100
+ @comment = Insightly::Comment.new.build({
101
+ "COMMENT_ID" => 132456,
102
+ "BODY" => "test comment",
103
+ "OWNER_USER_ID" => 12345,
104
+ "DATE_CREATED_UTC" => "2012-03-09 11:59:19",
105
+ "DATE_UPDATED_UTC" => "2012-03-09 11:59:19",
106
+ "FILE_ATTACHMENTS" =>
107
+ {
108
+ "FILE_ID" => 4567899,
109
+ "FILE_NAME" => "test.docx",
110
+ "CONTENT_TYPE" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
111
+ "FILE_SIZE" => 2489,
112
+ "FILE_CATEGORY_ID" => nil,
113
+ "OWNER_USER_ID" => 12345,
114
+ "DATE_CREATED_UTC" => "2012-03-09 11:59:20",
115
+ "DATE_UPDATED_UTC" => "2012-03-09 11:59:20",
116
+ "URL" => "/api/fileattachments/4567899"
117
+ }
118
+ }
119
+ )
120
+
106
121
  end
107
- end
108
- it "should know that is it in progress" do
109
- @statuses.each do |s|
110
- @task.status = s
111
- s == "IN PROGRESS" ? (@task.should be_in_progress) : (@task.should_not be_in_progress)
122
+ it "should be able to fetch the comments" do
123
+ Insightly::Task.any_instance.should_receive(:get_collection).with("Tasks/#{@task.task_id}/comments").and_return([@comment.remote_data])
124
+ comments = @task.comments
125
+ comments.length.should == 1
126
+ comments.first.body.should == "test comment"
112
127
  end
113
- end
114
- it "should know that is it waiting" do
115
- @statuses.each do |s|
116
- @task.status = s
117
- s == "WAITING" ? (@task.should be_waiting) : (@task.should_not be_waiting)
128
+ it "should be able to post a new comment" do
129
+ value= "Test Comment #{Time.now}"
130
+ @comment.body = value
131
+ incoming_comment = Insightly::Comment.new.build({"BODY" => value})
132
+ Insightly::Task.any_instance.should_receive(:post_collection).with("Tasks/#{@task.task_id}/comments", incoming_comment.remote_data.to_json).and_return(@comment.remote_data)
133
+ #@task = Insightly::Task.new(3216775)
134
+
135
+ result = @task.comment_on(value)
136
+ result.comment_id.should_not be_nil
137
+ result.body.should == value
118
138
  end
119
139
  end
120
- it "should know that is it completed" do
121
- @statuses.each do |s|
122
- @task.status = s
123
- s == "COMPLETED" ? (@task.should be_completed) : (@task.should_not be_completed)
140
+ context "Status query" do
141
+ before(:each) do
142
+ @statuses = ["NOT STARTED", "IN PROGRESS", "WAITING", "COMPLETED", "DEFERRED"]
143
+ end
144
+ it "should know that is it not started" do
145
+ @statuses.each do |s|
146
+ @task.status = s
147
+ s == "NOT STARTED" ? (@task.should be_not_started) : (@task.should_not be_not_started)
148
+ end
149
+ end
150
+ it "should know that is it in progress" do
151
+ @statuses.each do |s|
152
+ @task.status = s
153
+ s == "IN PROGRESS" ? (@task.should be_in_progress) : (@task.should_not be_in_progress)
154
+ end
155
+ end
156
+ it "should know that is it waiting" do
157
+ @statuses.each do |s|
158
+ @task.status = s
159
+ s == "WAITING" ? (@task.should be_waiting) : (@task.should_not be_waiting)
160
+ end
124
161
  end
162
+ it "should know that is it completed" do
163
+ @statuses.each do |s|
164
+ @task.status = s
165
+ s == "COMPLETED" ? (@task.should be_completed) : (@task.should_not be_completed)
166
+ end
167
+ end
168
+ it "should know that is it deferred" do
169
+ @statuses.each do |s|
170
+ @task.status = s
171
+ s == "DEFERRED" ? (@task.should be_deferred) : (@task.should_not be_deferred)
172
+ end
173
+ end
174
+
175
+
125
176
  end
126
- it "should know that is it deferred" do
127
- @statuses.each do |s|
128
- @task.status = s
129
- s == "DEFERRED" ? (@task.should be_deferred) : (@task.should_not be_deferred)
177
+ context "link to an contact" do
178
+ before(:each) do
179
+
180
+
181
+ @contact = Insightly::Contact.build({
182
+
183
+ "VISIBLE_TO" => "OWNER",
184
+ "LAST_NAME" => "Other",
185
+ "FIRST_NAME" => "000 Test Contact #{Date.today}"
186
+
187
+ })
188
+
189
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
190
+ "RESPONSIBLE_USER_ID" => 500,
191
+ "OWNER_USER_ID" =>500,
192
+ "TITLE" => "000 Test Task #{Date.today}"
193
+ })
194
+ end
195
+ it "should be able to fetch the list of contact ids" do
196
+ @contact.contact_id = 100
197
+ @task.remote_id = 200
198
+ @task.contact_ids.should == []
199
+ @task.add_task_link(Insightly::TaskLink.add_contact(100))
200
+ @task.add_task_link(Insightly::TaskLink.add_organisation(200))
201
+ @task.contact_ids.should == [100]
130
202
  end
203
+ it "should be able to fetch the list of contacts" do
204
+ @task.remote_id = 200
205
+ @task.contacts.should == []
206
+ @contact.contact_id = 100
207
+ @task.add_task_link(Insightly::TaskLink.add_contact(100))
208
+ @task.add_task_link(Insightly::TaskLink.add_organisation(200))
209
+ Insightly::Contact.should_receive(:new).with(100).and_return(@contact)
210
+ @task.contacts.should == [@contact]
211
+ end
212
+ context "with an contact object" do
213
+
214
+
215
+ it "should not pre-save the task if it has an id" do
216
+ @task.task_id = 100
217
+ @task.should_not_receive(:save)
218
+ @contact.stub(:save)
219
+ @task.add_contact(@contact)
220
+ end
221
+ it "should save the task before linking if it has never been saved" do
222
+ @task.task_id.should be_nil
223
+ @task.should_receive(:save).twice do
224
+ @task.remote_id = 200
225
+ end
226
+ @contact.remote_id = 100
227
+ @contact.stub(:save)
228
+ @task.add_contact(@contact)
229
+ end
230
+ it "should save the contact before linking if it has never been saved" do
231
+ @task.stub(:save)
232
+ @contact.contact_id.should be_nil
233
+ @contact.should_receive(:save)
234
+ @task.add_contact(@contact)
235
+ end
236
+ it "should not pre-save the contact if it has an id" do
237
+ @task.task_id = 100
238
+ @task.stub(:save)
239
+ @contact.contact_id = 100
240
+ @contact.should_not_receive(:save)
241
+ @task.add_contact(@contact)
242
+ end
243
+ end
244
+ context "with an contact id" do
245
+
246
+ it "should not do anything if the contact is nil" do
247
+ @task.add_contact_id(nil).should be_false
248
+ end
249
+
250
+ it "should save the task before linking if it has never been saved" do
251
+ @task.task_id.should be_nil
252
+ @task.should_receive(:save).twice do
253
+ @task.remote_id = 200
254
+ end
255
+ org = mock
256
+
257
+ Insightly::Contact.stub(:new).with(100).and_return(org)
258
+ @task.add_contact_id(100)
259
+ end
260
+
261
+ end
262
+
131
263
  end
264
+ context "link to an opportunity" do
265
+ before(:each) do
132
266
 
133
267
 
134
- end
135
- it "should be able to link a task to an opportunity" do
136
- @opportunity = Insightly::Opportunity.build({
268
+ @opportunity = Insightly::Opportunity.build({
137
269
 
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
- })
270
+ "VISIBLE_TO" => "OWNER",
271
+ "BID_TYPE" => "Fixed Bid",
272
+ "ACTUAL_CLOSE_DATE" => nil,
273
+ "BID_CURRENTY" => "USD",
274
+ "OPPORTUNITY_STATE" => "Suspended",
275
+ "OPPORTUNITY_NAME" => "000 Test Opportunity #{Date.today}"
146
276
 
147
- @task = Insightly::Task.new.build({
277
+ })
148
278
 
279
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
280
+ "RESPONSIBLE_USER_ID" => 500,
281
+ "OWNER_USER_ID" =>500,
282
+ "TITLE" => "000 Test Task #{Date.today}"
283
+ })
284
+ end
285
+ it "should be able to fetch the list of opportunity ids" do
286
+ @opportunity.opportunity_id = 100
287
+ @task.remote_id = 200
288
+ @task.opportunity_ids.should == []
289
+ @task.add_task_link(Insightly::TaskLink.add_opportunity(100))
290
+ @task.add_task_link(Insightly::TaskLink.add_contact(200))
291
+ @task.opportunity_ids.should == [100]
292
+ end
293
+ it "should be able to fetch the list of opportunities" do
294
+ @task.remote_id = 200
295
+ @task.opportunities.should == []
296
+ @opportunity.opportunity_id = 100
297
+ @task.add_task_link(Insightly::TaskLink.add_opportunity(100))
298
+ @task.add_task_link(Insightly::TaskLink.add_contact(200))
299
+ Insightly::Opportunity.should_receive(:new).with(100).and_return(@opportunity)
300
+ @task.opportunities.should == [@opportunity]
301
+ end
302
+ context "with an opportunity object" do
149
303
 
150
- "PUBLICLY_VISIBLE" => true,
151
- "RESPONSIBLE_USER_ID" => "226277" ,
152
- "OWNER_USER_ID" => "226277" ,
153
- "DETAILS" => "This proves we can link them",
154
304
 
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
305
+ it "should not pre-save the task if it has an id" do
306
+ @task.task_id = 100
307
+ @task.should_not_receive(:save)
308
+ @opportunity.stub(:save)
309
+ @task.add_opportunity(@opportunity)
310
+ end
311
+ it "should save the task before linking if it has never been saved" do
312
+ @task.task_id.should be_nil
313
+ @task.should_receive(:save).twice do
314
+ @task.remote_id = 200
315
+ end
316
+ @opportunity.remote_id = 100
317
+ @opportunity.stub(:save)
318
+ @task.add_opportunity(@opportunity)
319
+ end
320
+ it "should save the opportunity before linking if it has never been saved" do
321
+ @task.stub(:save)
322
+ @opportunity.opportunity_id.should be_nil
323
+ @opportunity.should_receive(:save)
324
+ @task.add_opportunity(@opportunity)
325
+ end
326
+ it "should not pre-save the opportunity if it has an id" do
327
+ @task.task_id = 100
328
+ @task.stub(:save)
329
+ @opportunity.opportunity_id = 100
330
+ @opportunity.should_not_receive(:save)
331
+ @task.add_opportunity(@opportunity)
332
+ end
333
+ end
334
+ context "with an opportunity id" do
173
335
 
174
- context "TaskLinks" do
175
- before(:each) do
176
- # @task = Insightly::Task.new(3263739)
177
- @task = Insightly::Task.new
178
- @task.task_links = []
179
- # @task.save
336
+ it "should not do anything if the opportunity is nil" do
337
+ @task.add_opportunity_id(nil).should be_false
338
+ end
339
+
340
+ it "should save the task before linking if it has never been saved" do
341
+ @task.task_id.should be_nil
342
+ @task.should_receive(:save).twice do
343
+ @task.remote_id = 200
344
+ end
345
+ org = mock
346
+
347
+ Insightly::Opportunity.stub(:new).with(100).and_return(org)
348
+ @task.add_opportunity_id(100)
349
+ end
350
+
351
+ end
352
+
353
+ end
354
+ context "link to an organisation" do
355
+ before(:each) do
180
356
 
181
357
 
182
- @link = Insightly::TaskLink.add_organisation(8936117)
183
- @link2 = Insightly::TaskLink.add_opportunity(968613)
184
- end
185
- it "should allow you to try to set it to nil" do
186
- @task = Insightly::Task.new
187
- @task.task_links = nil
188
- @task.task_links.should == []
189
- end
190
- it "should allow you to update an link" do
191
- @task.task_links.should == []
192
- @task.add_task_link(@link)
358
+ @organisation = Insightly::Organisation.build({
193
359
 
194
- @task.save
195
- @link = @task.task_links.first
196
- @link2.task_link_id = @link.task_link_id
197
- @task.task_links = [@link2]
198
- @task.save
199
- @task.reload
200
- @task.task_links.length.should == 1
201
- @task.task_links.first.opportunity_id.should == 968613
202
- end
203
- it "should allow you to add an link" do
360
+ "VISIBLE_TO" => "OWNER",
361
+ "ORGANISATION_NAME" => "000 Test Organisation #{Date.today}"
204
362
 
363
+ })
205
364
 
206
- @task.task_links.should == []
207
- @task.add_task_link(@link)
208
-
209
- @task.save
210
- @task.reload
211
- @task.task_links.length.should == 1
212
- @task.task_links.first.organisation_id.should == 8936117
213
- end
214
- it "should allow you to remove an link" do
365
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
366
+ "RESPONSIBLE_USER_ID" => 500,
367
+ "OWNER_USER_ID" =>500,
368
+ "TITLE" => "000 Test Task #{Date.today}"
369
+ })
370
+ end
371
+ it "should be able to fetch the list of organisation ids" do
372
+ @organisation.organisation_id = 100
373
+ @task.remote_id = 200
374
+ @task.organisation_ids.should == []
375
+ @task.add_task_link(Insightly::TaskLink.add_organisation(100))
376
+ @task.add_task_link(Insightly::TaskLink.add_contact(200))
377
+ @task.organisation_ids.should == [100]
378
+ end
379
+ it "should be able to fetch the list of organisations" do
380
+ @task.remote_id = 200
381
+ @task.organisations.should == []
382
+ @organisation.organisation_id = 100
383
+ @task.add_task_link(Insightly::TaskLink.add_organisation(100))
384
+ @task.add_task_link(Insightly::TaskLink.add_contact(200))
385
+ Insightly::Organisation.should_receive(:new).with(100).and_return(@organisation)
386
+ @task.organisations.should == [@organisation]
387
+ end
388
+ context "with an organisation object" do
215
389
 
216
- @task.task_links.should == []
217
- @task.add_task_link(@link)
218
390
 
219
- @task.save
220
- @task.task_links = []
221
- @task.save
222
- @task.reload
223
- @task.task_links.length.should == 0
391
+ it "should not pre-save the task if it has an id" do
392
+ @task.task_id = 100
393
+ @task.should_not_receive(:save)
394
+ @organisation.stub(:save)
395
+ @task.add_organisation(@organisation)
396
+ end
397
+ it "should save the task before linking if it has never been saved" do
398
+ @task.task_id.should be_nil
399
+ @task.should_receive(:save).twice do
400
+ @task.remote_id = 200
401
+ end
402
+ @organisation.remote_id = 100
403
+ @organisation.stub(:save)
404
+ @task.add_organisation(@organisation)
405
+ end
406
+ it "should save the organisation before linking if it has never been saved" do
407
+ @task.stub(:save)
408
+ @organisation.organisation_id.should be_nil
409
+ @organisation.should_receive(:save)
410
+ @task.add_organisation(@organisation)
411
+ end
412
+ it "should not pre-save the organisation if it has an id" do
413
+ @task.task_id = 100
414
+ @task.stub(:save)
415
+ @organisation.organisation_id = 100
416
+ @organisation.should_not_receive(:save)
417
+ @task.add_organisation(@organisation)
418
+ end
419
+ end
420
+ context "with an organisation id" do
224
421
 
225
- end
226
- it "should allow you to clear all links" do
227
- @task.task_links.should == []
228
- @task.add_task_link(@link)
422
+ it "should not do anything if the organisation is nil" do
423
+ @task.add_organisation_id(nil).should be_false
424
+ end
425
+
426
+ it "should save the task before linking if it has never been saved" do
427
+ @task.task_id.should be_nil
428
+ @task.should_receive(:save).twice do
429
+ @task.remote_id = 200
430
+ end
431
+ org = mock
432
+
433
+ Insightly::Organisation.stub(:new).with(100).and_return(org)
434
+ @task.add_organisation_id(100)
435
+ end
436
+
437
+ end
229
438
 
230
- @task.save
231
- @task.task_links = []
232
- @task.save
233
- @task.reload
234
- @task.task_links.length.should == 0
235
439
  end
236
- end
440
+
441
+
442
+ context "TaskLinks" do
443
+
444
+ it "should allow you to try to set it to nil" do
445
+ @task = Insightly::Task.new
446
+ @task.task_links = nil
447
+ @task.task_links.should == []
448
+ end
449
+ it "should raise an error if you try to add a link but have not saved" do
450
+ @task = Insightly::Task.new
451
+ expect { @task.add_task_link(@link) }.to raise_error(ScriptError, "You must save the Insightly::Task before adding a link.")
452
+ end
453
+
454
+ end
455
+ end
456
+ context "with network" do
457
+ before(:each) do
458
+ Insightly::Configuration.api_key = INSIGHTLY_API_KEY
459
+ Insightly::Configuration.logger = Insightly::Configuration._debug_logger
460
+ @user = simple_insightly_user
461
+
462
+
463
+ end
464
+ it "should be able to load a task from a id" do
465
+
466
+ VCR.use_cassette('load task by id') do
467
+ @task = simple_insightly_task
468
+ @task.reload
469
+ @alt_task = Insightly::Task.new(@task.remote_id)
470
+ end
471
+ @alt_task.should == @task
472
+ end
473
+ context "link to an contact" do
474
+ before(:each) do
475
+
476
+
477
+
478
+ @contact = Insightly::Contact.build({
479
+
480
+ "VISIBLE_TO" => "OWNER",
481
+ "LAST_NAME" => "Other",
482
+ "FIRST_NAME" => "000 Test Contact #{Date.today}"
483
+
484
+ })
485
+
486
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
487
+ "RESPONSIBLE_USER_ID" => @user.user_id,
488
+ "OWNER_USER_ID" => @user.user_id,
489
+ "TITLE" => "000 Test Task #{Date.today}"
490
+ })
491
+ end
492
+
493
+ context "with an contact object" do
494
+ it "should be able to link to a task" do
495
+ VCR.use_cassette('add an contact to a task with object') do
496
+ @task.add_contact(@contact)
497
+ @task.reload
498
+ @contact.reload
499
+ @task.contacts.should == [@contact]
500
+ end
501
+ end
502
+
503
+
504
+ end
505
+ context "with an contact id" do
506
+ it "should be able to link to a task" do
507
+ VCR.use_cassette('add an contact to a task by id') do
508
+ @contact.save
509
+ @task.add_contact_id(@contact.contact_id)
510
+ end
511
+ @task.contact_ids.should == [@contact.contact_id]
512
+ end
513
+
514
+
515
+ end
516
+
517
+ end
518
+ context "link to an opportunity" do
519
+ before(:each) do
520
+
521
+
522
+ @opportunity = Insightly::Opportunity.build({
523
+
524
+ "VISIBLE_TO" => "OWNER",
525
+ "BID_TYPE" => "Fixed Bid",
526
+ "ACTUAL_CLOSE_DATE" => nil,
527
+ "BID_CURRENTY" => "USD",
528
+ "OPPORTUNITY_STATE" => "Suspended",
529
+ "OPPORTUNITY_NAME" => "000 Test Opportunity #{Date.today}"
530
+
531
+ })
532
+
533
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
534
+ "RESPONSIBLE_USER_ID" => @user.user_id,
535
+ "OWNER_USER_ID" => @user.user_id,
536
+ "TITLE" => "000 Test Task #{Date.today}"
537
+ })
538
+ end
539
+
540
+ context "with an opportunity object" do
541
+ it "should be able to link to a task" do
542
+ VCR.use_cassette('add an opportunity to a task with object') do
543
+ @task.add_opportunity(@opportunity)
544
+ @task.reload
545
+ @opportunity.reload
546
+ @task.opportunities.should == [@opportunity]
547
+ end
548
+ end
549
+
550
+
551
+ end
552
+ context "with an opportunity id" do
553
+ it "should be able to link to a task" do
554
+ VCR.use_cassette('add an opportunity to a task by id') do
555
+ @opportunity.save
556
+ @task.add_opportunity_id(@opportunity.opportunity_id)
557
+ end
558
+ @task.opportunity_ids.should == [@opportunity.opportunity_id]
559
+ end
560
+
561
+
562
+ end
563
+
564
+ end
565
+ context "link to an organisation" do
566
+ before(:each) do
567
+
568
+
569
+ @organisation = Insightly::Organisation.build({
570
+
571
+ "VISIBLE_TO" => "OWNER",
572
+ "ORGANISATION_NAME" => "000 Test Organisation #{Date.today}"
573
+
574
+ })
575
+
576
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
577
+ "RESPONSIBLE_USER_ID" => @user.user_id,
578
+ "OWNER_USER_ID" => @user.user_id,
579
+ "TITLE" => "000 Test Task #{Date.today}"
580
+ })
581
+ end
582
+
583
+ context "with an organisation object" do
584
+ it "should be able to link to a task" do
585
+ VCR.use_cassette('add an organisation to a task with object') do
586
+
587
+
588
+ @task.add_organisation(@organisation)
589
+ @task.reload
590
+ @organisation.reload
591
+ @task.organisations.should == [@organisation]
592
+ end
593
+ end
594
+
595
+
596
+ end
597
+ context "with an organisation id" do
598
+ it "should be able to link to a task" do
599
+ VCR.use_cassette('add an organisation to a task by id') do
600
+ @organisation.save
601
+ @task.add_organisation_id(@organisation.organisation_id)
602
+ end
603
+ @task.organisation_ids.should == [@organisation.organisation_id]
604
+ end
605
+
606
+
607
+ end
608
+
609
+ end
610
+
611
+
612
+ context "TaskLinks" do
613
+ before(:each) do
614
+
615
+
616
+ VCR.use_cassette('simple task') do
617
+ @task = Insightly::Task.new.build({"STATUS" => "Completed",
618
+ "RESPONSIBLE_USER_ID" => @user.user_id,
619
+ "OWNER_USER_ID" => @user.user_id,
620
+ "TITLE" => "000 Test Task #{Date.today}"
621
+ })
622
+ @task.save
623
+ end
624
+ @task.task_links.should == []
625
+ VCR.use_cassette('organisation task link') do
626
+ @organisation = Insightly::Organisation.build({
627
+ "VISIBLE_TO" => "OWNER",
628
+ "ORGANISATION_NAME" => "000 Test Org #{Date.today}"
629
+ })
630
+ @organisation.save
631
+ @link = Insightly::TaskLink.add_organisation(@organisation.remote_id)
632
+ end
633
+ VCR.use_cassette('opportunity task link') do
634
+ @opportunity = Insightly::Opportunity.build({
635
+
636
+ "VISIBLE_TO" => "OWNER",
637
+ "BID_TYPE" => "Fixed Bid",
638
+ "ACTUAL_CLOSE_DATE" => nil,
639
+ "BID_CURRENTY" => "USD",
640
+ "OPPORTUNITY_STATE" => "Suspended",
641
+ "OPPORTUNITY_NAME" => "000 Test Opportunity #{Date.today}"
642
+
643
+ })
644
+ @opportunity.save
645
+ @link2 = Insightly::TaskLink.add_opportunity(@opportunity.remote_id)
646
+ end
647
+ end
648
+
649
+ it "should allow you to update an link" do
650
+ VCR.use_cassette('update task link for simple task') do
651
+ @task.task_links.should == []
652
+ @task.add_task_link(@link)
653
+
654
+ @task.save
655
+ @link = @task.task_links.first
656
+ @link2.task_link_id = @link.task_link_id
657
+ @task.task_links = [@link2]
658
+ @task.save
659
+ @task.reload
660
+ @task.task_links.length.should == 1
661
+ @task.task_links.first.opportunity_id.should == @opportunity.remote_id
662
+ end
663
+
664
+ end
665
+ it "should allow you to add an link" do
666
+
667
+ VCR.use_cassette('add task link to simple task') do
668
+ @task.task_links.should == []
669
+ @task.add_task_link(@link)
670
+
671
+ @task.save
672
+ @task.reload
673
+ @task.task_links.length.should == 1
674
+ @task.task_links.first.organisation_id.should == @organisation.remote_id
675
+ end
676
+ end
677
+ it "should allow you to remove an link" do
678
+ VCR.use_cassette('remove task link from simple task') do
679
+ @task.task_links.should == []
680
+ @task.add_task_link(@link)
681
+
682
+ @task.save
683
+ @task.task_links = []
684
+ @task.save
685
+ @task.reload
686
+ @task.task_links.length.should == 0
687
+ end
688
+
689
+ end
690
+ it "should allow you to clear all links" do
691
+ VCR.use_cassette('clear task links for simple task') do
692
+ @task.task_links.should == []
693
+ @task.add_task_link(@link)
694
+
695
+ @task.save
696
+ @task.task_links = []
697
+ @task.save
698
+ @task.reload
699
+ @task.task_links.length.should == 0
700
+ end
701
+ end
702
+ end
703
+ end
704
+
705
+
706
+
707
+
237
708
  end