restforce-db 1.2.9 → 1.2.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/restforce/db/association_cache.rb +4 -1
  3. data/lib/restforce/db/associations/belongs_to.rb +27 -3
  4. data/lib/restforce/db/associations/has_many.rb +3 -3
  5. data/lib/restforce/db/associations/has_one.rb +2 -2
  6. data/lib/restforce/db/associator.rb +104 -0
  7. data/lib/restforce/db/cleaner.rb +3 -15
  8. data/lib/restforce/db/collector.rb +2 -4
  9. data/lib/restforce/db/initializer.rb +10 -10
  10. data/lib/restforce/db/record_types/active_record.rb +6 -7
  11. data/lib/restforce/db/record_types/base.rb +0 -2
  12. data/lib/restforce/db/record_types/salesforce.rb +6 -6
  13. data/lib/restforce/db/runner.rb +8 -8
  14. data/lib/restforce/db/runner_cache.rb +93 -0
  15. data/lib/restforce/db/version.rb +1 -1
  16. data/lib/restforce/db/worker.rb +23 -9
  17. data/lib/restforce/db.rb +2 -0
  18. data/restforce-db.gemspec +3 -3
  19. data/test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/returns_a_hash_of_the_associated_records_lookup_IDs.yml +195 -0
  20. data/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 +119 -0
  21. data/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 +421 -0
  22. data/test/cassettes/Restforce_DB_Associator/_run/given_a_BelongsTo_association/given_another_record_for_association/when_the_database_association_is_out_of_date/updates_the_associated_record_in_the_database.yml +459 -0
  23. data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/{_each/loops_through_the_existing_records_in_Salesforce.yml → _all/returns_a_list_of_the_existing_records_in_Salesforce.yml} +0 -0
  24. data/test/lib/restforce/db/accumulator_test.rb +3 -0
  25. data/test/lib/restforce/db/association_cache_test.rb +8 -0
  26. data/test/lib/restforce/db/associations/belongs_to_test.rb +18 -0
  27. data/test/lib/restforce/db/associator_test.rb +82 -0
  28. data/test/lib/restforce/db/configuration_test.rb +3 -0
  29. data/test/lib/restforce/db/dsl_test.rb +2 -0
  30. data/test/lib/restforce/db/record_types/salesforce_test.rb +3 -5
  31. data/test/lib/restforce/db/runner_cache_test.rb +60 -0
  32. data/test/lib/restforce/db/runner_test.rb +3 -0
  33. data/test/lib/restforce/db/strategies/passive_test.rb +3 -0
  34. data/test/lib/restforce/db/strategy_test.rb +2 -0
  35. data/test/lib/restforce/db/tracker_test.rb +3 -0
  36. data/test/support/stub.rb +37 -0
  37. metadata +18 -9
@@ -1,6 +1,9 @@
1
1
  require_relative "../../../test_helper"
2
2
 
3
3
  describe Restforce::DB::Runner do
4
+
5
+ configure!
6
+
4
7
  let(:runner) { Restforce::DB::Runner.new }
5
8
 
6
9
  describe "#initialize" do
@@ -1,6 +1,9 @@
1
1
  require_relative "../../../../test_helper"
2
2
 
3
3
  describe Restforce::DB::Strategies::Passive do
4
+
5
+ configure!
6
+
4
7
  let(:strategy) { Restforce::DB::Strategies::Passive.new }
5
8
 
6
9
  it "is a passive strategy" do
@@ -2,6 +2,8 @@ require_relative "../../../test_helper"
2
2
 
3
3
  describe Restforce::DB::Strategy do
4
4
 
5
+ configure!
6
+
5
7
  describe ".for" do
6
8
  let(:strategy) { Restforce::DB::Strategy.for(type) }
7
9
 
@@ -1,6 +1,9 @@
1
1
  require_relative "../../../test_helper"
2
2
 
3
3
  describe Restforce::DB::Tracker do
4
+
5
+ configure!
6
+
4
7
  let(:file) { Tempfile.new(".restforce-db") }
5
8
  let(:tracker) { Restforce::DB::Tracker.new(file.path) }
6
9
  let(:runtime) { Time.now }
@@ -0,0 +1,37 @@
1
+ # Extend all objects with `#stub_any_instance`. Implementation taken from:
2
+ # https://github.com/codeodor/minitest-stub_any_instance
3
+ class Object
4
+
5
+ # Public: Stub the specified method for any instance of the passed class
6
+ # within the context of a block.
7
+ #
8
+ # name - A String or Symbol method name.
9
+ # val_or_callable - The value which the stubbed method should return.
10
+ # block - A block of code to execute in this context.
11
+ #
12
+ # Returns nothing.
13
+ def self.stub_any_instance(name, val_or_callable)
14
+ new_name = "__minitest_any_instance_stub__#{name}"
15
+
16
+ class_eval do
17
+ alias_method new_name, name
18
+
19
+ define_method(name) do |*args|
20
+ if val_or_callable.respond_to?(:call)
21
+ instance_exec(*args, &val_or_callable)
22
+ else
23
+ val_or_callable
24
+ end
25
+ end
26
+ end
27
+
28
+ yield
29
+ ensure
30
+ class_eval do
31
+ undef_method name
32
+ alias_method name, new_name
33
+ undef_method new_name
34
+ end
35
+ end
36
+
37
+ end
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.9
4
+ version: 1.2.10
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-04 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: minitest
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - '='
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 5.5.1
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - '='
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 5.5.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: minitest-spec-expect
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 0.30.0
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 0.30.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: sqlite3
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -214,6 +214,7 @@ files:
214
214
  - lib/restforce/db/associations/foreign_key.rb
