rubyzoho 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,19 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
+ require 'vcr'
3
4
 
4
5
  SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
6
  SimpleCov.start do
6
7
  add_filter 'app/secrets'
7
- end
8
+ end
8
9
 
9
10
  Coveralls.wear!
10
11
 
11
- # This file was generated by the `rspec --init` command. Conventionally, all
12
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
13
- # Require this file using `require "spec_helper"` to ensure that it is only
14
- # loaded once.
15
- #
16
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
12
  RSpec.configure do |config|
18
- config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ # config.treat_symbols_as_metadata_keys_with_true_values = true
19
14
  config.run_all_when_everything_filtered = true
20
15
  config.filter_run :focus
16
+ config.expect_with(:rspec) { |c| c.syntax = :should }
21
17
 
22
18
  # Run specs in random order to surface order dependencies. If you find an
23
19
  # order dependency and want to debug it, you can fix the order by providing
@@ -25,3 +21,4 @@ RSpec.configure do |config|
25
21
  # --seed 1234
26
22
  config.order = 'random'
27
23
  end
24
+
@@ -5,276 +5,335 @@ require 'spec_helper'
5
5
  require 'zoho_api'
6
6
  require 'xmlsimple'
7
7
  require 'yaml'
8
- #require 'vcr'
8
+ require 'vcr'
9
+
10
+ VCR.configure do |c|
11
+ c.cassette_library_dir = 'spec/vcr'
12
+ c.hook_into :webmock
13
+ # c.default_cassette_options = {:record => :all}
14
+ # c.debug_logger = File.open('log/vcr_debug.log', 'w')
15
+ end
9
16
 
10
17
  describe ZohoApi do
11
18
 
12
19
  def add_dummy_contact
13
- c = {:first_name => 'BobDifficultToMatch', :last_name => 'SmithDifficultToMatch',
14
- :email => 'bob@smith.com'}
15
- @zoho.add_record('Contacts', c)
20
+ VCR.use_cassette 'api_response/add_dummy_contact' do
21
+ c = {:first_name => 'BobDifficultToMatch', :last_name => 'SmithDifficultToMatch',
22
+ :email => 'bob@smith.com'}
23
+ @zoho.add_record('Contacts', c)
24
+ end
16
25
  end
17
26
 
18
27
  def delete_dummy_contact
19
- c = @zoho.find_records(
20
- 'Contacts', :email, '=', 'bob@smith.com')
21
- @zoho.delete_record('Contacts', c[0][:contactid]) unless c == []
28
+ VCR.use_cassette 'api_response/delete_dummy_contact' do
29
+ c = @zoho.find_records(
30
+ 'Contacts', :email, '=', 'bob@smith.com')
31
+ @zoho.delete_record('Contacts', c[0][:contactid]) unless c == []
32
+ end
22
33
  end
23
34
 
24
35
  def init_api(api_key, base_path, modules)
25
- ignore_fields = true
26
- if File.exists?(File.join(base_path, 'fields.snapshot'))
27
- #noinspection RubyResolve
28
- fields = YAML.load(File.read(File.join(base_path, 'fields.snapshot')))
29
- zoho = ZohoApi::Crm.new(api_key, modules, ignore_fields, fields)
30
- else
31
- zoho = ZohoApi::Crm.new(api_key, modules, ignore_fields)
32
- fields = zoho.module_fields
33
- File.open(File.join(base_path, 'fields.snapshot'), 'wb') { |file| file.write(fields.to_yaml) }
36
+ zoho = nil
37
+ VCR.use_cassette 'api_response/init_api' do
38
+ ignore_fields = true
39
+ if File.exists?(File.join(base_path, 'fields.snapshot'))
40
+ #noinspection RubyResolve
41
+ fields = YAML.load(File.read(File.join(base_path, 'fields.snapshot')))
42
+ zoho = ZohoApi::Crm.new(api_key, modules, ignore_fields, fields)
43
+ else
44
+ zoho = ZohoApi::Crm.new(api_key, modules, ignore_fields)
45
+ fields = zoho.module_fields
46
+ File.open(File.join(base_path, 'fields.snapshot'), 'wb') { |file| file.write(fields.to_yaml) }
47
+ end
34
48
  end
