activesalesforce 0.0.8 → 0.0.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.
- data/README +3 -1
- data/lib/rforce.rb +16 -2
- data/test/unit/account_test.rb +3 -61
- metadata +1 -1
data/README
CHANGED
@@ -23,7 +23,9 @@
|
|
23
23
|
username: <salesforce user name goes here>
|
24
24
|
password: <salesforce password goes here>
|
25
25
|
|
26
|
-
5. proceed using standard Rails development techniques!
|
26
|
+
5. proceed using standard Rails development techniques!
|
27
|
+
|
28
|
+
NOTE: To use a custom object append the word Custom to the name of the object instead of __c, e.g. FlipflapOnTheDuckmill would be FlipflapOnTheDuckmillCustom
|
27
29
|
|
28
30
|
== Description of contents
|
29
31
|
|
data/lib/rforce.rb
CHANGED
@@ -164,8 +164,11 @@ module RForce
|
|
164
164
|
|
165
165
|
#Log in to the server and remember the session ID
|
166
166
|
#returned to us by SalesForce.
|
167
|
-
def login(user,
|
168
|
-
|
167
|
+
def login(user, password)
|
168
|
+
@user = user
|
169
|
+
@password = password
|
170
|
+
|
171
|
+
response = call_remote(:login, [:username, user, :password, password])
|
169
172
|
|
170
173
|
raise "Incorrect user name / password [#{response.fault}]" unless response.loginResponse
|
171
174
|
|
@@ -195,6 +198,17 @@ module RForce
|
|
195
198
|
|
196
199
|
#Send the request to the server and read the response.
|
197
200
|
response = @server.post2(@url.path, request, {'SOAPAction' => method.to_s, 'content-type' => 'text/xml'})
|
201
|
+
|
202
|
+
# Check to see if INVALID_SESSION_ID was raised and try to relogin in
|
203
|
+
if method != :login and @session_id and response =~ /<faultcode>sf\:INVALID_SESSION_ID<\/faultcode>/
|
204
|
+
puts "\n\nSession timeout error - auto relogin activated"
|
205
|
+
|
206
|
+
login(@user, @password)
|
207
|
+
|
208
|
+
#Send the request to the server and read the response.
|
209
|
+
response = @server.post2(@url.path, request, {'SOAPAction' => method.to_s, 'content-type' => 'text/xml'})
|
210
|
+
end
|
211
|
+
|
198
212
|
SoapResponse.new(response.body)
|
199
213
|
end
|
200
214
|
|
data/test/unit/account_test.rb
CHANGED
@@ -3,68 +3,10 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|
3
3
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
|
-
class
|
7
|
-
def setup
|
8
|
-
ActiveRecord::Base.allow_concurrency = true
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
def test_get_account
|
13
|
-
accounts = Account.find(:all)
|
14
|
-
|
15
|
-
#accounts.each { |account| puts "#{account.Name}, #{account.Id}, #{account.LastModifiedById}" }
|
16
|
-
|
17
|
-
acme = Account.find(:first, :conditions => ["Name = 'Acme'"])
|
18
|
-
|
19
|
-
acme = Account.find_by_Id(acme.Id)
|
20
|
-
|
21
|
-
acme = Account.find_by_Name_and_LastModifiedById('salesforce.com', acme.LastModifiedById)
|
22
|
-
end
|
23
|
-
|
24
|
-
|
6
|
+
class ContactSControl
|
25
7
|
def test_update_account
|
26
|
-
|
27
|
-
acme.Name = "Acme"
|
28
|
-
acme.save
|
29
|
-
|
30
|
-
acme = Account.find_by_Name('Acme')
|
31
|
-
|
32
|
-
acme.Website = "http://www.dutchforce.com/#{Time.now}.jpg"
|
33
|
-
acme.LastModifiedDate = Time.now
|
34
|
-
|
35
|
-
acme.save
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def test_create_account
|
40
|
-
dutchCo = Account.new
|
41
|
-
dutchCo.Name = "DutchCo"
|
42
|
-
dutchCo.Website = "www.dutchco.com"
|
43
|
-
dutchCo.save
|
44
|
-
|
45
|
-
dutchCo2 = Account.new(:Name => "DutchCo2", :Website => "www.dutchco2.com")
|
46
|
-
dutchCo2.save
|
47
|
-
|
48
|
-
dutchCo3 = Account.create(:Name => "DutchCo3", :Website => "www.dutchco3.com")
|
49
|
-
|
50
|
-
accounts = Account.create([
|
51
|
-
{ :Name => "DutchCo4", :Website => "www.dutchco4.com" },
|
52
|
-
{ :Name => "DutchCo5", :Website => "www.dutchco5.com" }])
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
def test_destroy_account
|
57
|
-
account = Account.create(:Name => "DutchADelete", :Website => "www.dutchcodelete.com")
|
58
|
-
account = Account.find_by_Id(account.Id)
|
59
|
-
|
60
|
-
pp account.Parent
|
8
|
+
account = Account.find_by_Name('Acme')
|
61
9
|
|
62
|
-
|
63
|
-
createdBy = account.CreatedBy
|
64
|
-
createdBy = User.find_by_Id(account.CreatedById);
|
65
|
-
puts createdBy.Email
|
66
|
-
|
67
|
-
Account.delete(account.Id)
|
10
|
+
pp account
|
68
11
|
end
|
69
|
-
|
70
12
|
end
|
metadata
CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: activesalesforce
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
6
|
+
version: 0.0.9
|
7
7
|
date: 2006-01-26 00:00:00 -05:00
|
8
8
|
summary: ActiveSalesforce is an extension to the Rails Framework that allows for the dynamic creation and management of ActiveRecord objects through the use of Salesforce meta-data and uses a Salesforce.com organization as the backing store.
|
9
9
|
require_paths:
|