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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66066f14c2a63bbba0e2e92314c1841447a8bb58
4
- data.tar.gz: 0188ff2c949728a8c47f4305b14ea57bc4324f71
3
+ metadata.gz: 5ea7146536605fd074a1b198f20611f6c8eefe00
4
+ data.tar.gz: 9cf11bd4251a79f891cecb27dc8ae25c1c3b74ef
5
5
  SHA512:
6
- metadata.gz: 31776fad63147b4f3d8931930679c5665c2141cd61b78e5b21a0d91403fdcb7df3207e8237c49594501fc6cb6b96cb1acbb60519f21e384f1fd888376c92d6b7
7
- data.tar.gz: ef1ffb3e25b322aabf3fa2d3972baa9e5589f09c9f2721e888eb935bc3fca601c89d15c23b4b88f43a88338b52138d29aaacbcae23539b86ba77327b27523437
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 = {}
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Salesforce
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -48,3 +48,4 @@ Migrating to InstallOpenStaxSalesforce (0)
48
48
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
49
49
  ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
50
50
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
51
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky