restforce-db 2.2.1 → 2.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: b2cb85f0771086af64738fb779fef4a19013bf63
4
- data.tar.gz: 0b5126b6420dde9841cfd2a724f9756b452b6922
3
+ metadata.gz: c790174b7a31460e534bb254f1a624d5eaa3c0d0
4
+ data.tar.gz: 500ff38107efb2fc41e18cea8c645b0e4fc4b2af
5
5
  SHA512:
6
- metadata.gz: 5e6b36b7d739d92ed0cd5851702134d030065cc11024b7c2eb383bc30efd6435072cbcc8b0053f5565b57c39427d8adc0ca75e5d8535cc3824296ede65e63eb1
7
- data.tar.gz: 61301c3deb673a01c1d233e3d727387b074e453b92db30b8faade80fba61134d5e9db30e7d0d29d6d782a825ddb189d9d05166b98574143ba839617c8d3206c5
6
+ metadata.gz: 88a7f335785b06227b32aedc9846b658f9e765fe69c26e48a33ca1e2f2915bc22f20f75f3a08c4bd9a93d99332091ce1b937e4bc5e936e90bbb46d17028dd512
7
+ data.tar.gz: 63a32a184556cf24cd4f1565fe735d025d8390070280a8bccbf5d76fb4ac5d782bff272ffd2db9eebf251922dabe4b7e78e06bc1e5a474a99694d6e87bf0c00e
@@ -57,6 +57,16 @@ module Restforce
57
57
  end
58
58
  end
59
59
 
60
+ # Public: Does the timestamp of the most recent change meet or exceed the
61
+ # specified timestamp?
62
+ #
63
+ # timestamp - A Time object.
64
+ #
65
+ # Returns a Boolean.
66
+ def up_to_date_for?(timestamp)
67
+ keys.sort.last >= timestamp
68
+ end
69
+
60
70
  end
61
71
 
62
72
  end
@@ -34,6 +34,12 @@ module Restforce
34
34
  salesforce_instance = @mapping.salesforce_record_type.find(id)
35
35
  next unless database_instance && salesforce_instance
36
36
 
37
+ most_recent_timestamp = [
38
+ database_instance.last_update,
39
+ salesforce_instance.last_update,
40
+ ].max
41
+ next unless accumulator.up_to_date_for?(most_recent_timestamp)
42
+
37
43
  update(database_instance, accumulator)
38
44
  update(salesforce_instance, accumulator)
39
45
  end
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "2.2.1"
6
+ VERSION = "2.2.2"
7
7
 
8
8
  end
9
9
 
