restforce-db 3.1.4 → 3.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54adddb1c2bfbeb30e483647871635c25c699ac9
4
- data.tar.gz: c0c9d14b7f758b0c2347a304a92d7e797317c682
3
+ metadata.gz: d28f5b9de2ee661484f34ea9bcbb6da3cba7b7b8
4
+ data.tar.gz: a40633b212013d5044299083938956feaa8fc184
5
5
  SHA512:
6
- metadata.gz: 63f141e17b73c5bb41f950610cc133e940da5df78ecfc526503e36b5ebe7d6238897af608d16e4b40a38a7fb7fa47f973f7aa58255105f413c42197433541842
7
- data.tar.gz: 2f0f3d913be6828ac706e8b3805693118a4df5aaa462e0bc94ef0d88e2c254dff43ec8708cbdd059bbb5b2265340ba4c28ec15a968aafb5fdcbdceb6496950cc
6
+ metadata.gz: 0bb2a407ff93ccf23c9761bcfcb4a0998c852f57b99cb48b9793cdf37d7ab51a62694b2cd852a6180d129e2771a391cb27aa3fe919ddd95f289a125886642008
7
+ data.tar.gz: 6a25b37b9fad62442841cd1943cab5f412e4b0ff40f678b9478c4af208a78ced68fb2d1743063e4ff022568f14b0430ce74ec5fe92578f7221393109d503b4a4
@@ -66,7 +66,7 @@ module Restforce
66
66
  # for what is actually a one-to-many association on the
67
67
  # ActiveRecord object, so we always treat the result as an Array.
68
68
  associated = Array(database_record.association(name).reader)
69
- ids[lookup] = associated.empty? ? nil : associated.first.send(mapping.lookup_column)
69
+ ids[lookup] = associated.first.send(mapping.lookup_column) unless associated.empty?
70
70
  end
71
71
 
72
72
  ids
@@ -95,12 +95,13 @@ module Restforce
95
95
  end
96
96
 
97
97
  # Internal: Get a list of the BelongsTo associations defined for the
98
- # target mapping.
98
+ # target mapping. Ignores associations where the foreign key is Id, as
99
+ # a record's Id will never change.
99
100
  #
100
101
  # Returns an Array of Restforce::DB::Association::BelongsTo objects.
101
102
  def belongs_to_associations
102
103
  @belongs_to_associations ||= @mapping.associations.select do |association|
103
- association.is_a?(Restforce::DB::Associations::BelongsTo)
104
+ association.is_a?(Restforce::DB::Associations::BelongsTo) && association.lookup != "Id"
104
105
  end
105
106
  end
106
107
 
@@ -33,6 +33,8 @@ module Restforce
33
33
  return unless @mapping.strategy.build?(instance)
34
34
 
35
35
  created = @mapping.database_record_type.create!(instance)
36
+
37
+ @runner.cache_timestamp instance
36
38
  @runner.cache_timestamp created
37
39
  rescue ActiveRecord::ActiveRecordError => e
38
40
  DB.logger.error(SynchronizationError.new(e, instance))
@@ -49,6 +51,8 @@ module Restforce
49
51
  return if instance.synced?
50
52
 
51
53
  created = @mapping.salesforce_record_type.create!(instance)
54
+
55
+ @runner.cache_timestamp instance
52
56
  @runner.cache_timestamp created
53
57
  rescue Faraday::Error::ClientError => e
54
58
  DB.logger.error(SynchronizationError.new(e, instance))
@@ -3,7 +3,7 @@ module Restforce
3
3
  # :nodoc:
4
4
  module DB
5
5
 
6
- VERSION = "3.1.4"
6
+ VERSION = "3.1.5"
7
7
 
8
8
  end
9
9
 
@@ -75,12 +75,12 @@ module Restforce
75
75
  run("ATTACHING RECORDS", Attacher, mapping)
76
76
  run("PROPAGATING RECORDS", Initializer, mapping)
77
77
  run("COLLECTING CHANGES", Collector, mapping)
78
- run("UPDATING ASSOCIATIONS", Associator, mapping)
79
78
  end
80
79
 
81
80
  # NOTE: We can only perform the synchronization after all record
82
81
  # changes have been aggregated, so this second loop is necessary.
83
82
  Restforce::DB::Registry.each do |mapping|
83
+ run("UPDATING ASSOCIATIONS", Associator, mapping)
84
84
  run("APPLYING CHANGES", Synchronizer, mapping)
85
85
  end
86
86
  end
@@ -21,10 +21,10 @@ http_interactions:
21
21
  message: OK
22
22
  headers:
23
23
  Date:
24
- - Thu, 25 Jun 2015 21:55:07 GMT
24
+ - Wed, 01 Jul 2015 22:21:59 GMT
25
25
  Set-Cookie:
