restforce-db 0.1.4

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.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rubocop/custom/method_documentation.rb +65 -0
  4. data/.rubocop.yml +39 -0
  5. data/.travis.yml +3 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +68 -0
  9. data/Rakefile +13 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +7 -0
  12. data/lib/generators/restforce_generator.rb +19 -0
  13. data/lib/generators/templates/config.yml +8 -0
  14. data/lib/generators/templates/script +6 -0
  15. data/lib/restforce/db/command.rb +98 -0
  16. data/lib/restforce/db/configuration.rb +50 -0
  17. data/lib/restforce/db/instances/active_record.rb +48 -0
  18. data/lib/restforce/db/instances/base.rb +66 -0
  19. data/lib/restforce/db/instances/salesforce.rb +46 -0
  20. data/lib/restforce/db/mapping.rb +106 -0
  21. data/lib/restforce/db/model.rb +50 -0
  22. data/lib/restforce/db/record_type.rb +77 -0
  23. data/lib/restforce/db/record_types/active_record.rb +80 -0
  24. data/lib/restforce/db/record_types/base.rb +44 -0
  25. data/lib/restforce/db/record_types/salesforce.rb +94 -0
  26. data/lib/restforce/db/synchronizer.rb +57 -0
  27. data/lib/restforce/db/version.rb +10 -0
  28. data/lib/restforce/db/worker.rb +156 -0
  29. data/lib/restforce/db.rb +77 -0
  30. data/lib/restforce/extensions.rb +19 -0
  31. data/restforce-db.gemspec +41 -0
  32. data/test/cassettes/Restforce_DB/accessing_Salesforce/uses_the_configured_credentials.yml +43 -0
  33. data/test/cassettes/Restforce_DB_Instances_Salesforce/_copy_/updates_the_record_with_the_attributes_from_the_copied_object.yml +193 -0
  34. data/test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_local_record_with_the_passed_attributes.yml +193 -0
  35. data/test/cassettes/Restforce_DB_Instances_Salesforce/_update_/updates_the_record_in_Salesforce_with_the_passed_attributes.yml +232 -0
  36. data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/creates_a_record_in_Salesforce_from_the_passed_database_record_s_attributes.yml +158 -0
  37. data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_create_/updates_the_database_record_with_the_Salesforce_record_s_ID.yml +158 -0
  38. data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/finds_existing_records_in_Salesforce.yml +157 -0
  39. data/test/cassettes/Restforce_DB_RecordTypes_Salesforce/_find/returns_nil_when_no_matching_record_exists.yml +81 -0
  40. data/test/cassettes/Restforce_DB_Synchronizer/_run/given_a_Salesforce_record_with_an_existing_record_in_the_database/updates_the_database_record.yml +158 -0
  41. data/test/cassettes/Restforce_DB_Synchronizer/_run/given_an_existing_Salesforce_record/populates_the_database_with_the_new_record.yml +158 -0
  42. data/test/cassettes/Restforce_DB_Synchronizer/_run/given_an_existing_database_record/populates_Salesforce_with_the_new_record.yml +235 -0
  43. data/test/lib/restforce/db/configuration_test.rb +38 -0
  44. data/test/lib/restforce/db/instances/active_record_test.rb +39 -0
  45. data/test/lib/restforce/db/instances/salesforce_test.rb +51 -0
  46. data/test/lib/restforce/db/mapping_test.rb +70 -0
  47. data/test/lib/restforce/db/model_test.rb +48 -0
  48. data/test/lib/restforce/db/record_type_test.rb +26 -0
  49. data/test/lib/restforce/db/record_types/active_record_test.rb +85 -0
  50. data/test/lib/restforce/db/record_types/salesforce_test.rb +46 -0
  51. data/test/lib/restforce/db/synchronizer_test.rb +84 -0
  52. data/test/lib/restforce/db_test.rb +24 -0
  53. data/test/support/active_record.rb +20 -0
  54. data/test/support/database_cleaner.rb +3 -0
  55. data/test/support/salesforce.rb +48 -0
  56. data/test/support/vcr.rb +23 -0
  57. data/test/test_helper.rb +25 -0
  58. metadata +287 -0