@@ -0,0 +1,197 @@
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
+ - Fri, 05 Jun 2015 20:25:15 GMT
25
+ Set-Cookie:
26
+ - BrowserId=NaqbSOCqRUG6T6kMI7khkA;Path=/;Domain=.salesforce.com;Expires=Tue,
27
+ 04-Aug-2015 20:25:15 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":"1433535915696","token_type":"Bearer","instance_url":"https://<host>","signature":"fD9CLmClrzCnCIA6HkADFMT5/dCPYKYImpoZjvAkDic=","access_token":"00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE"}'
41
+ http_version:
42
+ recorded_at: Fri, 05 Jun 2015 20:25:15 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://<host>/services/data/<api_version>/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!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:16 GMT
67
+ Set-Cookie:
68
+ - BrowserId=EYRZMT40RRiN-tBLEgOllw;Path=/;Domain=.salesforce.com;Expires=Tue,
69
+ 04-Aug-2015 20:25:16 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/<api_version>/sobjects/CustomObject__c/a001a000001c8ahAAA"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001c8ahAAA","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Fri, 05 Jun 2015 20:25:16 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/<api_version>/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001c8ahAAA%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:17 GMT
107
+ Set-Cookie:
108
+ - BrowserId=xQtzOGa1SL-c96vfqFd1-Q;Path=/;Domain=.salesforce.com;Expires=Tue,
109
+ 04-Aug-2015 20:25:17 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/<api_version>/sobjects/CustomObject__c/a001a000001c8ahAAA"},"Id":"a001a000001c8ahAAA","SystemModstamp":"2015-06-05T20:25:16.000+0000","Name":"Custom
121
+ object","Example_Field__c":"Some sample text"}]}'
122
+ http_version:
123
+ recorded_at: Fri, 05 Jun 2015 20:25:17 GMT
124
+ - request:
125
+ method: get
126
+ uri: https://<host>/services/data/<api_version>/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001c8ahAAA%27
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:18 GMT
146
+ Set-Cookie:
147
+ - BrowserId=GV0SXgQCSqWGC-GW2kbr7Q;Path=/;Domain=.salesforce.com;Expires=Tue,
148
+ 04-Aug-2015 20:25:18 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":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/<api_version>/sobjects/CustomObject__c/a001a000001c8ahAAA"},"Id":"a001a000001c8ahAAA","SystemModstamp":"2015-06-05T20:25:16.000+0000","Name":"Custom
160
+ object","Example_Field__c":"Some sample text"}]}'
161
+ http_version:
162
+ recorded_at: Fri, 05 Jun 2015 20:25:18 GMT
163
+ - request:
164
+ method: delete
165
+ uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a000001c8ahAAA
166
+ body:
167
+ encoding: US-ASCII
168
+ string: ''
169
+ headers:
170
+ User-Agent:
171
+ - Faraday v0.9.1
172
+ Authorization:
173
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
174
+ Accept-Encoding:
175
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
176
+ Accept:
177
+ - "*/*"
178
+ response:
179
+ status:
180
+ code: 204
181
+ message: No Content
182
+ headers:
183
+ Date:
184
+ - Fri, 05 Jun 2015 20:25:19 GMT
185
+ Set-Cookie:
186
+ - BrowserId=i2ttnY_IShCGquR_RqSKug;Path=/;Domain=.salesforce.com;Expires=Tue,
187
+ 04-Aug-2015 20:25:19 GMT
188
+ Expires:
189
+ - Thu, 01 Jan 1970 00:00:00 GMT
190
+ Sforce-Limit-Info:
191
+ - api-usage=5/15000
192
+ body:
193
+ encoding: UTF-8
194
+ string: ''
195
+ http_version:
196
+ recorded_at: Fri, 05 Jun 2015 20:25:19 GMT
197
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,236 @@
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
+ - Fri, 05 Jun 2015 20:25:20 GMT
25
+ Set-Cookie:
26
+ - BrowserId=Kty7tJAYT1qPGeq4D3Unug;Path=/;Domain=.salesforce.com;Expires=Tue,
27
+ 04-Aug-2015 20:25:20 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":"1433535920475","token_type":"Bearer","instance_url":"https://<host>","signature":"O35nl1BtAs3tfVm7q9qvPHALERbq5y66/3Eo5ATxYCs=","access_token":"00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE"}'
41
+ http_version:
42
+ recorded_at: Fri, 05 Jun 2015 20:25:20 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://<host>/services/data/<api_version>/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!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:21 GMT
67
+ Set-Cookie:
68
+ - BrowserId=LtnrKaJZSWGIynlqL75g8w;Path=/;Domain=.salesforce.com;Expires=Tue,
69
+ 04-Aug-2015 20:25:21 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/<api_version>/sobjects/CustomObject__c/a001a000001c8amAAA"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001c8amAAA","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Fri, 05 Jun 2015 20:25:21 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/<api_version>/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001c8amAAA%27
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:22 GMT
107
+ Set-Cookie:
108
+ - BrowserId=kXFjdyBMQqCtOcPfbobm0g;Path=/;Domain=.salesforce.com;Expires=Tue,
109
+ 04-Aug-2015 20:25:22 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/<api_version>/sobjects/CustomObject__c/a001a000001c8amAAA"},"Id":"a001a000001c8amAAA","SystemModstamp":"2015-06-05T20:25:21.000+0000","Name":"Custom
121
+ object","Example_Field__c":"Some sample text"}]}'
122
+ http_version:
123
+ recorded_at: Fri, 05 Jun 2015 20:25:22 GMT
124
+ - request:
125
+ method: get
126
+ uri: https://<host>/services/data/<api_version>/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001c8amAAA%27
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
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
+ - Fri, 05 Jun 2015 20:25:23 GMT
146
+ Set-Cookie:
147
+ - BrowserId=GOzB5Yp2RQOKO5AakuKbng;Path=/;Domain=.salesforce.com;Expires=Tue,
148
+ 04-Aug-2015 20:25:23 GMT
149
+ Expires:
150
+ - Thu, 01 Jan 1970 00:00:00 GMT
151
+ Sforce-Limit-Info:
152
+ - api-usage=6/15000
153
+ Content-Type:
154
+ - application/json;charset=UTF-8
155
+ Transfer-Encoding:
156
+ - chunked
157
+ body:
158
+ encoding: ASCII-8BIT
159
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/<api_version>/sobjects/CustomObject__c/a001a000001c8amAAA"},"Id":"a001a000001c8amAAA","SystemModstamp":"2015-06-05T20:25:21.000+0000","Name":"Custom
160
+ object","Example_Field__c":"Some sample text"}]}'
161
+ http_version:
162
+ recorded_at: Fri, 05 Jun 2015 20:25:23 GMT
163
+ - request:
164
+ method: get
165
+ uri: https://<host>/services/data/<api_version>/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001c8amAAA%27
166
+ body:
167
+ encoding: US-ASCII
168
+ string: ''
169
+ headers:
170
+ User-Agent:
171
+ - Faraday v0.9.1
172
+ Authorization:
173
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
174
+ Accept-Encoding:
175
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
176
+ Accept:
177
+ - "*/*"
178
+ response:
179
+ status:
180
+ code: 200
181
+ message: OK
182
+ headers:
183
+ Date:
184
+ - Fri, 05 Jun 2015 20:25:24 GMT
185
+ Set-Cookie:
186
+ - BrowserId=fpDWWW5iRZ26VWwJw39FPg;Path=/;Domain=.salesforce.com;Expires=Tue,
187
+ 04-Aug-2015 20:25:24 GMT
188
+ Expires:
189
+ - Thu, 01 Jan 1970 00:00:00 GMT
190
+ Sforce-Limit-Info:
191
+ - api-usage=5/15000
192
+ Content-Type:
193
+ - application/json;charset=UTF-8
194
+ Transfer-Encoding:
195
+ - chunked
196
+ body:
197
+ encoding: ASCII-8BIT
198
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/<api_version>/sobjects/CustomObject__c/a001a000001c8amAAA"},"Id":"a001a000001c8amAAA","SystemModstamp":"2015-06-05T20:25:21.000+0000","Name":"Custom
199
+ object","Example_Field__c":"Some sample text"}]}'
200
+ http_version:
201
+ recorded_at: Fri, 05 Jun 2015 20:25:24 GMT
202
+ - request:
203
+ method: delete
204
+ uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a000001c8amAAA
205
+ body:
206
+ encoding: US-ASCII
207
+ string: ''
208
+ headers:
209
+ User-Agent:
210
+ - Faraday v0.9.1
211
+ Authorization:
212
+ - OAuth 00D1a000000H3O9!AQ4AQLdODWB6P_wMhlnykddo4HxmtCuVAVPgx9sgecmdoTNEs7010v3G1F8nbgWFQ_XozpNmW0nYAaVNlcbYhEEoEDBwHPmE
213
+ Accept-Encoding:
214
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
215
+ Accept:
216
+ - "*/*"
217
+ response:
218
+ status:
219
+ code: 204
220
+ message: No Content
221
+ headers:
222
+ Date:
223
+ - Fri, 05 Jun 2015 20:25:24 GMT
224
+ Set-Cookie:
225
+ - BrowserId=UXTZHmJ4Q7eeBuTTDakbOQ;Path=/;Domain=.salesforce.com;Expires=Tue,
226
+ 04-Aug-2015 20:25:24 GMT
227
+ Expires:
228
+ - Thu, 01 Jan 1970 00:00:00 GMT
229
+ Sforce-Limit-Info:
230
+ - api-usage=5/15000
231
+ body:
232
+ encoding: UTF-8
233
+ string: ''
234
+ http_version:
235
+ recorded_at: Fri, 05 Jun 2015 20:25:25 GMT
236
+ recorded_with: VCR 2.9.3
@@ -96,4 +96,25 @@ describe Restforce::DB::Accumulator do
96
96
  expect(accumulator).to_not_be :changed?, yottle: "Bottle"
