restforce-db 1.2.1 → 1.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0949316bfb922720bc820e65d71b71dcaf830c47
4
- data.tar.gz: 270a8d50a820d805316b0f3a54bf5386f3fbfdc9
3
+ metadata.gz: b45cedf169f50d5e0dc1ea13ba579e9d02ad440b
4
+ data.tar.gz: 8f4805e1d4d1addae8c5e710432e21ef5d5f8e32
5
5
  SHA512:
6
- metadata.gz: fc8d66f4c534f6b683e074c35c0f74ad88eb2ed085866c7f28c46ea2ff2ec06dcf641e2cb459bc364ebaa188d7d7bbf3860d648df939d6b30a1174f9ba342761
7
- data.tar.gz: e12dab58a707f332f69bcf63f2fdfa5752128566567ac73eeaaa1fb1ffd335c1b87820669e4539e9b7257269c551ce9682f6ad40f134b484a5a8c047141df341
6
+ metadata.gz: 97cd3dd1aef23fc71f967acbdce6bd1cd96b75fd20f89051e85df9f6a97377c45b3736c0d38255e6ba7db78ebeb14677789480f5d13f315d3d67238872f86683
7
+ data.tar.gz: a410e144635242065e91e9862cf192393427b4944064591e773b5995ab5914bae116285e7b1198930f194bd42f41ef4b0e1fcb0817b6663aa6e8261a7a72f1d1
@@ -25,6 +25,11 @@ module Restforce
25
25
  lookups[mapping.lookup_column] = lookup_id
26
26
 
27
27
  instance = mapping.salesforce_record_type.find(lookup_id)
28
+
29
+ # If any of the mappings are invalid, short-circuit the creation of
30
+ # the associated record.
31
+ return [] unless instance
32
+
28
33
  instances << instance
29
34
 
30
35
  hash.merge(mapping.convert(mapping.database_model, instance.attributes))
@@ -21,7 +21,7 @@ module Restforce
21
21
  query = "#{lookup_field(target, database_record)} = '#{salesforce_record.Id}'"
22
22
 
23
23
  instance = target.salesforce_record_type.first(query)
24
- construct_for(database_record, instance)
24
+ instance ? construct_for(database_record, instance) : []
25
25
  end
26
26
 
27
27
  end
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "1.2.1"
6
+ VERSION = "1.2.2"
7
7
 
8
8
  end
9
9
 
@@ -0,0 +1,195 @@
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
+ - Mon, 20 Apr 2015 19:25:30 GMT
25
+ Set-Cookie:
26
+ - BrowserId=CXWuPSH8QvCYOFUGY4K_-g;Path=/;Domain=.salesforce.com;Expires=Fri,
27
+ 19-Jun-2015 19:25:30 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":"1429557930126","token_type":"Bearer","instance_url":"https://<host>","signature":"r67C8yGA3MlpIHibA9/5ixX6k3b4vIgUwX+3d1iC3Qs=","access_token":"00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP"}'
41
+ http_version:
42
+ recorded_at: Mon, 20 Apr 2015 19:25:30 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: '{"Friend__c":null}'
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v0.9.1
52
+ Content-Type:
53
+ - application/json
54
+ Authorization:
55
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:25:31 GMT
67
+ Set-Cookie:
68
+ - BrowserId=m-mQLSZGT5ywhOztVhoACA;Path=/;Domain=.salesforce.com;Expires=Fri,
69
+ 19-Jun-2015 19:25:31 GMT
70
+ Expires:
71
+ - Thu, 01 Jan 1970 00:00:00 GMT
72
+ Sforce-Limit-Info:
73
+ - api-usage=13/15000
74
+ Location:
75
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001MG7WAAW"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001MG7WAAW","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Mon, 20 Apr 2015 19:25:31 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c,%20Friend__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001MG7WAAW%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:25:31 GMT
107
+ Set-Cookie:
108
+ - BrowserId=7lkL7l8_SNuY-kCjNc0jFA;Path=/;Domain=.salesforce.com;Expires=Fri,
109
+ 19-Jun-2015 19:25:31 GMT
110
+ Expires:
111
+ - Thu, 01 Jan 1970 00:00:00 GMT
112
+ Sforce-Limit-Info:
113
+ - api-usage=13/15000
114
+ Content-Type:
115
+ - application/json;charset=UTF-8
116
+ Transfer-Encoding:
117
+ - chunked
118
+ body:
119
+ encoding: ASCII-8BIT
120
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001MG7WAAW"},"Id":"a001a000001MG7WAAW","SystemModstamp":"2015-04-20T19:25:31.000+0000","Name":"a001a000001MG7W","Example_Field__c":null,"Friend__c":null}]}'
121
+ http_version:
122
+ recorded_at: Mon, 20 Apr 2015 19:25:32 GMT
123
+ - request:
124
+ method: get
125
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Email%20from%20Contact%20where%20Id%20=%20%27%27
126
+ body:
127
+ encoding: US-ASCII
128
+ string: ''
129
+ headers:
130
+ User-Agent:
131
+ - Faraday v0.9.1
132
+ Authorization:
133
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
134
+ Accept-Encoding:
135
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
136
+ Accept:
137
+ - "*/*"
138
+ response:
139
+ status:
140
+ code: 200
141
+ message: OK
142
+ headers:
143
+ Date:
144
+ - Mon, 20 Apr 2015 19:25:33 GMT
145
+ Set-Cookie:
146
+ - BrowserId=AoKaatypTjaBpGNgJAH23A;Path=/;Domain=.salesforce.com;Expires=Fri,
147
+ 19-Jun-2015 19:25:33 GMT
148
+ Expires:
149
+ - Thu, 01 Jan 1970 00:00:00 GMT
150
+ Sforce-Limit-Info:
151
+ - api-usage=13/15000
152
+ Content-Type:
153
+ - application/json;charset=UTF-8
154
+ Transfer-Encoding:
155
+ - chunked
156
+ body:
157
+ encoding: ASCII-8BIT
158
+ string: '{"totalSize":0,"done":true,"records":[]}'
159
+ http_version:
160
+ recorded_at: Mon, 20 Apr 2015 19:25:33 GMT
161
+ - request:
162
+ method: delete
163
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001MG7WAAW
164
+ body:
165
+ encoding: US-ASCII
166
+ string: ''
167
+ headers:
168
+ User-Agent:
169
+ - Faraday v0.9.1
170
+ Authorization:
171
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
172
+ Accept-Encoding:
173
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
174
+ Accept:
175
+ - "*/*"
176
+ response:
177
+ status:
178
+ code: 204
179
+ message: No Content
180
+ headers:
181
+ Date:
182
+ - Mon, 20 Apr 2015 19:25:34 GMT
183
+ Set-Cookie:
184
+ - BrowserId=GkhRvxVRRTCj8d09-Dp6Kw;Path=/;Domain=.salesforce.com;Expires=Fri,
185
+ 19-Jun-2015 19:25:34 GMT
186
+ Expires:
187
+ - Thu, 01 Jan 1970 00:00:00 GMT
188
+ Sforce-Limit-Info:
189
+ - api-usage=13/15000
190
+ body:
191
+ encoding: UTF-8
192
+ string: ''
193
+ http_version:
194
+ recorded_at: Mon, 20 Apr 2015 19:25:34 GMT
195
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,196 @@
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
+ - Mon, 20 Apr 2015 19:17:58 GMT
25
+ Set-Cookie:
26
+ - BrowserId=knvFN9iJTMKYpcGnHxGrNQ;Path=/;Domain=.salesforce.com;Expires=Fri,
27
+ 19-Jun-2015 19:17:58 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":"1429557478143","token_type":"Bearer","instance_url":"https://<host>","signature":"ra/+CwNB4ZgXs5e+MFICh3OTNXzz5U4pVS+WeaUDLAU=","access_token":"00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP"}'
41
+ http_version:
42
+ recorded_at: Mon, 20 Apr 2015 19:17:58 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":"Sample object"}'
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v0.9.1
52
+ Content-Type:
53
+ - application/json
54
+ Authorization:
55
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:17:59 GMT
67
+ Set-Cookie:
68
+ - BrowserId=JaVblvyiRQqfJcGVtSmJ4Q;Path=/;Domain=.salesforce.com;Expires=Fri,
69
+ 19-Jun-2015 19:17:59 GMT
70
+ Expires:
71
+ - Thu, 01 Jan 1970 00:00:00 GMT
72
+ Sforce-Limit-Info:
73
+ - api-usage=5/15000
74
+ Location:
75
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001MFzDAAW"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001MFzDAAW","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Mon, 20 Apr 2015 19:17:59 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%20Id%20=%20%27a001a000001MFzDAAW%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:18:00 GMT
107
+ Set-Cookie:
108
+ - BrowserId=0Ab5uTlGTL-VOz6fZeGBQQ;Path=/;Domain=.salesforce.com;Expires=Fri,
109
+ 19-Jun-2015 19:18:00 GMT
110
+ Expires:
111
+ - Thu, 01 Jan 1970 00:00:00 GMT
112
+ Sforce-Limit-Info:
113
+ - api-usage=5/15000
114
+ Content-Type:
115
+ - application/json;charset=UTF-8
116
+ Transfer-Encoding:
117
+ - chunked
118
+ body:
119
+ encoding: ASCII-8BIT
120
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001MFzDAAW"},"Id":"a001a000001MFzDAAW","SystemModstamp":"2015-04-20T19:17:59.000+0000","Name":"Sample
121
+ object","Example_Field__c":null}]}'
122
+ http_version:
123
+ recorded_at: Mon, 20 Apr 2015 19:18:00 GMT
124
+ - request:
125
+ method: get
126
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20CustomObject__c%20from%20CustomObjectDetail__c%20where%20CustomObject__c%20=%20%27a001a000001MFzDAAW%27
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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: 200
142
+ message: OK
143
+ headers:
144
+ Date:
145
+ - Mon, 20 Apr 2015 19:18:01 GMT
146
+ Set-Cookie:
147
+ - BrowserId=UZsTVUtDRXy4NAO7ErcPVQ;Path=/;Domain=.salesforce.com;Expires=Fri,
148
+ 19-Jun-2015 19:18:01 GMT
149
+ Expires:
150
+ - Thu, 01 Jan 1970 00:00:00 GMT
151
+ Sforce-Limit-Info:
152
+ - api-usage=5/15000
153
+ Content-Type:
154
+ - application/json;charset=UTF-8
155
+ Transfer-Encoding:
156
+ - chunked
157
+ body:
158
+ encoding: ASCII-8BIT
159
+ string: '{"totalSize":0,"done":true,"records":[]}'
160
+ http_version:
161
+ recorded_at: Mon, 20 Apr 2015 19:18:01 GMT
162
+ - request:
163
+ method: delete
164
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001MFzDAAW
165
+ body:
166
+ encoding: US-ASCII
167
+ string: ''
168
+ headers:
169
+ User-Agent:
170
+ - Faraday v0.9.1
171
+ Authorization:
172
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
173
+ Accept-Encoding:
174
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
175
+ Accept:
176
+ - "*/*"
177
+ response:
178
+ status:
179
+ code: 204
180
+ message: No Content
181
+ headers:
182
+ Date:
183
+ - Mon, 20 Apr 2015 19:18:02 GMT
184
+ Set-Cookie:
185
+ - BrowserId=t4MT5NpQS2Cm_VnlJC0gag;Path=/;Domain=.salesforce.com;Expires=Fri,
186
+ 19-Jun-2015 19:18:02 GMT
187
+ Expires:
188
+ - Thu, 01 Jan 1970 00:00:00 GMT
189
+ Sforce-Limit-Info:
190
+ - api-usage=5/15000
191
+ body:
192
+ encoding: UTF-8
193
+ string: ''
194
+ http_version:
195
+ recorded_at: Mon, 20 Apr 2015 19:18:02 GMT
196
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,195 @@
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
+ - Mon, 20 Apr 2015 19:15:45 GMT
25
+ Set-Cookie:
26
+ - BrowserId=fyl77n8ITN2XO6RXSYfNwQ;Path=/;Domain=.salesforce.com;Expires=Fri,
27
+ 19-Jun-2015 19:15:45 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":"1429557345288","token_type":"Bearer","instance_url":"https://<host>","signature":"KWVtlhIqzN6OZ3uEXDa7ZakPVzRL4UeHWNXC7QKJacs=","access_token":"00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP"}'
41
+ http_version:
42
+ recorded_at: Mon, 20 Apr 2015 19:15:45 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://<host>/services/data/v26.0/sobjects/Contact
46
+ body:
47
+ encoding: UTF-8
48
+ string: '{"Email":"somebody@example.com","LastName":"Somebody"}'
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v0.9.1
52
+ Content-Type:
53
+ - application/json
54
+ Authorization:
55
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:15:46 GMT
67
+ Set-Cookie:
68
+ - BrowserId=ouOxeCEtQlygBOZMsZkTqQ;Path=/;Domain=.salesforce.com;Expires=Fri,
69
+ 19-Jun-2015 19:15:46 GMT
70
+ Expires:
71
+ - Thu, 01 Jan 1970 00:00:00 GMT
72
+ Sforce-Limit-Info:
73
+ - api-usage=1/15000
74
+ Location:
75
+ - "/services/data/v26.0/sobjects/Contact/0031a000002bvGPAAY"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"0031a000002bvGPAAY","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Mon, 20 Apr 2015 19:15:46 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Email%20from%20Contact%20where%20Id%20=%20%270031a000002bvGPAAY%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
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
+ - Mon, 20 Apr 2015 19:15:47 GMT
107
+ Set-Cookie:
108
+ - BrowserId=L-qnfxHxQT-0giWwEiWxLQ;Path=/;Domain=.salesforce.com;Expires=Fri,
109
+ 19-Jun-2015 19:15:47 GMT
110
+ Expires:
111
+ - Thu, 01 Jan 1970 00:00:00 GMT
112
+ Sforce-Limit-Info:
113
+ - api-usage=1/15000
114
+ Content-Type:
115
+ - application/json;charset=UTF-8
116
+ Transfer-Encoding:
117
+ - chunked
118
+ body:
119
+ encoding: ASCII-8BIT
120
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Contact","url":"/services/data/v26.0/sobjects/Contact/0031a000002bvGPAAY"},"Id":"0031a000002bvGPAAY","SystemModstamp":"2015-04-20T19:15:46.000+0000","Email":"somebody@example.com"}]}'
121
+ http_version:
122
+ recorded_at: Mon, 20 Apr 2015 19:15:47 GMT
123
+ - request:
124
+ method: get
125
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c,%20Friend__c%20from%20CustomObject__c%20where%20Friend__c%20=%20%270031a000002bvGPAAY%27
126
+ body:
127
+ encoding: US-ASCII
128
+ string: ''
129
+ headers:
130
+ User-Agent:
131
+ - Faraday v0.9.1
132
+ Authorization:
133
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
134
+ Accept-Encoding:
135
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
136
+ Accept:
137
+ - "*/*"
138
+ response:
139
+ status:
140
+ code: 200
141
+ message: OK
142
+ headers:
143
+ Date:
144
+ - Mon, 20 Apr 2015 19:15:48 GMT
145
+ Set-Cookie:
146
+ - BrowserId=T1KkYnY3SHmnBUDVocLZxA;Path=/;Domain=.salesforce.com;Expires=Fri,
147
+ 19-Jun-2015 19:15:48 GMT
148
+ Expires:
149
+ - Thu, 01 Jan 1970 00:00:00 GMT
150
+ Sforce-Limit-Info:
151
+ - api-usage=1/15000
152
+ Content-Type:
153
+ - application/json;charset=UTF-8
154
+ Transfer-Encoding:
155
+ - chunked
156
+ body:
157
+ encoding: ASCII-8BIT
158
+ string: '{"totalSize":0,"done":true,"records":[]}'
159
+ http_version:
160
+ recorded_at: Mon, 20 Apr 2015 19:15:49 GMT
161
+ - request:
162
+ method: delete
163
+ uri: https://<host>/services/data/v26.0/sobjects/Contact/0031a000002bvGPAAY
164
+ body:
165
+ encoding: US-ASCII
166
+ string: ''
167
+ headers:
168
+ User-Agent:
169
+ - Faraday v0.9.1
170
+ Authorization:
171
+ - OAuth 00D1a000000H3O9!AQ4AQJoC69lofp3.BkQNHdxEquIbjgARO_AQ3LgRth6RSFmB4_KVDLfm9_.J64ouFAGqhXyiThQHypNf.xCD1enx2SQbZDcP
172
+ Accept-Encoding:
173
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
174
+ Accept:
175
+ - "*/*"
176
+ response:
177
+ status:
178
+ code: 204
179
+ message: No Content
180
+ headers:
181
+ Date:
182
+ - Mon, 20 Apr 2015 19:15:49 GMT
183
+ Set-Cookie:
184
+ - BrowserId=zs9JsBwzTSuxXfkH1xTs0g;Path=/;Domain=.salesforce.com;Expires=Fri,
185
+ 19-Jun-2015 19:15:49 GMT
186
+ Expires:
187
+ - Thu, 01 Jan 1970 00:00:00 GMT
188
+ Sforce-Limit-Info:
189
+ - api-usage=1/15000
190
+ body:
191
+ encoding: UTF-8
192
+ string: ''
193
+ http_version:
194
+ recorded_at: Mon, 20 Apr 2015 19:15:50 GMT
195
+ recorded_with: VCR 2.9.3
@@ -69,12 +69,22 @@ describe Restforce::DB::Associations::BelongsTo do
69
69
  describe "#build" do
