restforce-db 1.2.12 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54e87c10756c3eaa8d5a1307477ab6bcbe3743eb
4
- data.tar.gz: 281164ea7eaaca49f8b2867b85232634fa63e326
3
+ metadata.gz: 7d8819030ad19f9cf66c0f4f0e8a8f619a75a207
4
+ data.tar.gz: 239e7983d8a2f382f02616635d2d96882eae3a44
5
5
  SHA512:
6
- metadata.gz: 84649d0104478df05e9e1d4664781757a2a68f3e067861c25093f0a4df31c1587121648a57d4bcf8a992b1d8d7ad52702efbbc236fc87650ee7983f8ccf76c1d
7
- data.tar.gz: 00509806871db7f6fb9046232882d7dd2564b72c6b541b1b73bd2f5f2af763ca47e2cc07001e51774fde2e50920a569fc1dbefa8d3d3ca6a4aed90c0cea266af
6
+ metadata.gz: dac325298c30890ac75800f246863b3e831c25e2c66c108f3835f091271f49cd2c69ddc9fa165620c8c650f507d22db44346435c3c062deac0fd251728918c64
7
+ data.tar.gz: 0d95128ded0b74be19e399e2350d9a0f34889c1a0fd0f69703dd5dc475f2f1684e32ff1be9b4f030c8d1ed41385b9e487e40cc4d8d5a14f96e20bd5df2fec80c
data/README.md CHANGED
@@ -170,7 +170,20 @@ This _also_ defines an inverse relationship for a `belongs_to` relationship. The
170
170
 
171
171
  In the above example, `Dish__c` is a Salesforce object type which references the `Restaurant__c` object type through an aptly-named Lookup. There is no restriction on the number of `Dish__c` objects that may reference the same `Restaurant__c`, so we define this relationship as a `has_many` associaition in our `Restaurant` mapping.
172
172
 