35
49
  zoho
36
50
  end
37
51
 
38
52
  before(:all) do
39
- #VCR.configure do |c|
40
- # c.cassette_library_dir = 'fixtures/vcr_cassettes'
41
- # c.hook_into :webmock # or :fakeweb
42
- #end
43
-
44
- base_path = File.join(File.dirname(__FILE__), 'fixtures')
45
- @sample_pdf = File.join(base_path, 'sample.pdf')
46
- modules = %w(Accounts Contacts Events Leads Tasks Potentials)
47
- @zoho = init_api(ENV['ZOHO_API_KEY'].strip, base_path, modules)
48
- @h_smith = { :first_name => 'Robert',
49
- :last_name => 'Smith',
50
- :email => 'rsmith@smithereens.com',
51
- :department => 'Waste Collection and Management',
52
- :phone => '13452129087',
53
- :mobile => '12341238790'
54
- }
55
- contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
56
- contacts.each { |c| @zoho.delete_record('Contacts', c[:contactid]) } unless contacts.nil?
53
+ VCR.use_cassette('api_response/initialization') do
54
+ base_path = File.join(File.dirname(__FILE__), 'fixtures')
55
+ @sample_pdf = File.join(base_path, 'sample.pdf')
56
+ modules = %w(Accounts Contacts Events Leads Tasks Potentials)
57
+ @zoho = init_api(ENV['ZOHO_API_KEY'].strip, base_path, modules)
58
+ @h_smith = {:first_name => 'Robert',
59
+ :last_name => 'Smith',
60
+ :email => 'rsmith@smithereens.com',
61
+ :department => 'Waste Collection and Management',
62
+ :phone => '13452129087',
63
+ :mobile => '12341238790'
64
+ }
65
+ contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
66
+ contacts.each { |c| @zoho.delete_record('Contacts', c[:contactid]) } unless contacts.nil?
67
+ end
57
68
  end
58
69
 
59
70
  it 'should add a new contact' do
60
- @zoho.add_record('Contacts', @h_smith)
61
- contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
62
- @zoho.delete_record('Contacts', contacts[0][:contactid])
63
- contacts.should_not eq(nil)
64
- # contacts.count.should eq(1)
71
+ VCR.use_cassette 'api_response/add_contact' do
72
+ @zoho.add_record('Contacts', @h_smith)
73
+ contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
74
+ @zoho.delete_record('Contacts', contacts[0][:contactid])
75
+ contacts.should_not eq(nil)
76
+ # contacts.count.should eq(1)
77
+ end
65
78
  end
66
79
 
67
80
  it 'should add a new event' do
68
81
  pending
69
- pp @zoho.fields_from_api('Events')
70
- pp @zoho.fields_from_record('Events')
71
- pp @zoho.some('Events')
72
- h = { :subject => 'Test Event',
73
- :start_datetime => '2014-02-16 16:00:00',
74
- :end_datetime => '2014-02-16 18:00:00'
75
- }
76
- @zoho.add_record('Events', h)
77
- events = @zoho.some('Events')
78
- pp events
79
- #@zoho.delete_record('Contacts', contacts[0][:contactid])
80
- events.should_not eq(nil)
81
- events.count.should eq(1)
82
+ VCR.use_cassette 'api_response/add_event' do
83
+ @zoho.fields_from_api('Events')
84
+ @zoho.fields_from_record('Events')
85
+ @zoho.some('Events')
86
+ h = {:subject => 'Test Event',
87
+ :start_datetime => '2014-02-16 16:00:00',
88
+ :end_datetime => '2014-02-16 18:00:00'
89
+ }
90
+ @zoho.add_record('Events', h)
91
+ events = @zoho.some('Events')
92
+ events
93
+ #@zoho.delete_record('Contacts', contacts[0][:contactid])
94
+ events.should_not eq(nil)
95
+ events.count.should eq(1)
96
+ end
82
97
  end
83
98
 
84
99
  it 'should attach a file to a contact record' do
