restforce-db 0.2.3 → 0.3.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.
- checksums.yaml +4 -4
- data/README.md +39 -8
- data/lib/restforce/db/instances/active_record.rb +0 -9
- data/lib/restforce/db/instances/base.rb +7 -5
- data/lib/restforce/db/instances/salesforce.rb +0 -9
- data/lib/restforce/db/mapping.rb +91 -31
- data/lib/restforce/db/model.rb +5 -20
- data/lib/restforce/db/record_types/active_record.rb +38 -5
- data/lib/restforce/db/record_types/base.rb +2 -2
- data/lib/restforce/db/record_types/salesforce.rb +3 -3
- data/lib/restforce/db/version.rb +1 -1
- data/lib/restforce/db/worker.rb +7 -10
- data/lib/restforce/db.rb +0 -1
- data/test/cassettes/Restforce_DB/accessing_Salesforce/uses_the_configured_credentials.yml +5 -5
- data/test/cassettes/Restforce_DB_Instances_Salesforce/_copy_/updates_the_record_with_the_attributes_from_the_copied_object.yml +36 -35
- data/test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_local_record_with_the_passed_attributes.yml +34 -33
- data/test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_record_in_Salesforce_with_the_passed_attributes.yml +45 -44
- data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/creates_a_record_in_Salesforce_from_the_passed_database_record_s_attributes.yml +28 -28
- data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/updates_the_database_record_with_the_Salesforce_record_s_ID.yml +28 -28
- data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/finds_existing_records_in_Salesforce.yml +29 -28
- data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/returns_nil_when_no_matching_record_exists.yml +12 -12
- data/test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/when_synchronization_is_stale/updates_the_database_record.yml +36 -36
- data/test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/when_synchronization_is_up-to-date/does_not_update_the_database_record.yml +28 -104
- data/test/cassettes/Restforce_DB_Synchronizer/_run/given_an_existing_Salesforce_record/{populates_the_database_with_the_new_record.yml → for_a_non-root_mapping/does_not_create_a_database_record.yml} +28 -28
- data/test/cassettes/Restforce_DB_Synchronizer/_run/given_an_existing_Salesforce_record/for_a_root_mapping/creates_a_matching_database_record.yml +158 -0
- data/test/cassettes/Restforce_DB_Synchronizer/_run/given_an_existing_database_record/populates_Salesforce_with_the_new_record.yml +44 -44
- data/test/lib/restforce/db/instances/active_record_test.rb +4 -2
- data/test/lib/restforce/db/instances/salesforce_test.rb +5 -6
- data/test/lib/restforce/db/mapping_test.rb +40 -15
- data/test/lib/restforce/db/model_test.rb +6 -23
- data/test/lib/restforce/db/record_types/active_record_test.rb +45 -17
- data/test/lib/restforce/db/record_types/salesforce_test.rb +6 -7
- data/test/lib/restforce/db/synchronizer_test.rb +31 -17
- data/test/support/active_record.rb +20 -1
- data/test/support/utilities.rb +29 -0
- data/test/test_helper.rb +0 -12
- metadata +4 -4
- data/lib/restforce/db/record_type.rb +0 -77
- data/test/lib/restforce/db/record_type_test.rb +0 -26
@@ -0,0 +1,158 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://<host>/services/oauth2/token
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: grant_type=password&client_id=<client_id>&client_secret=<client_secret>&username=<username>&password=<password><security_token>
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Content-Type:
|
13
|
+
- application/x-www-form-urlencoded
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Thu, 26 Mar 2015 10:38:52 GMT
|
25
|
+
Set-Cookie:
|
26
|
+
- BrowserId=37YKB17FQXeugJwOsd0zkw;Path=/;Domain=.salesforce.com;Expires=Mon,
|
27
|
+
25-May-2015 10:38:52 GMT
|
28
|
+
Expires:
|
29
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
30
|
+
Pragma:
|
31
|
+
- no-cache
|
32
|
+
Cache-Control:
|
33
|
+
- no-cache, no-store
|
34
|
+
Content-Type:
|
35
|
+
- application/json;charset=UTF-8
|
36
|
+
Transfer-Encoding:
|
37
|
+
- chunked
|
38
|
+
body:
|
39
|
+
encoding: ASCII-8BIT
|
40
|
+
string: '{"id":"https://login.salesforce.com/id/00D1a000000H3O9EAK/0051a000000UGT8AAO","issued_at":"1427366333069","token_type":"Bearer","instance_url":"https://<host>","signature":"fLjdti3hVSnGVmDfe2q7IuyM0ezADibgQZn8IJjabQ0=","access_token":"00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ"}'
|
41
|
+
http_version:
|
42
|
+
recorded_at: Thu, 26 Mar 2015 10:38:53 GMT
|
43
|
+
- request:
|
44
|
+
method: post
|
45
|
+
uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c
|
46
|
+
body:
|
47
|
+
encoding: UTF-8
|
48
|
+
string: '{"Name":"Custom object","Example_Field__c":"Some sample text"}'
|
49
|
+
headers:
|
50
|
+
User-Agent:
|
51
|
+
- Faraday v0.9.1
|
52
|
+
Content-Type:
|
53
|
+
- application/json
|
54
|
+
Authorization:
|
55
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
56
|
+
Accept-Encoding:
|
57
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
58
|
+
Accept:
|
59
|
+
- "*/*"
|
60
|
+
response:
|
61
|
+
status:
|
62
|
+
code: 201
|
63
|
+
message: Created
|
64
|
+
headers:
|
65
|
+
Date:
|
66
|
+
- Thu, 26 Mar 2015 10:38:53 GMT
|
67
|
+
Set-Cookie:
|
68
|
+
- BrowserId=MBCeRTzjSuudckQJYgK3TA;Path=/;Domain=.salesforce.com;Expires=Mon,
|
69
|
+
25-May-2015 10:38:53 GMT
|
70
|
+
Expires:
|
71
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
72
|
+
Sforce-Limit-Info:
|
73
|
+
- api-usage=55/15000
|
74
|
+
Location:
|
75
|
+
- "/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1BUAA0"
|
76
|
+
Content-Type:
|
77
|
+
- application/json;charset=UTF-8
|
78
|
+
Transfer-Encoding:
|
79
|
+
- chunked
|
80
|
+
body:
|
81
|
+
encoding: ASCII-8BIT
|
82
|
+
string: '{"id":"a001a000001J1BUAA0","success":true,"errors":[]}'
|
83
|
+
http_version:
|
84
|
+
recorded_at: Thu, 26 Mar 2015 10:38:54 GMT
|
85
|
+
- request:
|
86
|
+
method: get
|
87
|
+
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20SystemModstamp%20%3C=%202015-03-26T10:38:54Z
|
88
|
+
body:
|
89
|
+
encoding: US-ASCII
|
90
|
+
string: ''
|
91
|
+
headers:
|
92
|
+
User-Agent:
|
93
|
+
- Faraday v0.9.1
|
94
|
+
Authorization:
|
95
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
96
|
+
Accept-Encoding:
|
97
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
98
|
+
Accept:
|
99
|
+
- "*/*"
|
100
|
+
response:
|
101
|
+
status:
|
102
|
+
code: 200
|
103
|
+
message: OK
|
104
|
+
headers:
|
105
|
+
Date:
|
106
|
+
- Thu, 26 Mar 2015 10:38:55 GMT
|
107
|
+
Set-Cookie:
|
108
|
+
- BrowserId=rtKeh9fcSRKtYNUePpgWfw;Path=/;Domain=.salesforce.com;Expires=Mon,
|
109
|
+
25-May-2015 10:38:55 GMT
|
110
|
+
Expires:
|
111
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
112
|
+
Sforce-Limit-Info:
|
113
|
+
- api-usage=55/15000
|
114
|
+
Content-Type:
|
115
|
+
- application/json;charset=UTF-8
|
116
|
+
Transfer-Encoding:
|
117
|
+
- chunked
|
118
|
+
body:
|
119
|
+
encoding: ASCII-8BIT
|
120
|
+
string: '{"totalSize":3,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001IjCFAA0"},"Id":"a001a000001IjCFAA0","SystemModstamp":"2015-03-24T08:25:04.000+0000","Name":"andrew@tablexi.com","Example_Field__c":null},{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001IjP2AAK"},"Id":"a001a000001IjP2AAK","SystemModstamp":"2015-03-24T08:27:33.000+0000","Name":"somebody+new@example.com","Example_Field__c":null},{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1BUAA0"},"Id":"a001a000001J1BUAA0","SystemModstamp":"2015-03-26T10:38:54.000+0000","Name":"Custom
|
121
|
+
object","Example_Field__c":"Some sample text"}]}'
|
122
|
+
http_version:
|
123
|
+
recorded_at: Thu, 26 Mar 2015 10:38:55 GMT
|
124
|
+
- request:
|
125
|
+
method: delete
|
126
|
+
uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1BUAA0
|
127
|
+
body:
|
128
|
+
encoding: US-ASCII
|
129
|
+
string: ''
|
130
|
+
headers:
|
131
|
+
User-Agent:
|
132
|
+
- Faraday v0.9.1
|
133
|
+
Authorization:
|
134
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
135
|
+
Accept-Encoding:
|
136
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
137
|
+
Accept:
|
138
|
+
- "*/*"
|
139
|
+
response:
|
140
|
+
status:
|
141
|
+
code: 204
|
142
|
+
message: No Content
|
143
|
+
headers:
|
144
|
+
Date:
|
145
|
+
- Thu, 26 Mar 2015 10:38:57 GMT
|
146
|
+
Set-Cookie:
|
147
|
+
- BrowserId=PGwh31HXTN2JpmU15oP_dw;Path=/;Domain=.salesforce.com;Expires=Mon,
|
148
|
+
25-May-2015 10:38:57 GMT
|
149
|
+
Expires:
|
150
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
151
|
+
Sforce-Limit-Info:
|
152
|
+
- api-usage=55/15000
|
153
|
+
body:
|
154
|
+
encoding: UTF-8
|
155
|
+
string: ''
|
156
|
+
http_version:
|
157
|
+
recorded_at: Thu, 26 Mar 2015 10:39:00 GMT
|
158
|
+
recorded_with: VCR 2.9.3
|
@@ -21,10 +21,10 @@ http_interactions:
|
|
21
21
|
message: OK
|
22
22
|
headers:
|
23
23
|
Date:
|
24
|
-
-
|
24
|
+
- Thu, 26 Mar 2015 10:19:56 GMT
|
25
25
|
Set-Cookie:
|
26
|
-
- BrowserId=
|
27
|
-
|
26
|
+
- BrowserId=GtWaDvybSpm7AZ4mmgjX3w;Path=/;Domain=.salesforce.com;Expires=Mon,
|
27
|
+
25-May-2015 10:19:56 GMT
|
28
28
|
Expires:
|
29
29
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
30
30
|
Pragma:
|
@@ -37,12 +37,12 @@ http_interactions:
|
|
37
37
|
- chunked
|
38
38
|
body:
|
39
39
|
encoding: ASCII-8BIT
|
40
|
-
string: '{"id":"https://login.salesforce.com/id/00D1a000000H3O9EAK/0051a000000UGT8AAO","issued_at":"
|
40
|
+
string: '{"id":"https://login.salesforce.com/id/00D1a000000H3O9EAK/0051a000000UGT8AAO","issued_at":"1427365196735","token_type":"Bearer","instance_url":"https://<host>","signature":"H8KRil5gcExkALOqiCgIxlW6JyUVX98qsaaBeHlgwX8=","access_token":"00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ"}'
|
41
41
|
http_version:
|
42
|
-
recorded_at:
|
42
|
+
recorded_at: Thu, 26 Mar 2015 10:19:56 GMT
|
43
43
|
- request:
|
44
44
|
method: get
|
45
|
-
uri: https://<host>/services/data/v26.0/query?q=
|
45
|
+
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20SystemModstamp%20%3C=%202015-03-26T10:19:55Z
|
46
46
|
body:
|
47
47
|
encoding: US-ASCII
|
48
48
|
string: ''
|
@@ -50,7 +50,7 @@ http_interactions:
|
|
50
50
|
User-Agent:
|
51
51
|
- Faraday v0.9.1
|
52
52
|
Authorization:
|
53
|
-
- OAuth 00D1a000000H3O9!
|
53
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
54
54
|
Accept-Encoding:
|
55
55
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
56
56
|
Accept:
|
@@ -61,23 +61,23 @@ http_interactions:
|
|
61
61
|
message: OK
|
62
62
|
headers:
|
63
63
|
Date:
|
64
|
-
-
|
64
|
+
- Thu, 26 Mar 2015 10:19:57 GMT
|
65
65
|
Set-Cookie:
|
66
|
-
- BrowserId=
|
67
|
-
|
66
|
+
- BrowserId=2JsFmWKWSkitzAzTtym_3A;Path=/;Domain=.salesforce.com;Expires=Mon,
|
67
|
+
25-May-2015 10:19:57 GMT
|
68
68
|
Expires:
|
69
69
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
70
70
|
Sforce-Limit-Info:
|
71
|
-
- api-usage=
|
71
|
+
- api-usage=1/15000
|
72
72
|
Content-Type:
|
73
73
|
- application/json;charset=UTF-8
|
74
74
|
Transfer-Encoding:
|
75
75
|
- chunked
|
76
76
|
body:
|
77
77
|
encoding: ASCII-8BIT
|
78
|
-
string: '{"totalSize":
|
78
|
+
string: '{"totalSize":2,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001IjCFAA0"},"Id":"a001a000001IjCFAA0","SystemModstamp":"2015-03-24T08:25:04.000+0000","Name":"andrew@tablexi.com","Example_Field__c":null},{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001IjP2AAK"},"Id":"a001a000001IjP2AAK","SystemModstamp":"2015-03-24T08:27:33.000+0000","Name":"somebody+new@example.com","Example_Field__c":null}]}'
|
79
79
|
http_version:
|
80
|
-
recorded_at:
|
80
|
+
recorded_at: Thu, 26 Mar 2015 10:19:57 GMT
|
81
81
|
- request:
|
82
82
|
method: post
|
83
83
|
uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c
|
@@ -90,7 +90,7 @@ http_interactions:
|
|
90
90
|
Content-Type:
|
91
91
|
- application/json
|
92
92
|
Authorization:
|
93
|
-
- OAuth 00D1a000000H3O9!
|
93
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
94
94
|
Accept-Encoding:
|
95
95
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
96
96
|
Accept:
|
@@ -101,28 +101,28 @@ http_interactions:
|
|
101
101
|
message: Created
|
102
102
|
headers:
|
103
103
|
Date:
|
104
|
-
-
|
104
|
+
- Thu, 26 Mar 2015 10:19:59 GMT
|
105
105
|
Set-Cookie:
|
106
|
-
- BrowserId=
|
107
|
-
|
106
|
+
- BrowserId=XhJr7VJzQnK9uk9PB7-MzQ;Path=/;Domain=.salesforce.com;Expires=Mon,
|
107
|
+
25-May-2015 10:19:59 GMT
|
108
108
|
Expires:
|
109
109
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
110
110
|
Sforce-Limit-Info:
|
111
|
-
- api-usage=
|
111
|
+
- api-usage=1/15000
|
112
112
|
Location:
|
113
|
-
- "/services/data/v26.0/sobjects/CustomObject__c/
|
113
|
+
- "/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1ARAA0"
|
114
114
|
Content-Type:
|
115
115
|
- application/json;charset=UTF-8
|
116
116
|
Transfer-Encoding:
|
117
117
|
- chunked
|
118
118
|
body:
|
119
119
|
encoding: ASCII-8BIT
|
120
|
-
string: '{"id":"
|
120
|
+
string: '{"id":"a001a000001J1ARAA0","success":true,"errors":[]}'
|
121
121
|
http_version:
|
122
|
-
recorded_at:
|
122
|
+
recorded_at: Thu, 26 Mar 2015 10:19:59 GMT
|
123
123
|
- request:
|
124
124
|
method: get
|
125
|
-
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%
|
125
|
+
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001J1ARAA0%27
|
126
126
|
body:
|
127
127
|
encoding: US-ASCII
|
128
128
|
string: ''
|
@@ -130,7 +130,7 @@ http_interactions:
|
|
130
130
|
User-Agent:
|
131
131
|
- Faraday v0.9.1
|
132
132
|
Authorization:
|
133
|
-
- OAuth 00D1a000000H3O9!
|
133
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
134
134
|
Accept-Encoding:
|
135
135
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
136
136
|
Accept:
|
@@ -141,27 +141,27 @@ http_interactions:
|
|
141
141
|
message: OK
|
142
142
|
headers:
|
143
143
|
Date:
|
144
|
-
-
|
144
|
+
- Thu, 26 Mar 2015 10:20:00 GMT
|
145
145
|
Set-Cookie:
|
146
|
-
- BrowserId=
|
147
|
-
|
146
|
+
- BrowserId=fQiEFut9S62onQpI8mKGwg;Path=/;Domain=.salesforce.com;Expires=Mon,
|
147
|
+
25-May-2015 10:20:00 GMT
|
148
148
|
Expires:
|
149
149
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
150
150
|
Sforce-Limit-Info:
|
151
|
-
- api-usage=
|
151
|
+
- api-usage=2/15000
|
152
152
|
Content-Type:
|
153
153
|
- application/json;charset=UTF-8
|
154
154
|
Transfer-Encoding:
|
155
155
|
- chunked
|
156
156
|
body:
|
157
157
|
encoding: ASCII-8BIT
|
158
|
-
string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/
|
158
|
+
string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1ARAA0"},"Id":"a001a000001J1ARAA0","SystemModstamp":"2015-03-26T10:19:59.000+0000","Name":"Custom
|
159
159
|
object","Example_Field__c":"Some sample text"}]}'
|
160
160
|
http_version:
|
161
|
-
recorded_at:
|
161
|
+
recorded_at: Thu, 26 Mar 2015 10:20:00 GMT
|
162
162
|
- request:
|
163
163
|
method: get
|
164
|
-
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%
|
164
|
+
uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001J1ARAA0%27
|
165
165
|
body:
|
166
166
|
encoding: US-ASCII
|
167
167
|
string: ''
|
@@ -169,7 +169,7 @@ http_interactions:
|
|
169
169
|
User-Agent:
|
170
170
|
- Faraday v0.9.1
|
171
171
|
Authorization:
|
172
|
-
- OAuth 00D1a000000H3O9!
|
172
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
173
173
|
Accept-Encoding:
|
174
174
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
175
175
|
Accept:
|
@@ -180,27 +180,27 @@ http_interactions:
|
|
180
180
|
message: OK
|
181
181
|
headers:
|
182
182
|
Date:
|
183
|
-
-
|
183
|
+
- Thu, 26 Mar 2015 10:20:03 GMT
|
184
184
|
Set-Cookie:
|
185
|
-
- BrowserId=
|
186
|
-
|
185
|
+
- BrowserId=wLQ9lXJrS6aAKHllhiTIlQ;Path=/;Domain=.salesforce.com;Expires=Mon,
|
186
|
+
25-May-2015 10:20:03 GMT
|
187
187
|
Expires:
|
188
188
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
189
189
|
Sforce-Limit-Info:
|
190
|
-
- api-usage=
|
190
|
+
- api-usage=1/15000
|
191
191
|
Content-Type:
|
192
192
|
- application/json;charset=UTF-8
|
193
193
|
Transfer-Encoding:
|
194
194
|
- chunked
|
195
195
|
body:
|
196
196
|
encoding: ASCII-8BIT
|
197
|
-
string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/
|
197
|
+
string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1ARAA0"},"Id":"a001a000001J1ARAA0","SystemModstamp":"2015-03-26T10:19:59.000+0000","Name":"Custom
|
198
198
|
object","Example_Field__c":"Some sample text"}]}'
|
199
199
|
http_version:
|
200
|
-
recorded_at:
|
200
|
+
recorded_at: Thu, 26 Mar 2015 10:20:03 GMT
|
201
201
|
- request:
|
202
202
|
method: delete
|
203
|
-
uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/
|
203
|
+
uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001J1ARAA0
|
204
204
|
body:
|
205
205
|
encoding: US-ASCII
|
206
206
|
string: ''
|
@@ -208,7 +208,7 @@ http_interactions:
|
|
208
208
|
User-Agent:
|
209
209
|
- Faraday v0.9.1
|
210
210
|
Authorization:
|
211
|
-
- OAuth 00D1a000000H3O9!
|
211
|
+
- OAuth 00D1a000000H3O9!AQ4AQFqDs34WtnS6RDwxyGdLSPYE_cFTuNjjnDvX2HbNhGMu917m6JyqchGFbdiOruyd5Z.w7uN.ogsJF4_8TMMzdt2fw7OZ
|
212
212
|
Accept-Encoding:
|
213
213
|
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
214
214
|
Accept:
|
@@ -219,17 +219,17 @@ http_interactions:
|
|
219
219
|
message: No Content
|
220
220
|
headers:
|
221
221
|
Date:
|
222
|
-
-
|
222
|
+
- Thu, 26 Mar 2015 10:20:04 GMT
|
223
223
|
Set-Cookie:
|
224
|
-
- BrowserId=
|
225
|
-
|
224
|
+
- BrowserId=tuNUJCy2TB2npsWBWd7Sjw;Path=/;Domain=.salesforce.com;Expires=Mon,
|
225
|
+
25-May-2015 10:20:04 GMT
|
226
226
|
Expires:
|
227
227
|
- Thu, 01 Jan 1970 00:00:00 GMT
|
228
228
|
Sforce-Limit-Info:
|
229
|
-
- api-usage=
|
229
|
+
- api-usage=2/15000
|
230
230
|
body:
|
231
231
|
encoding: UTF-8
|
232
232
|
string: ''
|
233
233
|
http_version:
|
234
|
-
recorded_at:
|
234
|
+
recorded_at: Thu, 26 Mar 2015 10:20:04 GMT
|
235
235
|
recorded_with: VCR 2.9.3
|
@@ -3,10 +3,12 @@ require_relative "../../../../test_helper"
|
|
3
3
|
describe Restforce::DB::Instances::ActiveRecord do
|
4
4
|
|
5
5
|
configure!
|
6
|
+
mappings!
|
6
7
|
|
7
8
|
let(:record) { CustomObject.create! }
|
8
|
-
let(:
|
9
|
-
|
9
|
+
let(:instance) do
|
10
|
+
Restforce::DB::Instances::ActiveRecord.new(database_model, record, mapping)
|
11
|
+
end
|
10
12
|
|
11
13
|
describe "#update!" do
|
12
14
|
let(:text) { "Some new text" }
|
@@ -3,11 +3,10 @@ require_relative "../../../../test_helper"
|
|
3
3
|
describe Restforce::DB::Instances::Salesforce do
|
4
4
|
|
5
5
|
configure!
|
6
|
+
mappings!
|
6
7
|
|
7
|
-
let(:
|
8
|
-
let(:
|
9
|
-
let(:id) { Salesforce.create!("CustomObject__c") }
|
10
|
-
let(:instance) { record_type.find(id) }
|
8
|
+
let(:id) { Salesforce.create!(salesforce_model) }
|
9
|
+
let(:instance) { mapping.salesforce_record_type.find(id) }
|
11
10
|
|
12
11
|
describe "#update!", :vcr do
|
13
12
|
let(:text) { "Some new text" }
|
@@ -21,7 +20,7 @@ describe Restforce::DB::Instances::Salesforce do
|
|
21
20
|
end
|
22
21
|
|
23
22
|
it "updates the record in Salesforce with the passed attributes" do
|
24
|
-
expect(
|
23
|
+
expect(mapping.salesforce_record_type.find(id).record.Example_Field__c).to_equal text
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
@@ -41,7 +40,7 @@ describe Restforce::DB::Instances::Salesforce do
|
|
41
40
|
describe "#last_update" do
|
42
41
|
let(:timestamp) { "2015-03-18T20:28:24.000+0000" }
|
43
42
|
let(:record) { Struct.new(:SystemModstamp).new(timestamp) }
|
44
|
-
let(:instance) { Restforce::DB::Instances::Salesforce.new(record) }
|
43
|
+
let(:instance) { Restforce::DB::Instances::Salesforce.new(salesforce_model, record) }
|
45
44
|
|
46
45
|
it "parses a time from the record's system modification timestamp" do
|
47
46
|
expect(instance.last_update).to_equal(Time.new(2015, 3, 18, 20, 28, 24, 0))
|
@@ -4,37 +4,62 @@ describe Restforce::DB::Mapping do
|
|
4
4
|
|
5
5
|
configure!
|
6
6
|
|
7
|
-
let(:
|
8
|
-
let(:
|
7
|
+
let(:database_model) { CustomObject }
|
8
|
+
let(:salesforce_model) { "CustomObject__c" }
|
9
|
+
let(:associations) { {} }
|
10
|
+
let(:fields) do
|
9
11
|
{
|
10
12
|
column_one: "SF_Field_One__c",
|
11
13
|
column_two: "SF_Field_Two__c",
|
12
14
|
}
|
13
15
|
end
|
16
|
+
let!(:mapping) do
|
17
|
+
Restforce::DB::Mapping.new(
|
18
|
+
database_model,
|
19
|
+
salesforce_model,
|
20
|
+
fields: fields,
|
21
|
+
associations: associations,
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ".each" do
|
26
|
+
|
27
|
+
# Restforce::DB::Mapping actually implements Enumerable, so we're just
|
28
|
+
# going with a trivially testable portion of the Enumerable API.
|
29
|
+
it "yields the registered record types" do
|
30
|
+
expect(Restforce::DB::Mapping.first).to_equal [database_model.name, mapping]
|
31
|
+
end
|
32
|
+
end
|
14
33
|
|
15
34
|
describe "#initialize" do
|
16
35
|
|
17
|
-
it "
|
18
|
-
expect(
|
36
|
+
it "adds the mapping to the global collection" do
|
37
|
+
expect(Restforce::DB::Mapping[database_model]).to_equal mapping
|
19
38
|
end
|
20
39
|
end
|
21
40
|
|
22
|
-
describe "#
|
23
|
-
let(:new_mappings) { { a: "few", more: "mappings" } }
|
41
|
+
describe "#salesforce_fields" do
|
24
42
|
|
25
|
-
|
26
|
-
|
43
|
+
describe "given no mapped associations" do
|
44
|
+
|
45
|
+
it "lists the fields in the attribute map" do
|
46
|
+
expect(mapping.salesforce_fields).to_equal(fields.values)
|
47
|
+
end
|
27
48
|
end
|
28
49
|
|
29
|
-
|
30
|
-
|
50
|
+
describe "given a set of associations" do
|
51
|
+
let(:associations) { { user: "Owner" } }
|
52
|
+
|
53
|
+
it "lists the field and association lookups" do
|
54
|
+
expect(mapping.salesforce_fields).to_equal(fields.values + associations.values)
|
55
|
+
end
|
31
56
|
end
|
32
57
|
end
|
33
58
|
|
34
59
|
describe "#attributes" do
|
35
60
|
|
36
61
|
it "builds a normalized Hash of database attribute values" do
|
37
|
-
attributes = mapping.attributes(
|
62
|
+
attributes = mapping.attributes(database_model) do |attribute|
|
38
63
|
expect(mapping.database_fields.include?(attribute)).to_equal true
|
39
64
|
attribute
|
40
65
|
end
|
@@ -44,7 +69,7 @@ describe Restforce::DB::Mapping do
|
|
44
69
|
end
|
45
70
|
|
46
71
|
it "builds a normalized Hash of Salesforce field values" do
|
47
|
-
attributes = mapping.attributes(
|
72
|
+
attributes = mapping.attributes(salesforce_model) do |attribute|
|
48
73
|
expect(mapping.salesforce_fields.include?(attribute)).to_equal true
|
49
74
|
attribute
|
50
75
|
end
|
@@ -58,13 +83,13 @@ describe Restforce::DB::Mapping do
|
|
58
83
|
let(:attributes) { { column_one: "some value" } }
|
59
84
|
|
60
85
|
it "converts an attribute Hash to a Salesforce-compatible form" do
|
61
|
-
expect(mapping.convert(
|
62
|
-
|
86
|
+
expect(mapping.convert(salesforce_model, attributes)).to_equal(
|
87
|
+
fields[attributes.keys.first] => attributes.values.first,
|
63
88
|
)
|
64
89
|
end
|
65
90
|
|
66
91
|
it "performs no special conversion for database columns" do
|
67
|
-
expect(mapping.convert(
|
92
|
+
expect(mapping.convert(database_model, attributes)).to_equal(attributes)
|
68
93
|
end
|
69
94
|
end
|
70
95
|
end
|
@@ -6,7 +6,7 @@ describe Restforce::DB::Model do
|
|
6
6
|
|
7
7
|
let(:database_model) { CustomObject }
|
8
8
|
let(:salesforce_model) { "CustomObject__c" }
|
9
|
-
let(:
|
9
|
+
let(:fields) do
|
10
10
|
{
|
11
11
|
name: "Name",
|
12
12
|
example: "Example_Field__c",
|
@@ -17,31 +17,14 @@ describe Restforce::DB::Model do
|
|
17
17
|
database_model.send(:include, Restforce::DB::Model)
|
18
18
|
end
|
19
19
|
|
20
|
-
describe ".
|
20
|
+
describe ".sync_with" do
|
21
21
|
before do
|
22
|
-
database_model.
|
22
|
+
database_model.sync_with(salesforce_model, fields: fields)
|
23
23
|
end
|
24
24
|
|
25
|
-
it "creates a mapping in Restforce::DB::
|
26
|
-
expect(Restforce::DB::
|
27
|
-
.to_be_instance_of(Restforce::DB::
|
28
|
-
end
|
29
|
-
|
30
|
-
it "applies the passed attribute mappings to the registered RecordType" do
|
31
|
-
expect(Restforce::DB::RecordType[database_model].mapping.mappings)
|
32
|
-
.to_equal(mappings)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe ".add_mappings" do
|
37
|
-
before do
|
38
|
-
database_model.map_to(salesforce_model)
|
39
|
-
database_model.add_mappings(mappings)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "applies the passed attribute mappings to the registered RecordType" do
|
43
|
-
expect(Restforce::DB::RecordType[database_model].mapping.mappings)
|
44
|
-
.to_equal(mappings)
|
25
|
+
it "creates a mapping in Restforce::DB::Mapping" do
|
26
|
+
expect(Restforce::DB::Mapping[database_model])
|
27
|
+
.to_be_instance_of(Restforce::DB::Mapping)
|
45
28
|
end
|
46
29
|
end
|
47
30
|
|