26
- - BrowserId=c3tk_yLaSbugLEy7ZHfN0g;Path=/;Domain=.salesforce.com;Expires=Mon,
27
- 24-Aug-2015 21:55:07 GMT
26
+ - BrowserId=pSV4lvHNQnW2bmTjXxurMA;Path=/;Domain=.salesforce.com;Expires=Sun,
27
+ 30-Aug-2015 22:21:59 GMT
28
28
  Expires:
29
29
  - Thu, 01 Jan 1970 00:00:00 GMT
30
30
  Pragma:
@@ -37,9 +37,9 @@ 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":"1435269308063","token_type":"Bearer","instance_url":"https://<host>","signature":"oz5BIcQcl/oR4S8ti3lhZy2nj0bQilvb2m6YFaVBFbE=","access_token":"00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA"}'
40
+ string: '{"id":"https://login.salesforce.com/id/00D1a000000H3O9EAK/0051a000000UGT8AAO","issued_at":"1435789319584","token_type":"Bearer","instance_url":"https://<host>","signature":"IR8FX61zjomHUYcHXhnxA8c2OlpArSm/29OXS6TXI5A=","access_token":"00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g"}'
41
41
  http_version:
42
- recorded_at: Thu, 25 Jun 2015 21:55:08 GMT
42
+ recorded_at: Wed, 01 Jul 2015 22:21:59 GMT
43
43
  - request:
44
44
  method: post
45
45
  uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c
@@ -52,7 +52,7 @@ http_interactions:
52
52
  Content-Type:
53
53
  - application/json
54
54
  Authorization:
55
- - OAuth 00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA
55
+ - OAuth 00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g
56
56
  Accept-Encoding:
57
57
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
58
58
  Accept:
@@ -63,28 +63,28 @@ http_interactions:
63
63
  message: Created
64
64
  headers:
65
65
  Date:
66
- - Thu, 25 Jun 2015 21:55:08 GMT
66
+ - Wed, 01 Jul 2015 22:22:00 GMT
67
67
  Set-Cookie:
68
- - BrowserId=KMcbDqlmQlqnUw8JfdRg8g;Path=/;Domain=.salesforce.com;Expires=Mon,
69
- 24-Aug-2015 21:55:08 GMT
68
+ - BrowserId=U6tImumuReGJF-zS-Ebehg;Path=/;Domain=.salesforce.com;Expires=Sun,
69
+ 30-Aug-2015 22:22:00 GMT
70
70
  Expires:
71
71
  - Thu, 01 Jan 1970 00:00:00 GMT
72
72
  Sforce-Limit-Info:
73
- - api-usage=190/15000
73
+ - api-usage=7/15000
74
74
  Location:
75
- - "/services/data/<api_version>/sobjects/CustomObject__c/a001a000002zhXoAAI"
75
+ - "/services/data/<api_version>/sobjects/CustomObject__c/a001a00000309IXAAY"
76
76
  Content-Type:
77
77
  - application/json;charset=UTF-8
78
78
  Transfer-Encoding:
79
79
  - chunked
80
80
  body:
81
81
  encoding: ASCII-8BIT
82
- string: '{"id":"a001a000002zhXoAAI","success":true,"errors":[]}'
82
+ string: '{"id":"a001a00000309IXAAY","success":true,"errors":[]}'
83
83
  http_version:
84
- recorded_at: Thu, 25 Jun 2015 21:55:08 GMT
84
+ recorded_at: Wed, 01 Jul 2015 22:22:00 GMT
85
85
  - request:
86
86
  method: delete
87
- uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a000002zhXoAAI
87
+ uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a00000309IXAAY
88
88
  body:
89
89
  encoding: US-ASCII
90
90
  string: ''
@@ -92,7 +92,7 @@ http_interactions:
92
92
  User-Agent:
93
93
  - Faraday v0.9.1
94
94
  Authorization:
95
- - OAuth 00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA
95
+ - OAuth 00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g
96
96
  Accept-Encoding:
97
97
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
98
  Accept:
@@ -103,17 +103,17 @@ http_interactions:
103
103
  message: No Content
104
104
  headers:
105
105
  Date:
106
- - Thu, 25 Jun 2015 21:55:08 GMT
106
+ - Wed, 01 Jul 2015 22:22:01 GMT
107
107
  Set-Cookie:
108
- - BrowserId=1gCPQMOtTb2BQFtEeSfgAA;Path=/;Domain=.salesforce.com;Expires=Mon,
109
- 24-Aug-2015 21:55:08 GMT
108
+ - BrowserId=ExR5pJi2RHGsmv5WrGqJ6g;Path=/;Domain=.salesforce.com;Expires=Sun,
109
+ 30-Aug-2015 22:22:01 GMT
110
110
  Expires:
111
111
  - Thu, 01 Jan 1970 00:00:00 GMT