70
70
  let(:database_record) { CustomObject.new }
71
71
  let(:salesforce_record) { mapping.salesforce_record_type.find(object_salesforce_id).record }
72
- let(:associated) { association.build(database_record, salesforce_record).first }
72
+ let(:associated) { association.build(database_record, salesforce_record) }
73
73
 
74
74
  it "returns an associated record, populated with the Salesforce attributes" do
75
- expect(associated.custom_object).to_equal database_record
76
- expect(associated.email).to_equal "somebody@example.com"
77
- expect(associated.salesforce_id).to_equal user_salesforce_id
75
+ record = associated.first
76
+
77
+ expect(record.custom_object).to_equal database_record
78
+ expect(record.email).to_equal "somebody@example.com"
79
+ expect(record.salesforce_id).to_equal user_salesforce_id
80
+ end
81
+
82
+ describe "when no salesforce record is found for the association" do
83
+ let(:user_salesforce_id) { nil }
84
+
85
+ it "proceeds without constructing any records" do
86
+ expect(associated).to_be :empty?
87
+ end
78
88
  end
79
89
  end
80
90
  end
@@ -91,6 +91,15 @@ describe Restforce::DB::Associations::HasMany do
91
91
  expect(record.custom_object).to_equal database_record
92
92
  end
93
93
  end