@@ -0,0 +1,81 @@
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
+ - Wed, 18 Mar 2015 20:28:30 GMT
25
+ Set-Cookie:
26
+ - BrowserId=JHoLVba8RM6Dit7E94W1HQ;Path=/;Domain=.salesforce.com;Expires=Sun,
27
+ 17-May-2015 20:28:30 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":"1426710510270","token_type":"Bearer","instance_url":"https://<host>","signature":"ro5eVPPM6RAt+azw5aNuTjRwtu+JTZ2EYLbxi23u16c=","access_token":"00D1a000000H3O9!AQ4AQBPYB1dtKrLqKFY0OHPXkpY2WSuWV3emXMOLv6.4pyhpMQ0liAbd0z2To0vRk4VoArPod87jkJCAza2a_.92y4ZpZ_4m"}'
41
+ http_version:
42
+ recorded_at: Wed, 18 Mar 2015 20:28:29 GMT
43
+ - request:
44
+ method: get
45
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001E1vFAKE%27
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ''
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v0.9.1
52
+ Authorization:
53
+ - OAuth 00D1a000000H3O9!AQ4AQBPYB1dtKrLqKFY0OHPXkpY2WSuWV3emXMOLv6.4pyhpMQ0liAbd0z2To0vRk4VoArPod87jkJCAza2a_.92y4ZpZ_4m
54
+ Accept-Encoding:
55
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
56
+ Accept:
57
+ - "*/*"
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Date:
64
+ - Wed, 18 Mar 2015 20:28:30 GMT
65
+ Set-Cookie:
66
+ - BrowserId=oZ0qXAsES36c6s8yohMN9w;Path=/;Domain=.salesforce.com;Expires=Sun,
67
+ 17-May-2015 20:28:30 GMT
68
+ Expires:
69
+ - Thu, 01 Jan 1970 00:00:00 GMT
70
+ Sforce-Limit-Info:
71
+ - api-usage=6/15000
72
+ Content-Type:
73
+ - application/json;charset=UTF-8
74
+ Transfer-Encoding:
75
+ - chunked
76
+ body:
77
+ encoding: ASCII-8BIT
78
+ string: '{"totalSize":0,"done":true,"records":[]}'
79
+ http_version:
80
+ recorded_at: Wed, 18 Mar 2015 20:28:29 GMT
81
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,158 @@
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, 20 Mar 2015 20:59:39 GMT
25
+ Set-Cookie:
26
+ - BrowserId=uF36AF-_TUy_K6jmfPIc_w;Path=/;Domain=.salesforce.com;Expires=Tue,
27
+ 19-May-2015 20:59:39 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":"1426885179820","token_type":"Bearer","instance_url":"https://<host>","signature":"kaiHQV/T08tk9hkH4w04iaPo5ecEAyOvqNvgKy/CyjQ=","access_token":"00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP"}'
41
+ http_version:
42
+ recorded_at: Fri, 20 Mar 2015 20:59:40 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://<host>/services/data/v26.0/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!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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, 20 Mar 2015 20:59:41 GMT
67
+ Set-Cookie:
68
+ - BrowserId=xIZRRNLeRKuqkfwjkd3imw;Path=/;Domain=.salesforce.com;Expires=Tue,
69
+ 19-May-2015 20:59:41 GMT
70
+ Expires:
71
+ - Thu, 01 Jan 1970 00:00:00 GMT
72
+ Sforce-Limit-Info:
73
+ - api-usage=121/15000
74
+ Location:
75
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbGAAW"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001ECbGAAW","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Fri, 20 Mar 2015 20:59:41 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/v26.0/query?q=Select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20SystemModstamp%20%3C=%202015-03-20T20:59:41Z
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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, 20 Mar 2015 20:59:42 GMT
107
+ Set-Cookie:
108
+ - BrowserId=tY8SAk7XSniaZlF00IBN9Q;Path=/;Domain=.salesforce.com;Expires=Tue,
109
+ 19-May-2015 20:59:42 GMT
110
+ Expires:
111
+ - Thu, 01 Jan 1970 00:00:00 GMT
112
+ Sforce-Limit-Info:
113
+ - api-usage=121/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/v26.0/sobjects/CustomObject__c/a001a000001ECbGAAW"},"Id":"a001a000001ECbGAAW","SystemModstamp":"2015-03-20T20:59:41.000+0000","Name":"Custom
121
+ object","Example_Field__c":"Some sample text"}]}'
122
+ http_version:
123
+ recorded_at: Fri, 20 Mar 2015 20:59:42 GMT
124
+ - request:
125
+ method: delete
126
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbGAAW
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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: 204
142
+ message: No Content
143
+ headers:
144
+ Date:
145
+ - Fri, 20 Mar 2015 20:59:43 GMT
146
+ Set-Cookie:
147
+ - BrowserId=Ue_DPSZDSCyRoCXkP8Hmnw;Path=/;Domain=.salesforce.com;Expires=Tue,
148
+ 19-May-2015 20:59:43 GMT
149
+ Expires:
150
+ - Thu, 01 Jan 1970 00:00:00 GMT
151
+ Sforce-Limit-Info:
152
+ - api-usage=121/15000
153
+ body:
154
+ encoding: UTF-8
155
+ string: ''
156
+ http_version:
157
+ recorded_at: Fri, 20 Mar 2015 20:59:43 GMT
158
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,158 @@
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, 20 Mar 2015 20:59:32 GMT
25
+ Set-Cookie:
26
+ - BrowserId=ctCIpY5mRAqfJF7_xQty4A;Path=/;Domain=.salesforce.com;Expires=Tue,
27
+ 19-May-2015 20:59:32 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":"1426885173062","token_type":"Bearer","instance_url":"https://<host>","signature":"0pwdZp+Vj7PyZ2upgoSfNbdMvfwXSibKfcLPi8Q9PHI=","access_token":"00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP"}'
41
+ http_version:
42
+ recorded_at: Fri, 20 Mar 2015 20:59:33 GMT
43
+ - request:
44
+ method: post
45
+ uri: https://<host>/services/data/v26.0/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!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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, 20 Mar 2015 20:59:34 GMT
67
+ Set-Cookie:
68
+ - BrowserId=K-_7G-pvS2SW1oakYdpcaA;Path=/;Domain=.salesforce.com;Expires=Tue,
69
+ 19-May-2015 20:59:35 GMT
70
+ Expires:
71
+ - Thu, 01 Jan 1970 00:00:00 GMT
72
+ Sforce-Limit-Info:
73
+ - api-usage=121/15000
74
+ Location:
75
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbBAAW"
76
+ Content-Type:
77
+ - application/json;charset=UTF-8
78
+ Transfer-Encoding:
79
+ - chunked
80
+ body:
81
+ encoding: ASCII-8BIT
82
+ string: '{"id":"a001a000001ECbBAAW","success":true,"errors":[]}'
83
+ http_version:
84
+ recorded_at: Fri, 20 Mar 2015 20:59:35 GMT
85
+ - request:
86
+ method: get
87
+ uri: https://<host>/services/data/v26.0/query?q=Select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20SystemModstamp%20%3C=%202015-03-20T20:59:35Z
88
+ body:
89
+ encoding: US-ASCII
90
+ string: ''
91
+ headers:
92
+ User-Agent:
93
+ - Faraday v0.9.1
94
+ Authorization:
95
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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, 20 Mar 2015 20:59:37 GMT
107
+ Set-Cookie:
108
+ - BrowserId=GlsO09GJSA2oDD0Y-p2p-g;Path=/;Domain=.salesforce.com;Expires=Tue,
109
+ 19-May-2015 20:59:37 GMT
110
+ Expires:
111
+ - Thu, 01 Jan 1970 00:00:00 GMT
112
+ Sforce-Limit-Info:
113
+ - api-usage=121/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/v26.0/sobjects/CustomObject__c/a001a000001ECbBAAW"},"Id":"a001a000001ECbBAAW","SystemModstamp":"2015-03-20T20:59:35.000+0000","Name":"Custom
121
+ object","Example_Field__c":"Some sample text"}]}'
122
+ http_version:
123
+ recorded_at: Fri, 20 Mar 2015 20:59:37 GMT
124
+ - request:
125
+ method: delete
126
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbBAAW
127
+ body:
128
+ encoding: US-ASCII
129
+ string: ''
130
+ headers:
131
+ User-Agent:
132
+ - Faraday v0.9.1
133
+ Authorization:
134
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
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: 204
142
+ message: No Content
143
+ headers:
144
+ Date:
145
+ - Fri, 20 Mar 2015 20:59:38 GMT
146
+ Set-Cookie:
147
+ - BrowserId=IUol5Ke_TSSg9-Wu6KzGmA;Path=/;Domain=.salesforce.com;Expires=Tue,
148
+ 19-May-2015 20:59:38 GMT
149
+ Expires:
150
+ - Thu, 01 Jan 1970 00:00:00 GMT
151
+ Sforce-Limit-Info:
152
+ - api-usage=121/15000
153
+ body:
154
+ encoding: UTF-8
155
+ string: ''
156
+ http_version:
157
+ recorded_at: Fri, 20 Mar 2015 20:59:38 GMT
158
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,235 @@
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, 20 Mar 2015 20:59:44 GMT
25
+ Set-Cookie:
26
+ - BrowserId=4-imtaBFRZeGX9Fo0NAZaA;Path=/;Domain=.salesforce.com;Expires=Tue,
27
+ 19-May-2015 20:59:44 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":"1426885184729","token_type":"Bearer","instance_url":"https://<host>","signature":"Q7OqbC/8t3cdP3VYzf8QgvHHco2nhQXT9WY4JOiNS1g=","access_token":"00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP"}'
41
+ http_version:
42
+ recorded_at: Fri, 20 Mar 2015 20:59:44 GMT
43
+ - request:
44
+ method: get
45
+ uri: https://<host>/services/data/v26.0/query?q=Select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20SystemModstamp%20%3C=%202015-03-20T20:59:43Z
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ''
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v0.9.1
52
+ Authorization:
53
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
54
+ Accept-Encoding:
55
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
56
+ Accept:
57
+ - "*/*"
58
+ response:
59
+ status:
60
+ code: 200
61
+ message: OK
62
+ headers:
63
+ Date:
64
+ - Fri, 20 Mar 2015 20:59:46 GMT
65
+ Set-Cookie:
66
+ - BrowserId=Zi1ka3p1Shi2JUilgv0izg;Path=/;Domain=.salesforce.com;Expires=Tue,
67
+ 19-May-2015 20:59:46 GMT
68
+ Expires:
69
+ - Thu, 01 Jan 1970 00:00:00 GMT
70
+ Sforce-Limit-Info:
71
+ - api-usage=121/15000
72
+ Content-Type:
73
+ - application/json;charset=UTF-8
74
+ Transfer-Encoding:
75
+ - chunked
76
+ body:
77
+ encoding: ASCII-8BIT
78
+ string: '{"totalSize":0,"done":true,"records":[]}'
79
+ http_version:
80
+ recorded_at: Fri, 20 Mar 2015 20:59:46 GMT
81
+ - request:
82
+ method: post
83
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c
84
+ body:
85
+ encoding: UTF-8
86
+ string: '{"Name":"Custom object","Example_Field__c":"Some sample text"}'
87
+ headers:
88
+ User-Agent:
89
+ - Faraday v0.9.1
90
+ Content-Type:
91
+ - application/json
92
+ Authorization:
93
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ Accept:
97
+ - "*/*"
98
+ response:
99
+ status:
100
+ code: 201
101
+ message: Created
102
+ headers:
103
+ Date:
104
+ - Fri, 20 Mar 2015 20:59:47 GMT
105
+ Set-Cookie:
106
+ - BrowserId=gllElZbhTxG6ED4P5LsPwA;Path=/;Domain=.salesforce.com;Expires=Tue,
107
+ 19-May-2015 20:59:47 GMT
108
+ Expires:
109
+ - Thu, 01 Jan 1970 00:00:00 GMT
110
+ Sforce-Limit-Info:
111
+ - api-usage=121/15000
112
+ Location:
113
+ - "/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbLAAW"
114
+ Content-Type:
115
+ - application/json;charset=UTF-8
116
+ Transfer-Encoding:
117
+ - chunked
118
+ body:
119
+ encoding: ASCII-8BIT
120
+ string: '{"id":"a001a000001ECbLAAW","success":true,"errors":[]}'
121
+ http_version:
122
+ recorded_at: Fri, 20 Mar 2015 20:59:48 GMT
123
+ - request:
124
+ method: get
125
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001ECbLAAW%27
126
+ body:
127
+ encoding: US-ASCII
128
+ string: ''
129
+ headers:
130
+ User-Agent:
131
+ - Faraday v0.9.1
132
+ Authorization:
133
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
134
+ Accept-Encoding:
135
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
136
+ Accept:
137
+ - "*/*"
138
+ response:
139
+ status:
140
+ code: 200
141
+ message: OK
142
+ headers:
143
+ Date:
144
+ - Fri, 20 Mar 2015 20:59:50 GMT
145
+ Set-Cookie:
146
+ - BrowserId=yA56CpT6QXqufmy9wYUA6A;Path=/;Domain=.salesforce.com;Expires=Tue,
147
+ 19-May-2015 20:59:50 GMT
148
+ Expires:
149
+ - Thu, 01 Jan 1970 00:00:00 GMT
150
+ Sforce-Limit-Info:
151
+ - api-usage=121/15000
152
+ Content-Type:
153
+ - application/json;charset=UTF-8
154
+ Transfer-Encoding:
155
+ - chunked
156
+ body:
157
+ encoding: ASCII-8BIT
158
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbLAAW"},"Id":"a001a000001ECbLAAW","SystemModstamp":"2015-03-20T20:59:47.000+0000","Name":"Custom
159
+ object","Example_Field__c":"Some sample text"}]}'
160
+ http_version:
161
+ recorded_at: Fri, 20 Mar 2015 20:59:50 GMT
162
+ - request:
163
+ method: get
164
+ uri: https://<host>/services/data/v26.0/query?q=select%20Id,%20SystemModstamp,%20Name,%20Example_Field__c%20from%20CustomObject__c%20where%20Id%20=%20%27a001a000001ECbLAAW%27
165
+ body:
166
+ encoding: US-ASCII
167
+ string: ''
168
+ headers:
169
+ User-Agent:
170
+ - Faraday v0.9.1
171
+ Authorization:
172
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
173
+ Accept-Encoding:
174
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
175
+ Accept:
176
+ - "*/*"
177
+ response:
178
+ status:
179
+ code: 200
180
+ message: OK
181
+ headers:
182
+ Date:
183
+ - Fri, 20 Mar 2015 20:59:51 GMT
184
+ Set-Cookie:
185
+ - BrowserId=uSFOtCw7TrKgwbJ6GpF9DQ;Path=/;Domain=.salesforce.com;Expires=Tue,
186
+ 19-May-2015 20:59:51 GMT
187
+ Expires:
188
+ - Thu, 01 Jan 1970 00:00:00 GMT
189
+ Sforce-Limit-Info:
190
+ - api-usage=121/15000
191
+ Content-Type:
192
+ - application/json;charset=UTF-8
193
+ Transfer-Encoding:
194
+ - chunked
195
+ body:
196
+ encoding: ASCII-8BIT
197
+ string: '{"totalSize":1,"done":true,"records":[{"attributes":{"type":"CustomObject__c","url":"/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbLAAW"},"Id":"a001a000001ECbLAAW","SystemModstamp":"2015-03-20T20:59:47.000+0000","Name":"Custom
198
+ object","Example_Field__c":"Some sample text"}]}'
199
+ http_version:
200
+ recorded_at: Fri, 20 Mar 2015 20:59:51 GMT
201
+ - request:
202
+ method: delete
203
+ uri: https://<host>/services/data/v26.0/sobjects/CustomObject__c/a001a000001ECbLAAW
204
+ body:
205
+ encoding: US-ASCII
206
+ string: ''
207
+ headers:
208
+ User-Agent:
209
+ - Faraday v0.9.1
210
+ Authorization:
211
+ - OAuth 00D1a000000H3O9!AQ4AQGLw7kXVL1YKNwYo.72MhTH_JsNiQrcufxWTIkqwVDyMWC2KTKnZXSai5sESPjpz2IjAY1BrBSrja5_PVh3nTEA_uXnP
212
+ Accept-Encoding:
213
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
214
+ Accept:
215
+ - "*/*"
216
+ response:
217
+ status:
218
+ code: 204
219
+ message: No Content
220
+ headers:
221
+ Date:
222
+ - Fri, 20 Mar 2015 20:59:52 GMT
223
+ Set-Cookie:
224
+ - BrowserId=qSd7kmwWTQWZyuEwjwYSiQ;Path=/;Domain=.salesforce.com;Expires=Tue,
225
+ 19-May-2015 20:59:52 GMT
226
+ Expires:
227
+ - Thu, 01 Jan 1970 00:00:00 GMT
228
+ Sforce-Limit-Info:
229
+ - api-usage=122/15000
230
+ body:
231
+ encoding: UTF-8
232
+ string: ''
233
+ http_version:
234
+ recorded_at: Fri, 20 Mar 2015 20:59:52 GMT
235
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,38 @@
1
+ require_relative "../../../test_helper"
2
+
3
+ describe Restforce::DB::Configuration do
4
+ let(:secrets) { Secrets["client"] }
5
+ let(:secrets_file) { File.expand_path("../../../../config/secrets.yml", __FILE__) }
6
+ let(:configuration) { Restforce::DB::Configuration.new }
7
+
8
+ describe "#load" do
9
+ before do
10
+ configuration.load(secrets)
11
+ end
12
+
13
+ it "loads the credentials from a passed hash" do
14
+ expect(configuration.username).to_equal secrets["username"]
15
+ expect(configuration.password).to_equal secrets["password"]
16
+ expect(configuration.security_token).to_equal secrets["security_token"]
17
+ expect(configuration.client_id).to_equal secrets["client_id"]
18
+ expect(configuration.client_secret).to_equal secrets["client_secret"]
19
+ expect(configuration.host).to_equal secrets["host"]
20
+ end
21
+ end
22
+
23
+ describe "#parse" do
24
+ before do
25
+ configuration.parse(secrets_file)
26
+ end
27
+
28
+ it "loads the credentials from a YAML file" do
29
+ expect(configuration.username).to_equal secrets["username"]
30
+ expect(configuration.password).to_equal secrets["password"]
31
+ expect(configuration.security_token).to_equal secrets["security_token"]
32
+ expect(configuration.client_id).to_equal secrets["client_id"]
33
+ expect(configuration.client_secret).to_equal secrets["client_secret"]
34
+ expect(configuration.host).to_equal secrets["host"]
35
+ end
36
+ end
37
+
38
+ end