85
- @zoho.add_record('Contacts', @h_smith)
86
- contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
87
- @zoho.attach_file('Contacts', contacts[0][:contactid], @sample_pdf, File.basename(@sample_pdf))
88
- @zoho.delete_record('Contacts', contacts[0][:contactid])
100
+ VCR.use_cassette 'api_response/add_file_to_contact' do
101
+ @zoho.add_record('Contacts', @h_smith)
102
+ contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
103
+ @zoho.attach_file('Contacts', contacts[0][:contactid], @sample_pdf, File.basename(@sample_pdf))
104
+ @zoho.delete_record('Contacts', contacts[0][:contactid])
105
+ end
89
106
  end
90
107
 
91
108
  it 'should attach a file to a potential record' do
92
109
  pending
93
- potential = @zoho.first('Potentials').first
94
- @zoho.attach_file('Potentials', potential[:potentialid], @sample_pdf, File.basename(@sample_pdf))
110
+ VCR.use_cassette 'api_response/add_file_to_potential' do
111
+ potential = @zoho.first('Potentials').first
112
+ @zoho.attach_file('Potentials', potential[:potentialid], @sample_pdf, File.basename(@sample_pdf))
113
+ true.should eq(false)
114
+ end
95
115
  end
96
116
 
97
117
  it 'should delete a contact record with id' do
98
- add_dummy_contact
99
- c = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
100
- @zoho.delete_record('Contacts', c[0][:contactid])
118
+ VCR.use_cassette 'api_response/delete_contact_with_id' do
119
+ add_dummy_contact
120
+ c = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
121
+ @zoho.delete_record('Contacts', c[0][:contactid])
122
+ end
101
123
  end
102
124
 
103
125
  it 'should find by module and field for columns' do
104
- add_dummy_contact
105
- r = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
106
- r[0][:email].should eq('bob@smith.com')
107
- delete_dummy_contact
126
+ VCR.use_cassette 'api_response/find_by_module_and_field' do
127
+ add_dummy_contact
128
+ r = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
129
+ r[0][:email].should eq('bob@smith.com')
130
+ delete_dummy_contact
131
+ end
108
132
  end
109
133
 
110
134
  it 'should find by module and id' do
111
- add_dummy_contact
112
- r = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
113
- r[0][:email].should eq('bob@smith.com')
114
- id = r[0][:contactid]
115
- c = @zoho.find_record_by_id('Contacts', id)
116
- c[0][:contactid].should eq(id)
117
- delete_dummy_contact
135
+ VCR.use_cassette 'api_response/find_by_module_and_id' do
136
+ add_dummy_contact
137
+ r = @zoho.find_records('Contacts', :email, '=', 'bob@smith.com')
138
+ r[0][:email].should eq('bob@smith.com')
139
+ id = r[0][:contactid]
140
+ c = @zoho.find_record_by_id('Contacts', id)
141
+ c[0][:contactid].should eq(id)
142
+ delete_dummy_contact
143
+ end
118
144
  end
119
145
 
120
146
  it 'should find by a potential by name, id and related id' do
121
- accounts = @zoho.some('Accounts')
122
- p = {
123
- :potential_name => 'A very big potential INDEED!!!!!!!!!!!!!',
124
- :accountid => accounts.first[:accountid],
125
- :account_name => accounts.first[:account_name],
126
- :closing_date => '1/1/2014',
127
- :type => 'New Business',
128
- :stage => 'Needs Analysis'
129
- }
130
- potentials = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
131
- potentials.map { |r| @zoho.delete_record('Potentials', r[:potentialid])} unless potentials.nil?
132
-
133
- @zoho.add_record('Potentials', p)
134
- p1 = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
135
- p1.should_not eq(nil)
136
-
137
- p2 = @zoho.find_records('Potentials', :potentialid, '=', p1.first[:potentialid])
138
- p2.first[:potentialid].should eq(p1.first[:potentialid])
139
-
140
- p_related = @zoho.find_records('Potentials', :accountid, '=', p[:accountid])
141
- p_related.first[:accountid].should eq(p[:accountid])
142
-
143
- potentials = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
144
- potentials.map { |r| @zoho.delete_record('Potentials', r[:potentialid])} unless potentials.nil?
147
+ VCR.use_cassette 'api_response' do
148
+ accounts = @zoho.some('Accounts')
149
+ p = {
150
+ :potential_name => 'A very big potential INDEED!!!!!!!!!!!!!',
151
+ :accountid => accounts.first[:accountid],
152
+ :account_name => accounts.first[:account_name],
153
+ :closing_date => '1/1/2014',
154
+ :type => 'New Business',
155
+ :stage => 'Needs Analysis'
156
+ }
157
+ potentials = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
158
+ potentials.map { |r| @zoho.delete_record('Potentials', r[:potentialid]) } unless potentials.nil?
159
+
160
+ @zoho.add_record('Potentials', p)
161
+ p1 = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
162
+ p1.should_not eq(nil)
163
+
164
+ p2 = @zoho.find_records('Potentials', :potentialid, '=', p1.first[:potentialid])
165
+ p2.first[:potentialid].should eq(p1.first[:potentialid])
166
+
167
+ p_related = @zoho.find_records('Potentials', :accountid, '=', p[:accountid])
168
+ p_related.first[:accountid].should eq(p[:accountid])
169
+
170
+ potentials = @zoho.find_records('Potentials', :potential_name, '=', p[:potential_name])
171
+ potentials.map { |r| @zoho.delete_record('Potentials', r[:potentialid]) } unless potentials.nil?
172
+ end
145
173
  end