94
+
95
+ describe "when no salesforce record is found for the association" do
96
+ let(:detail_salesforce_ids) { nil }
97
+
98
+ it "proceeds without constructing any records" do
99
+ detail_salesforce_ids
100
+ expect(associated).to_be :empty?
101
+ end
102
+ end
94
103
  end
95
104
  end
96
105
  end
@@ -76,6 +76,14 @@ describe Restforce::DB::Associations::HasOne do
76
76
  expect(object.salesforce_id).to_equal object_salesforce_id
77
77
  end
78
78
 
79
+ describe "when no salesforce record is found for the association" do
80
+ let(:object_salesforce_id) { nil }
81
+
82
+ it "proceeds without constructing any records" do
83
+ expect(associated).to_be :empty?
84
+ end
85
+ end
86
+
79
87
  describe "and a nested association on the associated mapping" do
80
88
  let(:nested_mapping) do
81
89
  Restforce::DB::Mapping.new(Detail, "CustomObjectDetail__c").tap do |m|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restforce-db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Horner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -241,13 +241,16 @@ files:
241
241
  - restforce-db.gemspec
242
242
  - test/cassettes/Restforce_DB/accessing_Salesforce/uses_the_configured_credentials.yml
243
243
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/returns_an_associated_record_populated_with_the_Salesforce_attributes.yml
244
+ - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_no_salesforce_record_is_found_for_the_association/proceeds_without_constructing_any_records.yml
244
245
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
245
246
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
246
247
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/builds_a_number_of_associated_records_from_the_data_in_Salesforce.yml
248
+ - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/when_no_salesforce_record_is_found_for_the_association/proceeds_without_constructing_any_records.yml
247
249
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
248
250
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
249
251
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/and_a_nested_association_on_the_associated_mapping/recursively_builds_all_associations.yml
250
252
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/returns_an_associated_record_populated_with_the_Salesforce_attributes.yml
253
+ - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/when_no_salesforce_record_is_found_for_the_association/proceeds_without_constructing_any_records.yml
251
254
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
252
255
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
253
256
  - test/cassettes/Restforce_DB_Collector/_run/given_a_Salesforce_record_with_an_associated_database_record/returns_the_attributes_from_both_records.yml