sportgenic-activerecord-activesalesforce-adapter 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +51 -0
- data/lib/active_record/connection_adapters/activesalesforce.rb +36 -0
- data/lib/active_record/connection_adapters/activesalesforce_adapter.rb +823 -0
- data/lib/active_record/connection_adapters/asf_active_record.rb +40 -0
- data/lib/active_record/connection_adapters/boxcar_command.rb +66 -0
- data/lib/active_record/connection_adapters/column_definition.rb +95 -0
- data/lib/active_record/connection_adapters/entity_definition.rb +59 -0
- data/lib/active_record/connection_adapters/id_resolver.rb +84 -0
- data/lib/active_record/connection_adapters/recording_binding.rb +90 -0
- data/lib/active_record/connection_adapters/relationship_definition.rb +81 -0
- data/lib/active_record/connection_adapters/result_array.rb +31 -0
- data/lib/active_record/connection_adapters/sid_authentication_filter.rb +57 -0
- data/lib/rforce/binding.rb +202 -0
- data/lib/rforce/method_keys.rb +14 -0
- data/lib/rforce/soap_pullable.rb +90 -0
- data/lib/rforce/soap_response_expat.rb +35 -0
- data/lib/rforce/soap_response_hpricot.rb +70 -0
- data/lib/rforce/soap_response_rexml.rb +34 -0
- data/lib/rforce/version.rb +3 -0
- data/lib/rforce.rb +116 -0
- data/test/unit/basic_test.rb +203 -0
- data/test/unit/config.yml +5 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_add_notes_to_contact.recording +1966 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_assignment_rule_id.recording +1621 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_batch_insert.recording +1611 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_client_id.recording +1618 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_count_contacts.recording +1620 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_create_a_contact.recording +1611 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_find_a_contact.recording +1611 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_find_a_contact_by_first_name.recording +3468 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_find_a_contact_by_id.recording +1664 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_find_addresses.recording +1635 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_get_created_by_from_contact.recording +4307 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_master_detail.recording +1951 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_read_all_content_columns.recording +1611 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_save_a_contact.recording +1611 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_use_default_rule.recording +1618 -0
- data/test/unit/recorded_results/AsfUnitTestsBasicTest.test_use_update_mru.recording +1618 -0
- data/test/unit/recorded_test_case.rb +83 -0
- metadata +160 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
=begin
|
2
|
+
ActiveSalesforce
|
3
|
+
Copyright 2006 Doug Chasman
|
4
|
+
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
you may not use this file except in compliance with the License.
|
7
|
+
You may obtain a copy of the License at
|
8
|
+
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
See the License for the specific language governing permissions and
|
15
|
+
limitations under the License.
|
16
|
+
=end
|
17
|
+
|
18
|
+
require 'rubygems'
|
19
|
+
|
20
|
+
#require_gem 'activesalesforce'
|
21
|
+
require File.dirname(__FILE__) + '/../../lib/active_record/connection_adapters/activesalesforce_adapter'
|
22
|
+
|
23
|
+
require File.dirname(__FILE__) + '/recorded_test_case'
|
24
|
+
require 'pp'
|
25
|
+
|
26
|
+
|
27
|
+
class Contact < ActiveRecord::Base
|
28
|
+
end
|
29
|
+
|
30
|
+
class Department < ActiveRecord::Base
|
31
|
+
end
|
32
|
+
|
33
|
+
class Address < ActiveRecord::Base
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
module Asf
|
38
|
+
module UnitTests
|
39
|
+
|
40
|
+
class BasicTest < Test::Unit::TestCase
|
41
|
+
include RecordedTestCase
|
42
|
+
|
43
|
+
attr_reader :contact
|
44
|
+
|
45
|
+
def initialize(test_method_name)
|
46
|
+
super(test_method_name)
|
47
|
+
|
48
|
+
#force_recording :test_create_a_contact
|
49
|
+
end
|
50
|
+
|
51
|
+
def setup
|
52
|
+
puts "\nStarting test '#{self.class.name.gsub('::', '')}.#{method_name}'"
|
53
|
+
|
54
|
+
super
|
55
|
+
|
56
|
+
@contact = Contact.new
|
57
|
+
|
58
|
+
reset_header_options
|
59
|
+
|
60
|
+
contact.first_name = 'DutchTestFirstName'
|
61
|
+
contact.last_name = 'DutchTestLastName'
|
62
|
+
contact.home_phone = '555-555-1212'
|
63
|
+
contact.save
|
64
|
+
|
65
|
+
contact.reload
|
66
|
+
end
|
67
|
+
|
68
|
+
def teardown
|
69
|
+
reset_header_options
|
70
|
+
|
71
|
+
contact.destroy if contact
|
72
|
+
|
73
|
+
super
|
74
|
+
end
|
75
|
+
|
76
|
+
def reset_header_options
|
77
|
+
binding = Contact.connection.binding
|
78
|
+
binding.assignment_rule_id = nil
|
79
|
+
binding.use_default_rule = false
|
80
|
+
binding.update_mru = false
|
81
|
+
binding.trigger_user_email = false
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def test_create_a_contact
|
86
|
+
contact.id
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_count_contacts
|
90
|
+
assert Contact.count > 0
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_save_a_contact
|
94
|
+
contact.id
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_find_a_contact
|
98
|
+
c = Contact.find(contact.id)
|
99
|
+
assert_equal contact.id, c.id
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_find_a_contact_by_id
|
103
|
+
c = Contact.find_by_id(contact.id)
|
104
|
+
assert_equal contact.id, c.id
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_find_a_contact_by_first_name
|
108
|
+
c = Contact.find_by_first_name('DutchTestFirstName')
|
109
|
+
assert_equal contact.id, c.id
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_read_all_content_columns
|
113
|
+
Contact.content_columns.each { |column| contact.send(column.name) }
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_get_created_by_from_contact
|
117
|
+
user = contact.created_by
|
118
|
+
assert_equal contact.created_by_id, user.id
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_use_update_mru
|
122
|
+
Contact.connection.binding.update_mru = true
|
123
|
+
contact.save
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_use_default_rule
|
127
|
+
Contact.connection.binding.use_default_rule = true
|
128
|
+
contact.save
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_assignment_rule_id
|
132
|
+
Contact.connection.binding.assignment_rule_id = "1234567890"
|
133
|
+
contact.save
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_client_id
|
137
|
+
Contact.connection.binding.client_id = "testClient"
|
138
|
+
contact.save
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
def test_add_notes_to_contact
|
143
|
+
n1 = Note.new(:title => "My Title", :body => "My Body")
|
144
|
+
n2 = Note.new(:title => "My Title 2", :body => "My Body 2")
|
145
|
+
|
146
|
+
contact.notes << n1
|
147
|
+
contact.notes << n2
|
148
|
+
|
149
|
+
n1.save
|
150
|
+
n2.save
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_master_detail
|
154
|
+
department = Department.new(:department_description__c => 'DutchTestDepartment description')
|
155
|
+
department.save
|
156
|
+
department.reload
|
157
|
+
|
158
|
+
job = Job.new(:name => "DutchJob")
|
159
|
+
|
160
|
+
department.jobs__c << job
|
161
|
+
|
162
|
+
department.destroy
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
def test_batch_insert
|
167
|
+
c1 = Contact.new(:first_name => 'FN1', :last_name => 'LN1')
|
168
|
+
c2 = Contact.new(:first_name => 'FN2', :last_name => 'LN2')
|
169
|
+
c3 = Contact.new(:first_name => 'FN3', :last_name => 'LN3')
|
170
|
+
|
171
|
+
Contact.transaction(c1, c2) do
|
172
|
+
c1.save
|
173
|
+
c2.save
|
174
|
+
end
|
175
|
+
|
176
|
+
c3.save
|
177
|
+
|
178
|
+
c1.first_name << '_2'
|
179
|
+
c2.first_name << '_2'
|
180
|
+
c3.first_name << '_2'
|
181
|
+
|
182
|
+
Contact.transaction(c1, c2) do
|
183
|
+
c1.save
|
184
|
+
c2.save
|
185
|
+
end
|
186
|
+
|
187
|
+
Contact.transaction(c1, c2) do
|
188
|
+
c3.save
|
189
|
+
|
190
|
+
c3.destroy
|
191
|
+
c2.destroy
|
192
|
+
c1.destroy
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_find_addresses
|
197
|
+
adresses = Address.find(:all)
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
end
|