146
174
 
147
175
  it 'should get a list of fields for a module' do
148
- r = @zoho.fields('Accounts')
149
- r.count.should >= 10
150
- r = @zoho.fields('Contacts')
151
- r.count.should be >= 10
152
- r = @zoho.fields('Events')
153
- r.count.should >= 10
154
- r = @zoho.fields('Leads')
155
- r.count.should be >= 10
156
- r = @zoho.fields('Potentials')
157
- r.count.should be >= 10
158
- r = @zoho.fields('Tasks')
159
- r.count.should >= 10
160
- r = @zoho.fields('Users')
161
- r.count.should >= 7
176
+ VCR.use_cassette 'api_response/list_of_fields' do
177
+ r = @zoho.fields('Accounts')
178
+ r.count.should >= 10
179
+ r = @zoho.fields('Contacts')
180
+ r.count.should be >= 10
181
+ r = @zoho.fields('Events')
182
+ r.count.should >= 10
183
+ r = @zoho.fields('Leads')
184
+ r.count.should be >= 10
185
+ r = @zoho.fields('Potentials')
186
+ r.count.should be >= 10
187
+ r = @zoho.fields('Tasks')
188
+ r.count.should >= 10
189
+ r = @zoho.fields('Users')
190
+ r.count.should >= 7
191
+ end
162
192
  end
163
193
 
164
194
  it 'should get a list of user fields' do
165
- r = @zoho.user_fields
166
- r.count.should be >= 7
195
+ VCR.use_cassette 'api_response/user_fields' do
196
+ r = @zoho.user_fields
197
+ r.count.should be >= 7
198
+ end
167
199
  end
168
200
 
169
201
  it 'should get a list of local and remote fields' do
170
202
  pending
171
- @zoho.fields('Accounts')
172
- pp r = @zoho.fields_original('Accounts')
173
- r.count.should >= 10
203
+ VCR.use_cassette 'api_response/remote_fields' do
204
+ @zoho.fields('Accounts')
205
+ r = @zoho.fields_original('Accounts')
206
+ r.count.should >= 10
207
+ end
174
208
  end
175
209
 
176
210
  it 'should retrieve records by module name' do
177
- r = @zoho.some('Contacts')
178
- r.should_not eq(nil)
179
- r.count.should be >= 1
211
+ VCR.use_cassette 'api_response/records_by_module_name' do
212
+ r = @zoho.some('Contacts')
213
+ r.should_not eq(nil)
214
+ r.count.should be >= 1
215
+ end
180
216
  end
181
217
 
182
218
  it 'should return related records by module and id' do
183
219
  pending
184
- r = @zoho.some('Accounts').first
185
- pp r
186
- #related = @zoho.related_records('Accounts', r[:accountid], 'Attachments')
220
+ VCR.use_cassette 'api_response/records_by_module_and_id' do
221
+ r = @zoho.some('Accounts').first
222
+ true.should eq(false)
223
+ #related = @zoho.related_records('Accounts', r[:accountid], 'Attachments')
224
+ end
187
225
  end