97
97
  end
98
98
  end
99
+
100
+ describe "#up_to_date_for?" do
101
+ let(:timestamp) { Time.now }
102
+
103
+ before do
104
+ accumulator.store(timestamp, some: "set", of: "attributes")
105
+ end
106
+
107
+ it "returns true if the passed timestamp is less recent than the stored time" do
108
+ expect(accumulator).to_be :up_to_date_for?, timestamp - 1
109
+ end
110
+
111
+ it "returns true if the passed timestamp is identical to the stored time" do
112
+ expect(accumulator).to_be :up_to_date_for?, timestamp
113
+ end
114
+
115
+ it "returns false if the passed timestamp is more recent than the stored time" do
116
+ expect(accumulator).to_not_be :up_to_date_for?, timestamp + 1
117
+ end
118
+ end
119
+
99
120
  end
@@ -9,6 +9,9 @@ describe Restforce::DB::Configuration do
9
9
  let(:configuration) { Restforce::DB::Configuration.new }
10
10
 
11
11
  describe "#before" do
12
+ after do
13
+ Thread.current[:before_hook] = nil
14
+ end
12
15
 
13
16
  it "does nothing if invoked without a block" do
14
17
  # NOTE: We're asserting that this invocation doesn't raise an error.
@@ -15,6 +15,7 @@ describe Restforce::DB::Synchronizer do
15
15
  }