173
- __NOTE__: If one side of an association has multiple possible lookup fields, the other side of the association is expected to declare a _single_ lookup field, which will be treated as the canonical lookup for that relationship. The Lookup is assumed to always refer to the `Id` of the object declaring the `has_many`/`has_one` side of the association.
173
+ ##### Association Caveats
174
+
175
+ - **Lookups.**
176
+ If one side of an association has multiple possible lookup fields, the other side of the association is expected to declare a _single_ lookup field, which will be treated as the canonical lookup for that relationship. The Lookup is assumed to always refer to the `Id` of the object declaring the `has_many`/`has_one` side of the association.
177
+
178
+ - **Record Construction.**
179
+ By default, _all_ associated records will be recursively constructed when a single record is synchronized into the system. This can result in a lot of unwanted/time-consuming record creation, particularly if your Salesforce account has a lot of irrelevant legacy data. You can turn off this behavior for specific associations by passing `build: false` when declaring the association in the DSL.
180
+
181
+ - **Record Persistence.**
182
+ See the `autosave: true` option declared for the `has_one` relationship on `Restaurant`? `Restforce::DB` requires your ActiveRecord models to handle persistence propagation.
183
+
184
+ When inserting new records, `save!` will only be invoked on the _entry point_ record (typically a mapping with an `:always` synchronization strategy), so the persistence of any associated records must be chained through this "root" object.
185
+
186
+ You may want to consult [the ActiveRecord documentation](http://apidock.com/rails/ActiveRecord/Associations/ClassMethods) for your specific use case.
174
187
 
175
188
  ### Seed your data
176
189
 
@@ -201,20 +214,13 @@ For additional information and a full set of options, you can run:
201
214
 
202
215
  $ bundle exec bin/restforce-db -h
203
216
 
204
- ## Caveats
217
+ ## System Caveats
205
218
 
206
219
  - **API Usage.**
207
220
  This gem performs most of its functionality via the Salesforce API (by way of the [`restforce`](https://github.com/ejholmes/restforce) gem). If you're at risk of hitting your Salesforce API limits, this may not be the right approach for you.
208
221
 
209
222
  - **Update Prioritization.**
210
223
  When synchronization occurs, the most recently updated record, Salesforce or database, gets to make the final call about the values of _all_ of the fields it observes. This means that race conditions can and probably will happen if both systems are updated within the same polling interval.
211
-
212
- - **Record Persistence.**
213
- See the `autosave: true` option declared for the `has_one` relationship on `Restaurant`? `Restforce::DB` requires your ActiveRecord models to handle persistence propagation.
214
-
215
- When inserting new records, `save!` will only be invoked on the _entry point_ record (typically a mapping with an `:always` synchronization strategy), so the persistence of any associated records must be chained through this "root" object.
216
-
217
- You may want to consult [the ActiveRecord documentation](http://apidock.com/rails/ActiveRecord/Associations/ClassMethods) for your specific use case.
218
224
 
219
225
  ## Development
220
226
 
@@ -14,9 +14,12 @@ module Restforce
14
14
  #
15
15
  # name - The name of the ActiveRecord association to construct.
16
16
  # through - The name of the lookup field on the Salesforce record.
17
- def initialize(name, through: nil)
17
+ # build - A Boolean indicating whether or not the association chain
18
+ # should be built out for new records.
19
+ def initialize(name, through: nil, build: true)
18
20
  @name = name.to_sym
19
21
  @lookup = through.is_a?(Array) ? through.map(&:to_s) : through.to_s
22
+ @build = build
20
23
  end
21
24
 
22
25
  # Public: Build a record or series of records for the association
@@ -55,6 +58,14 @@ module Restforce
55
58
 
56
59
  private
57
60
 
61
+ # Internal: Should records for this association be synchronized between
62
+ # the two systems when a new record is added for the base mapping?
63
+ #
64
+ # Returns a Boolean.
65
+ def build?
66
+ @build
67
+ end
68
+
58
69
  # Internal: Get the appropriate Salesforce Lookup ID field for the
59
70
  # passed mapping.
60
71
  #
@@ -18,6 +18,8 @@ module Restforce
18
18
  #
19
19
  # Returns an Array of constructed association records.
20
20
  def build(database_record, salesforce_record, cache = AssociationCache.new(database_record))
21
+ return [] unless build?
22
+
21
23
  @cache = cache
22
24
 
23
25
  lookups = {}
@@ -18,6 +18,8 @@ module Restforce
18
18
  #
19
19
  # Returns an Array of constructed association records.
20
20
  def build(database_record, salesforce_record, cache = AssociationCache.new(database_record))
21
+ return [] unless build?
22
+
21
23
  @cache = cache
22
24
 
23
25
  target = target_mapping(database_record)
@@ -18,6 +18,8 @@ module Restforce
18
18
  #
19
19
  # Returns an Array of constructed association records.
20
20
  def build(database_record, salesforce_record, cache = AssociationCache.new(database_record))
21
+ return [] unless build?
22
+
21
23
  @cache = cache
22
24
 
23
25
  target = target_mapping(database_record)
@@ -37,12 +37,15 @@ module Restforce
37
37
  #
38
38
  # association - The name of the ActiveRecord association.
39
39
  # through - A String or Array of Strings representing the Lookup IDs.
40
+ # build - A Boolean indicating whether or not the association chain
41
+ # should be built out for new records.
40
42
  #
41
43
  # Returns nothing.
42
- def belongs_to(association, through:)
44
+ def belongs_to(association, through:, build: true)
43
45
  @mapping.associations << Associations::BelongsTo.new(
44
46
  association,
45
47
  through: through,
48
+ build: build,
46
49
  )
47
50
  end
48
51
 
@@ -51,12 +54,15 @@ module Restforce
51
54
  #
52
55
  # association - The name of the ActiveRecord association.
53
56
  # through - A String representing the Lookup ID.
57
+ # build - A Boolean indicating whether or not the association chain
58
+ # should be built out for new records.
54
59
  #
55
60
  # Returns nothing.
56
- def has_one(association, through:) # rubocop:disable PredicateName
61
+ def has_one(association, through:, build: true) # rubocop:disable PredicateName
57
62
  @mapping.associations << Associations::HasOne.new(
58
63
  association,
59
64
  through: through,
65
+ build: build,
60
66
  )
61
67
  end
62
68
 
@@ -65,12 +71,15 @@ module Restforce
65
71
  #
66
72
  # association - The name of the ActiveRecord association.
67
73
  # through - A String representing the Lookup ID.
74
+ # build - A Boolean indicating whether or not the association chain
75
+ # should be built out for new records.
68
76
  #
69
77
  # Returns nothing.
70
- def has_many(association, through:) # rubocop:disable PredicateName
78
+ def has_many(association, through:, build: true) # rubocop:disable PredicateName
71
79
  @mapping.associations << Associations::HasMany.new(
72
80
  association,
73
81
  through: through,
82
+ build: build,
74
83
  )
75
84
  end
76
85
 
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "1.2.12"
6
+ VERSION = "1.3.0"
7
7
 
8
8
  end
9
9
 
@@ -0,0 +1,233 @@
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
+ - Tue, 12 May 2015 19:57:14 GMT
25
+ Set-Cookie:
26
+ - BrowserId=V9dFLjV5TievBVtXBTgLWg;Path=/;Domain=.salesforce.com;Expires=Sat,
27
+ 11-Jul-2015 19:57:14 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":"1431460634690","token_type":"Bearer","instance_url":"https://<host>","signature":"I1sgPTyHS2c7Q4mY6uYgi366rdlGdYcRwz3opVrE+58=","access_token":"00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM"}'
41
+ http_version:
42
+ recorded_at: Tue, 12 May 2015 19:57:14 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!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
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
+ - Tue, 12 May 2015 19:57:16 GMT
67
+ Set-Cookie:
68
+ - BrowserId=xiEWPErTSdeEBjwIUT0J3w;Path=/;Domain=.salesforce.com;Expires=Sat,
69
+ 11-Jul-2015 19:57:16 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/0031a000003Gm5NAAS"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"0031a000003Gm5NAAS","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Tue, 12 May 2015 19:57:16 GMT
85
+ - request:
86
+ method: post
87
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c
88
+ body:
89
+ encoding: UTF-8
90
+ string: '{"Friend__c":"0031a000003Gm5NAAS"}'
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Content-Type:
95
+ - application/json
96
+ Authorization:
97
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
98
+ Accept-Encoding:
99
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
100
+ Accept:
101
+ - "*/*"
102
+ response:
103
+ status:
104
+ code: 201
105
+ message: Created
106
+ headers:
107
+ Date:
108
+ - Tue, 12 May 2015 19:57:17 GMT
109
+ Set-Cookie:
110
+ - BrowserId=4lHsZnLEReGCcTNe30pcuA;Path=/;Domain=.salesforce.com;Expires=Sat,
111
+ 11-Jul-2015 19:57:17 GMT
112
+ Expires:
113
+ - Thu, 01 Jan 1970 00:00:00 GMT
114
+ Sforce-Limit-Info:
115
+ - api-usage=2/15000
116
+ Location:
117
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKKDAA4"
118
+ Content-Type:
119
+ - application/json;charset=UTF-8
120
+ Transfer-Encoding:
121
+ - chunked
122
+ body:
123
+ encoding: ASCII-8BIT
124
+ string: '{"id":"a001a000001ZKKDAA4","success":true,"errors":[]}'
125
+ http_version:
126
+ recorded_at: Tue, 12 May 2015 19:57:17 GMT
127
+ - request:
128
+ method: get
129
+ 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%27a001a000001ZKKDAA4%27
130
+ body:
131
+ encoding: US-ASCII
132
+ string: ''
133
+ headers:
134
+ User-Agent:
135
+ - Faraday v0.9.1
136
+ Authorization:
137
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
138
+ Accept-Encoding:
139
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
140
+ Accept:
141
+ - "*/*"
142
+ response:
143
+ status:
144
+ code: 200
145
+ message: OK
146
+ headers:
147
+ Date:
148
+ - Tue, 12 May 2015 19:57:18 GMT
149
+ Set-Cookie:
150
+ - BrowserId=cpODyp_6RtSVX3OwT0Rm3Q;Path=/;Domain=.salesforce.com;Expires=Sat,
151
+ 11-Jul-2015 19:57:18 GMT
152
+ Expires:
153
+ - Thu, 01 Jan 1970 00:00:00 GMT
154
+ Sforce-Limit-Info:
155
+ - api-usage=1/15000
156
+ Content-Type:
157
+ - application/json;charset=UTF-8
158
+ Transfer-Encoding:
159
+ - chunked
160
+ body:
161
+ encoding: ASCII-8BIT
162
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKKDAA4"},"Id":"a001a000001ZKKDAA4","SystemModstamp":"2015-05-12T19:57:17.000+0000","Name":"a001a000001ZKKD","Example_Field__c":null,"Friend__c":"0031a000003Gm5NAAS"}]}'
163
+ http_version:
164
+ recorded_at: Tue, 12 May 2015 19:57:18 GMT
165
+ - request:
166
+ method: delete
167
+ uri: https://<host>/services/data/v26.0/sobjects/Contact/0031a000003Gm5NAAS
168
+ body:
169
+ encoding: US-ASCII
170
+ string: ''
171
+ headers:
172
+ User-Agent:
173
+ - Faraday v0.9.1
174
+ Authorization:
175
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
176
+ Accept-Encoding:
177
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
178
+ Accept:
179
+ - "*/*"
180
+ response:
181
+ status:
182
+ code: 204
183
+ message: No Content
184
+ headers:
185
+ Date:
186
+ - Tue, 12 May 2015 19:57:19 GMT
187
+ Set-Cookie:
188
+ - BrowserId=3VOrxur8Rvq-ronZBZbAYw;Path=/;Domain=.salesforce.com;Expires=Sat,
189
+ 11-Jul-2015 19:57:19 GMT
190
+ Expires:
191
+ - Thu, 01 Jan 1970 00:00:00 GMT
192
+ Sforce-Limit-Info:
193
+ - api-usage=3/15000
194
+ body:
195
+ encoding: UTF-8
196
+ string: ''
197
+ http_version:
198
+ recorded_at: Tue, 12 May 2015 19:57:19 GMT
199
+ - request:
200
+ method: delete
201
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKKDAA4
202
+ body:
203
+ encoding: US-ASCII
204
+ string: ''
205
+ headers:
206
+ User-Agent:
207
+ - Faraday v0.9.1
208
+ Authorization:
209
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
210
+ Accept-Encoding:
211
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
212
+ Accept:
213
+ - "*/*"
214
+ response:
215
+ status:
216
+ code: 204
217
+ message: No Content
218
+ headers:
219
+ Date:
220
+ - Tue, 12 May 2015 19:57:20 GMT
221
+ Set-Cookie:
222
+ - BrowserId=JBvgCXUUQE6C-I39j-qI9Q;Path=/;Domain=.salesforce.com;Expires=Sat,
223
+ 11-Jul-2015 19:57:20 GMT
224
+ Expires:
225
+ - Thu, 01 Jan 1970 00:00:00 GMT
226
+ Sforce-Limit-Info:
227
+ - api-usage=4/15000
228
+ body:
229
+ encoding: UTF-8
230
+ string: ''
231
+ http_version:
232
+ recorded_at: Tue, 12 May 2015 19:57:20 GMT
233
+ recorded_with: VCR 2.9.3
@@ -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
+ - Tue, 12 May 2015 19:56:59 GMT
25
+ Set-Cookie:
26
+ - BrowserId=yusXRkc8QSyB7IvrQnLLOA;Path=/;Domain=.salesforce.com;Expires=Sat,
27
+ 11-Jul-2015 19:56:59 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":"1431460619986","token_type":"Bearer","instance_url":"https://<host>","signature":"u64BZdZBkpV7s2sYs1cc+mLttOxfG+RQh+VA+afErCc=","access_token":"00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM"}'
41
+ http_version:
42
+ recorded_at: Tue, 12 May 2015 19:56:59 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!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
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
+ - Tue, 12 May 2015 19:57:00 GMT
67
+ Set-Cookie:
68
+ - BrowserId=czn8MSKAQYCWpily8DabbA;Path=/;Domain=.salesforce.com;Expires=Sat,
69
+ 11-Jul-2015 19:57:00 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/CustomObject__c/a001a000001ZKK3AAO"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001ZKK3AAO","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Tue, 12 May 2015 19:57:01 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%27a001a000001ZKK3AAO%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
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
+ - Tue, 12 May 2015 19:57:02 GMT
107
+ Set-Cookie:
108
+ - BrowserId=iG1exjXpRjOfCoOwN3IvHw;Path=/;Domain=.salesforce.com;Expires=Sat,
109
+ 11-Jul-2015 19:57:02 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":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKK3AAO"},"Id":"a001a000001ZKK3AAO","SystemModstamp":"2015-05-12T19:57:01.000+0000","Name":"Sample
121
+ object","Example_Field__c":null}]}'
122
+ http_version:
123
+ recorded_at: Tue, 12 May 2015 19:57:02 GMT
124
+ - request:
125
+ method: delete
126
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKK3AAO
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
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
+ - Tue, 12 May 2015 19:57:03 GMT
146
+ Set-Cookie:
147
+ - BrowserId=zPNjjlJwT5y6BR4og2QjtA;Path=/;Domain=.salesforce.com;Expires=Sat,
148
+ 11-Jul-2015 19:57:03 GMT
149
+ Expires:
150
+ - Thu, 01 Jan 1970 00:00:00 GMT
151
+ Sforce-Limit-Info:
152
+ - api-usage=1/15000
153
+ body:
154
+ encoding: UTF-8
155
+ string: ''
156
+ http_version:
157
+ recorded_at: Tue, 12 May 2015 19:57:03 GMT
158
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,233 @@
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
+ - Tue, 12 May 2015 19:57:06 GMT
25
+ Set-Cookie:
26
+ - BrowserId=NUhYBDtmTYugORuK-TH2EA;Path=/;Domain=.salesforce.com;Expires=Sat,
27
+ 11-Jul-2015 19:57:06 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":"1431460626374","token_type":"Bearer","instance_url":"https://<host>","signature":"1Zzf/BDRxmeaZ/+eIrifZJcG35w/MfK2z4CME5hYJa8=","access_token":"00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM"}'
41
+ http_version:
42
+ recorded_at: Tue, 12 May 2015 19:57:06 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!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
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
+ - Tue, 12 May 2015 19:57:07 GMT
67
+ Set-Cookie:
68
+ - BrowserId=oglbfN3hRIOSsxoVd7t9Xg;Path=/;Domain=.salesforce.com;Expires=Sat,
69
+ 11-Jul-2015 19:57:07 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/0031a000003Gm5IAAS"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"0031a000003Gm5IAAS","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Tue, 12 May 2015 19:57:08 GMT
85
+ - request:
86
+ method: post
87
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c
88
+ body:
89
+ encoding: UTF-8
90
+ string: '{"Friend__c":"0031a000003Gm5IAAS"}'
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Content-Type:
95
+ - application/json
96
+ Authorization:
97
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
98
+ Accept-Encoding:
99
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
100
+ Accept:
101
+ - "*/*"
102
+ response:
103
+ status:
104
+ code: 201
105
+ message: Created
106
+ headers:
107
+ Date:
108
+ - Tue, 12 May 2015 19:57:08 GMT
109
+ Set-Cookie:
110
+ - BrowserId=rDu3h6a4QzCJ01BNom8m-A;Path=/;Domain=.salesforce.com;Expires=Sat,
111
+ 11-Jul-2015 19:57:08 GMT
112
+ Expires:
113
+ - Thu, 01 Jan 1970 00:00:00 GMT
114
+ Sforce-Limit-Info:
115
+ - api-usage=2/15000
116
+ Location:
117
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKK8AAO"
118
+ Content-Type:
119
+ - application/json;charset=UTF-8
120
+ Transfer-Encoding:
121
+ - chunked
122
+ body:
123
+ encoding: ASCII-8BIT
124
+ string: '{"id":"a001a000001ZKK8AAO","success":true,"errors":[]}'
125
+ http_version:
126
+ recorded_at: Tue, 12 May 2015 19:57:09 GMT
127
+ - request:
128
+ method: get
129
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Email%20from%20Contact%20where%20Id%20=%20%270031a000003Gm5IAAS%27
130
+ body:
131
+ encoding: US-ASCII
132
+ string: ''
133
+ headers:
134
+ User-Agent:
135
+ - Faraday v0.9.1
136
+ Authorization:
137
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
138
+ Accept-Encoding:
139
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
140
+ Accept:
141
+ - "*/*"
142
+ response:
143
+ status:
144
+ code: 200
145
+ message: OK
146
+ headers:
147
+ Date:
148
+ - Tue, 12 May 2015 19:57:10 GMT
149
+ Set-Cookie:
150
+ - BrowserId=bzTtVerbQeqmUsX-EWlJDQ;Path=/;Domain=.salesforce.com;Expires=Sat,
151
+ 11-Jul-2015 19:57:10 GMT
152
+ Expires:
153
+ - Thu, 01 Jan 1970 00:00:00 GMT
154
+ Sforce-Limit-Info:
155
+ - api-usage=1/15000
156
+ Content-Type:
157
+ - application/json;charset=UTF-8
158
+ Transfer-Encoding:
159
+ - chunked
160
+ body:
161
+ encoding: ASCII-8BIT
162
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"Contact","url":"/services/data/v26.0/sobjects/Contact/0031a000003Gm5IAAS"},"Id":"0031a000003Gm5IAAS","SystemModstamp":"2015-05-12T19:57:07.000+0000","Email":"somebody@example.com"}]}'
163
+ http_version:
164
+ recorded_at: Tue, 12 May 2015 19:57:10 GMT
165
+ - request:
166
+ method: delete
167
+ uri: https://<host>/services/data/v26.0/sobjects/Contact/0031a000003Gm5IAAS
168
+ body:
169
+ encoding: US-ASCII
170
+ string: ''
171
+ headers:
172
+ User-Agent:
173
+ - Faraday v0.9.1
174
+ Authorization:
175
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
176
+ Accept-Encoding:
177
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
178
+ Accept:
179
+ - "*/*"
180
+ response:
181
+ status:
182
+ code: 204
183
+ message: No Content
184
+ headers:
185
+ Date:
186
+ - Tue, 12 May 2015 19:57:11 GMT
187
+ Set-Cookie:
188
+ - BrowserId=EscE3IkGQPup41dBUcsBQQ;Path=/;Domain=.salesforce.com;Expires=Sat,
189
+ 11-Jul-2015 19:57:11 GMT
190
+ Expires:
191
+ - Thu, 01 Jan 1970 00:00:00 GMT
192
+ Sforce-Limit-Info:
193
+ - api-usage=2/15000
194
+ body:
195
+ encoding: UTF-8
196
+ string: ''
197
+ http_version:
198
+ recorded_at: Tue, 12 May 2015 19:57:11 GMT
199
+ - request:
200
+ method: delete
201
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ZKK8AAO
202
+ body:
203
+ encoding: US-ASCII
204
+ string: ''
205
+ headers:
206
+ User-Agent:
207
+ - Faraday v0.9.1
208
+ Authorization:
209
+ - OAuth 00D1a000000H3O9!AQ4AQCN.EK5q2GqYClj_rprS9iFZEfWNjLjAqM_ql5mTUm5HJcVjXHY5YGQjvRhrTa_S8zNQyoc122zuBhcNpC6YS7qVpYuM
210
+ Accept-Encoding:
211
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
212
+ Accept:
213
+ - "*/*"
214
+ response:
215
+ status:
216
+ code: 204
217
+ message: No Content
218
+ headers:
219
+ Date:
220
+ - Tue, 12 May 2015 19:57:12 GMT
221
+ Set-Cookie:
222
+ - BrowserId=-PW_MFHBSiWEgiW3Lxo9GQ;Path=/;Domain=.salesforce.com;Expires=Sat,
223
+ 11-Jul-2015 19:57:12 GMT
224
+ Expires:
225
+ - Thu, 01 Jan 1970 00:00:00 GMT
226
+ Sforce-Limit-Info:
227
+ - api-usage=1/15000
228
+ body:
229
+ encoding: UTF-8
230
+ string: ''
231
+ http_version:
232
+ recorded_at: Tue, 12 May 2015 19:57:12 GMT
233
+ recorded_with: VCR 2.9.3
@@ -97,6 +97,14 @@ describe Restforce::DB::Associations::BelongsTo do
97
97
  expect(record.salesforce_id).to_equal user_salesforce_id