188
226
 
189
227
  it 'should return calls' do
190
228
  pending
191
- r = @zoho.some('Calls').first
192
- r.should_not eq(nil)
229
+ VCR.use_cassette 'api_response/calls' do
230
+ r = @zoho.some('Calls').first
231
+ r.should_not eq(nil)
232
+ end
193
233
  end
194
234
 
195
235
  it 'should return events' do
196
236
  pending
197
- r = @zoho.some('Events').first
198
- r.should_not eq(nil)
237
+ VCR.use_cassette 'api_response/events' do
238
+ r = @zoho.some('Events').first
239
+ r.should_not eq(nil)
240
+ end
199
241
  end
200
242
 
201
243
  it 'should return tasks' do
202
- r = @zoho.some('Tasks').first
203
- r.should_not eq(nil)
244
+ VCR.use_cassette 'api_response/tasks' do
245
+ r = @zoho.some('Tasks').first
246
+ r.should_not eq(nil)
247
+ end
204
248
  end
205
249
 
206
250
  it 'should return users' do
207
- r = @zoho.users
208
- r.should_not eq(nil)
251
+ VCR.use_cassette 'api_response/users' do
252
+ r = @zoho.users
253
+ r.should_not eq(nil)
254
+ end
209
255
  end
210
256
 
211
257
  it 'should test for a primary key' do
212
- @zoho.primary_key?('Accounts', 'accountid').should eq(true)
213
- @zoho.primary_key?('Accounts', 'potentialid').should eq(false)
214
- @zoho.primary_key?('Accounts', 'Potential Name').should eq(false)
215
- @zoho.primary_key?('Accounts', 'Account Name').should eq(false)
216
- @zoho.primary_key?('Accounts', 'account_name').should eq(false)
258
+ VCR.use_cassette 'api_response/primary_key' do
259
+ @zoho.primary_key?('Accounts', 'accountid').should eq(true)
260
+ @zoho.primary_key?('Accounts', 'potentialid').should eq(false)
261
+ @zoho.primary_key?('Accounts', 'Potential Name').should eq(false)
262
+ @zoho.primary_key?('Accounts', 'Account Name').should eq(false)
263
+ @zoho.primary_key?('Accounts', 'account_name').should eq(false)
264
+ end
217
265
  end
218
266
 
219
267
  it 'should test for a related id' do
220
- @zoho.related_id?('Potentials', 'Account Name').should eq(false)
221
- @zoho.related_id?('Potentials', 'Accountid').should eq(true)
268
+ VCR.use_cassette 'api_response/related_id' do
269
+ @zoho.related_id?('Potentials', 'Account Name').should eq(false)
270
+ @zoho.related_id?('Potentials', 'Accountid').should eq(true)
271
+ end
222
272
  end
223
273
 
224
274
  it 'should test for a valid related field' do
225
- @zoho.valid_related?('Accounts', 'accountid').should_not eq(nil)
226
- @zoho.valid_related?('Notes', 'notesid').should_not eq(nil)
227
- @zoho.valid_related?('Accounts', 'email').should eq(nil)
275
+ VCR.use_cassette 'api_response/valid_related_id' do
276
+ @zoho.valid_related?('Accounts', 'accountid').should_not eq(nil)
277
+ @zoho.valid_related?('Notes', 'notesid').should_not eq(nil)
278
+ @zoho.valid_related?('Accounts', 'email').should eq(nil)
279
+ end
228
280
  end
229
281
 
230
282
  it 'should do a full CRUD lifecycle on tasks' do
231
- pending
232
- mod_name = 'Tasks'
233
- fields = @zoho.fields(mod_name)
234
- fields.count >= 10
235
- fields.index(:task_owner).should_not eq(nil)
236
- @zoho.add_record(mod_name, {:task_owner => 'Task Owner', :subject => 'Test Task', :due_date => '2100/1/1'})
237
- r = @zoho.find_record_by_field('Tasks', 'Subject', '=', 'Test Task')
238
- r.should_not eq(nil)
239
- r.map { |t| @zoho.delete_record('Tasks', t[:activityid]) }
283
+ VCR.use_cassette 'api_response/full_crud_lifecycle' do
284
+ mod_name = 'Tasks'
285
+ fields = @zoho.fields(mod_name)
286
+ fields.count >= 10
287
+ fields.index(:task_owner).should_not eq(nil)
288
+ @zoho.add_record(mod_name, {:task_owner => 'Task Owner', :subject => 'Test Task', :due_date => '2100/1/1'})
289
+ r = @zoho.find_record_by_field('Tasks', 'Subject', '=', 'Test Task')
290
+ r.should_not eq(nil)
291
+ r.map { |t| @zoho.delete_record('Tasks', t[:activityid]) }
292
+ end
240
293
  end