16
16
  end
17
17
  let(:salesforce_id) { Salesforce.create!(salesforce_model, attributes) }
18
+ let(:timestamp) { Time.now }
18
19
  let(:changes) { { [salesforce_id, salesforce_model] => accumulator } }
19
20
  let(:new_attributes) do
20
21
  {
@@ -24,7 +25,7 @@ describe Restforce::DB::Synchronizer do
24
25
  end
25
26
  let(:accumulator) do
26
27
  Restforce::DB::Accumulator.new.tap do |accumulator|
27
- accumulator.store(Time.now, new_attributes)
28
+ accumulator.store(timestamp, new_attributes)
28
29
  end
29
30
  end
30
31
 
@@ -70,7 +71,29 @@ describe Restforce::DB::Synchronizer do
70
71
  expect(record.Name).to_equal new_attributes["Name"]
71
72
  expect(record.Example_Field__c).to_equal new_attributes["Example_Field__c"]
72
73
  end
74
+
75
+ describe "when the change timestamp is stale" do
76
+ let(:timestamp) do
77
+ mapping.salesforce_record_type.find(salesforce_id).last_update - 1
78
+ end
79
+
80
+ it "does not update the database record" do
81
+ record = database_record.reload
82
+
83
+ expect(record.name).to_equal database_attributes[:name]
84
+ expect(record.example).to_equal database_attributes[:example]
85
+ end
86
+
87
+ it "does not update the salesforce record" do
88
+ record = mapping.salesforce_record_type.find(salesforce_id).record
89
+
90
+ expect(record.Name).to_equal attributes["Name"]
91
+ expect(record.Example_Field__c).to_equal attributes["Example_Field__c"]
92
+ end
93
+ end
94
+
73
95
  end
74
96
 
75
97
  end
98
+
76
99
  end
@@ -5,6 +5,7 @@ ActiveRecord::Base.establish_connection(
5
5
  adapter: "sqlite3",
6
6
  database: ":memory:",
7
7
  )
8
+ ActiveSupport::TestCase.test_order = :random
8
9
 
9
10
  ActiveRecord::Schema.define do
10
11
 
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: 2.2.1
4
+ version: 2.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-06-03 00:00:00.000000000 Z
11
+ date: 2015-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -306,6 +306,8 @@ files:
306
306
  - test/cassettes/Restforce_DB_Strategies_Associated/_build_/given_an_inverse_mapping/with_no_synchronized_association_record/does_not_want_to_build_a_new_record.yml
307
307
  - test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/updates_the_database_record.yml
308
308
  - test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/updates_the_salesforce_record.yml
309
+ - test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/when_the_change_timestamp_is_stale/does_not_update_the_database_record.yml
310
+ - test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_associated_database_record/when_the_change_timestamp_is_stale/does_not_update_the_salesforce_record.yml
309
311
  - test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_no_associated_database_record/does_nothing_for_this_specific_mapping.yml
310
312
  - test/lib/restforce/db/accumulator_test.rb
311
313
  - test/lib/restforce/db/adapter_test.rb