98
98
  end
99
99
 
100
+ describe "when the association is non-building" do
101
+ let(:association) { Restforce::DB::Associations::BelongsTo.new(:user, through: "Friend__c", build: false) }
102
+
103
+ it "proceeds without constructing any records" do
104
+ expect(associated).to_be :empty?
105
+ end
106
+ end
107
+
100
108
  describe "when no salesforce record is found for the association" do
101
109
  let(:user_salesforce_id) { nil }
102
110
 
@@ -92,6 +92,14 @@ describe Restforce::DB::Associations::HasMany do
92
92
  end
93
93
  end
94
94
 
95
+ describe "when the association is non-building" do
96
+ let(:association) { Restforce::DB::Associations::HasMany.new(:details, through: "CustomObject__c", build: false) }
97
+
98
+ it "proceeds without constructing any records" do
99
+ expect(associated).to_be :empty?
100
+ end
101
+ end
102
+
95
103
  describe "when no salesforce record is found for the association" do
96
104
  let(:detail_salesforce_ids) { nil }
97
105
 
@@ -77,6 +77,14 @@ describe Restforce::DB::Associations::HasOne do
77
77
  expect(object.salesforce_id).to_equal object_salesforce_id
78
78
  end
79
79
 
80
+ describe "when the association is non-building" do
81
+ let(:association) { Restforce::DB::Associations::HasOne.new(:custom_object, through: "Friend__c", build: false) }
82
+
83
+ it "proceeds without constructing any records" do
84
+ expect(associated).to_be :empty?
85
+ end
86
+ end
87
+
80
88
  describe "when no salesforce record is found for the association" do