112
112
  Sforce-Limit-Info:
113
- - api-usage=204/15000
113
+ - api-usage=7/15000
114
114
  body:
115
115
  encoding: UTF-8
116
116
  string: ''
117
117
  http_version:
118
- recorded_at: Thu, 25 Jun 2015 21:55:09 GMT
118
+ recorded_at: Wed, 01 Jul 2015 22:22:01 GMT
119
119
  recorded_with: VCR 2.9.3
@@ -21,10 +21,10 @@ http_interactions:
21
21
  message: OK
22
22
  headers:
23
23
  Date:
24
- - Thu, 25 Jun 2015 21:54:59 GMT
24
+ - Wed, 01 Jul 2015 22:22:03 GMT
25
25
  Set-Cookie:
26
- - BrowserId=PiXgo3-8QbWuN06OMsqyEg;Path=/;Domain=.salesforce.com;Expires=Mon,
27
- 24-Aug-2015 21:54:59 GMT
26
+ - BrowserId=qGHLRZezTjOQaFra2D9NGg;Path=/;Domain=.salesforce.com;Expires=Sun,
27
+ 30-Aug-2015 22:22:03 GMT
28
28
  Expires:
29
29
  - Thu, 01 Jan 1970 00:00:00 GMT
30
30
  Pragma:
@@ -37,9 +37,9 @@ 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":"1435269299946","token_type":"Bearer","instance_url":"https://<host>","signature":"QBli7y/0oiV6hAslccEqjbViwiPNKNC2uh3fhx3hn3A=","access_token":"00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA"}'
40
+ string: '{"id":"https://login.salesforce.com/id/00D1a000000H3O9EAK/0051a000000UGT8AAO","issued_at":"1435789323964","token_type":"Bearer","instance_url":"https://<host>","signature":"vfN4LijqlTxjHAcDWDjrwczNUgVgtpNxMVcf6IT0H2Q=","access_token":"00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g"}'
41
41
  http_version:
42
- recorded_at: Thu, 25 Jun 2015 21:55:00 GMT
42
+ recorded_at: Wed, 01 Jul 2015 22:22:03 GMT
43
43
  - request:
44
44
  method: post
45
45
  uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c
@@ -52,7 +52,7 @@ http_interactions:
52
52
  Content-Type:
53
53
  - application/json
54
54
  Authorization:
55
- - OAuth 00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA
55
+ - OAuth 00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g
56
56
  Accept-Encoding:
57
57
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
58
58
  Accept:
@@ -63,28 +63,28 @@ http_interactions:
63
63
  message: Created
64
64
  headers:
65
65
  Date:
66
- - Thu, 25 Jun 2015 21:55:00 GMT
66
+ - Wed, 01 Jul 2015 22:22:04 GMT
67
67
  Set-Cookie:
68
- - BrowserId=iEzyEGpKQxeERiy08x91bg;Path=/;Domain=.salesforce.com;Expires=Mon,
69
- 24-Aug-2015 21:55:00 GMT
68
+ - BrowserId=bgHJK63LRWaIlTO2E2U0QA;Path=/;Domain=.salesforce.com;Expires=Sun,
69
+ 30-Aug-2015 22:22:04 GMT
70
70
  Expires:
71
71
  - Thu, 01 Jan 1970 00:00:00 GMT
72
72
  Sforce-Limit-Info:
73
- - api-usage=145/15000
73
+ - api-usage=8/15000
74
74
  Location:
75
- - "/services/data/<api_version>/sobjects/CustomObject__c/a001a000002zhZoAAI"
75
+ - "/services/data/<api_version>/sobjects/CustomObject__c/a001a00000309IcAAI"
76
76
  Content-Type:
77
77
  - application/json;charset=UTF-8
78
78
  Transfer-Encoding:
79
79
  - chunked
80
80
  body:
81
81
  encoding: ASCII-8BIT
82
- string: '{"id":"a001a000002zhZoAAI","success":true,"errors":[]}'
82
+ string: '{"id":"a001a00000309IcAAI","success":true,"errors":[]}'
83
83
  http_version:
84
- recorded_at: Thu, 25 Jun 2015 21:55:00 GMT
84
+ recorded_at: Wed, 01 Jul 2015 22:22:05 GMT
85
85
  - request:
86
86
  method: delete
87
- uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a000002zhZoAAI
87
+ uri: https://<host>/services/data/<api_version>/sobjects/CustomObject__c/a001a00000309IcAAI
88
88
  body:
89
89
  encoding: US-ASCII
90
90
  string: ''
@@ -92,7 +92,7 @@ http_interactions:
92
92
  User-Agent:
93
93
  - Faraday v0.9.1
94
94
  Authorization:
95
- - OAuth 00D1a000000H3O9!AQ4AQIEnz7RMa1N2z10U8y.cU3CAaZeOCxcDVSetug6psPcDYNjSbdC91y8MHqmZ.ZXE_zkQURv2YNCWYEsl0fcbZwb1MPEA
95
+ - OAuth 00D1a000000H3O9!AQ4AQKJZZLBvLm3vEyoa1I_FUwCVKJTQydGXcIOYHXeuNRsEB5WSOXQC2x.kIQ3wbc1V_KhljRRKg43aIkvmAoiG.a4Ll49g
96
96
  Accept-Encoding:
97
97
  - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
98
98
  Accept:
@@ -103,17 +103,17 @@ http_interactions:
103
103
  message: No Content
104
104
  headers:
105
105
  Date:
106
- - Thu, 25 Jun 2015 21:55:00 GMT
106
+ - Wed, 01 Jul 2015 22:22:06 GMT
107
107
  Set-Cookie:
108
- - BrowserId=HNcH22aHRrC_YIanhNh0dA;Path=/;Domain=.salesforce.com;Expires=Mon,
109
- 24-Aug-2015 21:55:00 GMT
108
+ - BrowserId=bEI3cWD_SaCpOD8wvl95jg;Path=/;Domain=.salesforce.com;Expires=Sun,
109
+ 30-Aug-2015 22:22:06 GMT
110
110
  Expires:
111
111
  - Thu, 01 Jan 1970 00:00:00 GMT
112
112
  Sforce-Limit-Info:
113
- - api-usage=146/15000
113
+ - api-usage=7/15000
114
114
  body:
115
115
  encoding: UTF-8
116
116
  string: ''
117
117
  http_version:
118
- recorded_at: Thu, 25 Jun 2015 21:55:01 GMT
118
+ recorded_at: Wed, 01 Jul 2015 22:22:06 GMT
119
119
  recorded_with: VCR 2.9.3
@@ -57,8 +57,8 @@ describe Restforce::DB::Associations::BelongsTo do
57
57
  let(:object_salesforce_id) { Salesforce.create!(mapping.salesforce_model) }
58
58
  let(:object) { mapping.database_model.create!(salesforce_id: object_salesforce_id) }
59
59
 
60
- it "returns a nil lookup value in the hash" do
61
- expect(association.lookups(object)).to_equal("Friend__c" => nil)
60
+ it "returns no value in the hash" do
61
+ expect(association.lookups(object)).to_be :empty?
62
62
  end
63
63
 
64
64
  describe "and the underlying association is one-to-many" do
@@ -73,8 +73,8 @@ describe Restforce::DB::Associations::BelongsTo do
73
73
  end
74
74
  end
75
75
 
76
- it "still returns a nil lookup value in the hash" do
77
- expect(association.lookups(object)).to_equal("Friend__c" => nil)
76
+ it "still returns no value in the hash" do
77
+ expect(association.lookups(object)).to_be :empty?
78
78
  end
79
79
  end
80
80
  end
@@ -39,6 +39,14 @@ describe Restforce::DB::Associator do
39
39
  mapping.associations << association
40
40
  end
41
41
 
42
+ describe "when the association lookup is through Id" do
43
+ let(:association) { Restforce::DB::Associations::BelongsTo.new(:user, through: "Id") }
44
+
45
+ it "ignores the association" do
46
+ expect(associator.send(:belongs_to_associations)).to_be :empty?
47
+ end
48
+ end
49
+
42
50
  describe "given another record for association" do
43
51
  let(:new_user_salesforce_id) do
44
52
  Salesforce.create!(
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: 3.1.4
4
+ version: 3.1.5
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-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -260,8 +260,8 @@ files:
260
260
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_the_association_is_non-building/proceeds_without_constructing_any_records.yml
261
261
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/with_an_unrelated_association_mapping/proceeds_without_raising_an_error.yml
262
262
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/returns_a_hash_of_the_associated_records_lookup_IDs.yml
263
- - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/when_there_is_currently_no_associated_record/and_the_underlying_association_is_one-to-many/still_returns_a_nil_lookup_value_in_the_hash.yml
264
- - 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
263
+ - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/when_there_is_currently_no_associated_record/and_the_underlying_association_is_one-to-many/still_returns_no_value_in_the_hash.yml
264
+ - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/when_there_is_currently_no_associated_record/returns_no_value_in_the_hash.yml
265
265
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
266
266
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
267
267
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/builds_a_number_of_associated_records_from_the_data_in_Salesforce.yml
@@ -391,7 +391,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
391
391
  version: '0'
392
392
  requirements: []
393
393
  rubyforge_project:
394
- rubygems_version: 2.4.6
394
+ rubygems_version: 2.4.5
395
395
  signing_key:
396
396
  specification_version: 4
397
397
  summary: Bind your database to Salesforce data