241
294
 
242
- it 'should update fields from a record' do
243
- @zoho.module_fields.count.should be >= 7
295
+ it 'should update fields from a record/update_fields_from_record' do
296
+ VCR.use_cassette 'api_response' do
297
+ @zoho.module_fields.count.should be >= 7
298
+ end
244
299
  end
245
300
 
246
301
  it 'should update a contact' do
247
- @zoho.add_record('Contacts', @h_smith)
248
- contact = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
249
- h_changed = { :email => 'robert.smith@smithereens.com' }
250
- @zoho.update_record('Contacts', contact[0][:contactid], h_changed)
251
- changed_contact = @zoho.find_records('Contacts', :email, '=', h_changed[:email])
252
- changed_contact[0][:email].should eq(h_changed[:email])
253
- @zoho.delete_record('Contacts', contact[0][:contactid])
302
+ VCR.use_cassette 'api_response/update_contact' do
303
+ @zoho.add_record('Contacts', @h_smith)
304
+ contact = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
305
+ h_changed = {:email => 'robert.smith@smithereens.com'}
306
+ @zoho.update_record('Contacts', contact[0][:contactid], h_changed)
307
+ changed_contact = @zoho.find_records('Contacts', :email, '=', h_changed[:email])
308
+ changed_contact[0][:email].should eq(h_changed[:email])
309
+ @zoho.delete_record('Contacts', contact[0][:contactid])
310
+ end
254
311
  end
255
312
 
256
313
  it 'should validate that a field name is clean' do
257
- @zoho.clean_field_name?(nil).should eq(false)
258
- @zoho.clean_field_name?('Name').should eq(true)
259
- @zoho.clean_field_name?('Full_Name').should eq(true)
260
- @zoho.clean_field_name?('Name (All Upper)').should eq(false)
314
+ VCR.use_cassette 'api_response/clean_field_name' do
315
+ @zoho.clean_field_name?(nil).should eq(false)
316
+ @zoho.clean_field_name?('Name').should eq(true)
317
+ @zoho.clean_field_name?('Full_Name').should eq(true)
318
+ @zoho.clean_field_name?('Name (All Upper)').should eq(false)
319
+ end
261
320
  end
262
321
 
263
322
  it 'should relate contact with a product' do
264
- contact = @zoho.add_record('Contacts', @h_smith)
265
- product = @zoho.add_record('Products', {product_name: 'Watches'})
323
+ VCR.use_cassette 'api_response/relate_contact_with_product' do
324
+ contact = @zoho.add_record('Contacts', @h_smith)
325
+ product = @zoho.add_record('Products', {product_name: 'Watches'})
266
326
 
267
- related_module_params = {related_module: 'Contacts', xml_data: {contactid: contact[:id]}}
268
- r = @zoho.update_related_records('Products', product[:id], related_module_params)
269
- r.should eq('4800')
327
+ related_module_params = {related_module: 'Contacts', xml_data: {contactid: contact[:id]}}
328
+ r = @zoho.update_related_records('Products', product[:id], related_module_params)
329
+ r.should eq('4800')
270
330
 
271
- r = @zoho.related_records('Products', product[:id], 'Contacts')
272
- r.should eq(200)
331
+ r = @zoho.related_records('Products', product[:id], 'Contacts')
332
+ r.should eq(200)
273
333
 
274
- @zoho.delete_record('Contacts', contact[:id])
275
- @zoho.delete_record('Products', product[:id])
334
+ @zoho.delete_record('Contacts', contact[:id])
335
+ @zoho.delete_record('Products', product[:id])
336
+ end
276
337
  end
277
338
 
278
-
279
-
280
339
  end