81
89
  let(:object_salesforce_id) { nil }
82
90
 
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.12
4
+ version: 1.3.0
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-05-07 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -250,6 +250,7 @@ files:
250
250
  - 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
251
251
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_the_associated_record_has_already_been_persisted/assigns_the_existing_record.yml
252
252
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_the_associated_record_has_been_cached/uses_the_cached_record.yml
253
+ - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_the_association_is_non-building/proceeds_without_constructing_any_records.yml
253
254
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/with_an_unrelated_association_mapping/proceeds_without_raising_an_error.yml
254
255
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/returns_a_hash_of_the_associated_records_lookup_IDs.yml
255
256
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/when_there_is_currently_no_associated_record/returns_a_nil_lookup_value_in_the_hash.yml
@@ -259,6 +260,7 @@ files:
259
260
  - 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
260
261
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/when_the_associated_records_have_alrady_been_persisted/constructs_the_association_from_the_existing_records.yml
261
262
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/when_the_associated_records_have_been_cached/uses_the_cached_records.yml
263
+ - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/when_the_association_is_non-building/proceeds_without_constructing_any_records.yml
262
264
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
263
265
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
264
266
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/and_a_nested_association_on_the_associated_mapping/recursively_builds_all_associations.yml
@@ -266,6 +268,7 @@ files:
266
268
  - 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
267
269
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/when_the_associated_record_has_already_been_persisted/assigns_the_existing_record.yml
268
270
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/when_the_associated_record_has_been_cached/uses_the_cached_record.yml
271
+ - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/when_the_association_is_non-building/proceeds_without_constructing_any_records.yml
269
272
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
270
273
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
271
274
  - test/cassettes/Restforce_DB_Associator/_run/given_a_BelongsTo_association/given_another_record_for_association/when_the_Salesforce_association_is_out_of_date/updates_the_association_ID_in_Salesforce.yml