215
215
  - lib/restforce/db/associations/has_many.rb
216
216
  - lib/restforce/db/associations/has_one.rb
217
+ - lib/restforce/db/associator.rb
217
218
  - lib/restforce/db/attribute_map.rb
218
219
  - lib/restforce/db/cleaner.rb
219
220
  - lib/restforce/db/collector.rb
@@ -232,6 +233,7 @@ files:
232
233
  - lib/restforce/db/record_types/salesforce.rb
233
234
  - lib/restforce/db/registry.rb
234
235
  - lib/restforce/db/runner.rb
236
+ - lib/restforce/db/runner_cache.rb
235
237
  - lib/restforce/db/strategies/always.rb
236
238
  - lib/restforce/db/strategies/associated.rb
237
239
  - lib/restforce/db/strategies/passive.rb
@@ -249,6 +251,8 @@ files:
249
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
250
252
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/when_the_associated_record_has_been_cached/uses_the_cached_record.yml
251
253
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_build/with_an_unrelated_association_mapping/proceeds_without_raising_an_error.yml
254
+ - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_lookups/returns_a_hash_of_the_associated_records_lookup_IDs.yml
255
+ - 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
252
256
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
253
257
  - test/cassettes/Restforce_DB_Associations_BelongsTo/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
254
258
  - test/cassettes/Restforce_DB_Associations_HasMany/with_an_inverse_mapping/_build/builds_a_number_of_associated_records_from_the_data_in_Salesforce.yml
@@ -264,6 +268,8 @@ files:
264
268
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_build/when_the_associated_record_has_been_cached/uses_the_cached_record.yml
265
269
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_a_matching_associated_record_has_been_synchronized/returns_true.yml
266
270
  - test/cassettes/Restforce_DB_Associations_HasOne/with_an_inverse_mapping/_synced_for_/when_no_matching_associated_record_has_been_synchronized/returns_false.yml
271
+ - 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
272
+ - test/cassettes/Restforce_DB_Associator/_run/given_a_BelongsTo_association/given_another_record_for_association/when_the_database_association_is_out_of_date/updates_the_associated_record_in_the_database.yml
267
273
  - test/cassettes/Restforce_DB_Cleaner/_run/given_a_synchronized_Salesforce_record/when_the_record_does_not_meet_the_mapping_conditions/for_a_non-Passive_strategy/drops_the_synchronized_database_record.yml
268
274
  - test/cassettes/Restforce_DB_Cleaner/_run/given_a_synchronized_Salesforce_record/when_the_record_meets_the_mapping_conditions/does_not_drop_the_synchronized_database_record.yml
269
275
  - test/cassettes/Restforce_DB_Collector/_run/given_a_Salesforce_record_with_an_associated_database_record/returns_the_attributes_from_both_records.yml
@@ -277,9 +283,9 @@ files:
277
283
  - test/cassettes/Restforce_DB_Instances_Salesforce/_synced_/when_no_matching_database_record_exists/returns_false.yml
278
284
  - test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_local_record_with_the_passed_attributes.yml
279
285
  - test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_record_in_Salesforce_with_the_passed_attributes.yml
286
+ - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_all/returns_a_list_of_the_existing_records_in_Salesforce.yml
280
287
  - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/creates_a_record_in_Salesforce_from_the_passed_database_record_s_attributes.yml
281
288
  - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/updates_the_database_record_with_the_Salesforce_record_s_ID.yml
282
- - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_each/loops_through_the_existing_records_in_Salesforce.yml
283
289
  - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/finds_existing_records_in_Salesforce.yml
284
290
  - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/given_a_set_of_mapping_conditions/when_a_record_does_not_meet_the_conditions/does_not_find_the_record.yml
285
291
  - test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/given_a_set_of_mapping_conditions/when_a_record_meets_the_conditions/finds_the_record.yml
@@ -297,6 +303,7 @@ files:
297
303
  - test/lib/restforce/db/associations/belongs_to_test.rb
298
304
  - test/lib/restforce/db/associations/has_many_test.rb
299
305
  - test/lib/restforce/db/associations/has_one_test.rb
306
+ - test/lib/restforce/db/associator_test.rb
300
307
  - test/lib/restforce/db/attribute_map_test.rb
301
308
  - test/lib/restforce/db/cleaner_test.rb
302
309
  - test/lib/restforce/db/collector_test.rb
@@ -310,6 +317,7 @@ files:
310
317
  - test/lib/restforce/db/record_types/active_record_test.rb
311
318
  - test/lib/restforce/db/record_types/salesforce_test.rb
312
319
  - test/lib/restforce/db/registry_test.rb
320
+ - test/lib/restforce/db/runner_cache_test.rb
313
321
  - test/lib/restforce/db/runner_test.rb
314
322
  - test/lib/restforce/db/strategies/always_test.rb
315
323
  - test/lib/restforce/db/strategies/associated_test.rb
@@ -322,6 +330,7 @@ files:
322
330
  - test/support/database_cleaner.rb
323
331
  - test/support/matchers.rb
324
332
  - test/support/salesforce.rb
333
+ - test/support/stub.rb
325
334
  - test/support/utilities.rb
326
335
  - test/support/vcr.rb
327
336
  - test/test_helper.rb