openstax_salesforce 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/openstax/salesforce/spec_helpers.rb +26 -0
- data/lib/openstax/salesforce/version.rb +1 -1
- data/spec/dummy/log/test.log +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ea7146536605fd074a1b198f20611f6c8eefe00
|
4
|
+
data.tar.gz: 9cf11bd4251a79f891cecb27dc8ae25c1c3b74ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0f010bd7c10648d4670077c76d9a3464fdb40622c47ed2c647dafc69765af2a6f355a135ee27a8771bb7df873bd632b6a022784cde0c380f25e4a66795e500a
|
7
|
+
data.tar.gz: f18947489da830d79e65914e0e2b4d170bd0071e8a3adc2f3f90c7864194aa45e5c31eb4bef0106056089f95f8dc1dd1a152725dbf545e3999712165084b8dd4
|
@@ -25,6 +25,32 @@ module OpenStax::Salesforce::SpecHelpers
|
|
25
25
|
OpenStax::Salesforce::User.destroy_all
|
26
26
|
end
|
27
27
|
|
28
|
+
# Uses knowledge of how `SalesforceProxy` methods create new SF records using its
|
29
|
+
# `unique_token` to create the conditions you'd otherwise have to manually set
|
30
|
+
# when calling `limit_salesforce_queries`.
|
31
|
+
#
|
32
|
+
def limit_salesforce_queries_by_token(remote_class, token)
|
33
|
+
case remote_class.new
|
34
|
+
when OpenStax::Salesforce::Remote::Contact, OpenStax::Salesforce::Remote::Lead
|
35
|
+
limit_salesforce_queries(remote_class, last_name: "%#{token}")
|
36
|
+
else
|
37
|
+
raise "Don't know how to apply to #{remote_class}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Often, when dealing with Salesforce sandboxes, there are a bunch of other records
|
42
|
+
# in the sandbox that you'd rather your specs ignore. This method makes SF queries
|
43
|
+
# in your specs have additional `where` clauses to limit what is returned. If you
|
44
|
+
# are careful how you create the records you are testing against, you can use this
|
45
|
+
# method to only consider those records. E.g. when creating a contact, if you make
|
46
|
+
# each of the last names end with "_foobar", then by saying:
|
47
|
+
#
|
48
|
+
# limit_salesforce_queries(OpenStax::Salesforce::Remote::Contact, last_name: "%_foobar")
|
49
|
+
#
|
50
|
+
# your Contact queries will only return the one you made with the last name ending
|
51
|
+
# in "_foobar". The methods in SalesforceProxy that help you make SF records
|
52
|
+
# use the `unique_token` in this way (set via `reset_unique_token`).
|
53
|
+
#
|
28
54
|
def limit_salesforce_queries(remote_class, **conditions)
|
29
55
|
allow(remote_class).to receive(:query) do
|
30
56
|
like_conditions = {}
|
data/spec/dummy/log/test.log
CHANGED
@@ -48,3 +48,4 @@ Migrating to InstallOpenStaxSalesforce (0)
|
|
48
48
|
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
49
49
|
[1m[36mActiveRecord::SchemaMigration Load (0.2ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
50
50
|
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|
51
|
+
[1m[36mActiveRecord::SchemaMigration Load (0.1ms)[0m [1mSELECT "schema_migrations".* FROM "schema_migrations"[0m
|