cryptocoin_payable 1.4.0 → 1.4.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad069cdb3d17b910ae90f4ccfc893547df52af40
4
- data.tar.gz: d1af2f689d9ebfeb3cfcbf20efd8ef24e9d2705b
3
+ metadata.gz: d62d90884baf847ad534ef72165b1801e663fde8
4
+ data.tar.gz: 88faef02487bb72bc15f656c0165591413886c60
5
5
  SHA512:
6
- metadata.gz: 024b1be86b34a5a5949529ac22d99dfea3ea453f45ff0883e84fa38f079a5db16c6cfbd15cab727c0d78eb55fe29f8e5850bea11277e381fb4cc56ef2d501bcf
7
- data.tar.gz: 95f2f5a66d64c781e3dd94e56631b5fe104dd94b750e64a9293c1d6a70c619c08f8f179aee832ba6fccc0afeb8407c92689de8605af182c8cf58310811491163
6
+ metadata.gz: 8730b71aa84bf994a2b3a30b29cd49d36e11d67dae148c826867c8c002614b29adadf2b2c61eaef97f28df9fe6f3c3eda24d4bde00d31b730bf14ad114a06921
7
+ data.tar.gz: b613eae2be4f0f4d539d864b31bdc90e703306ee305430ac1c91bde10c42e757134f708fc991bcad2945d6d1eec397a87942602634a663ece87cd5008e789d9d
@@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'rspec-rails', '~> 3.7'
32
32
  spec.add_development_dependency 'rspec-retry', '~> 0.6'
33
33
  spec.add_development_dependency 'rubocop', '~> 0.59'
34
+ spec.add_development_dependency 'timecop', '~> 0.9'
34
35
  spec.add_development_dependency 'vcr', '~> 4.0'
35
36
  spec.add_development_dependency 'webmock', '~> 3.4'
36
37
 
@@ -25,7 +25,7 @@ module CryptocoinPayable
25
25
  # Loop through all unpaid payments and update them with the new price if
26
26
  # it has been 30 mins since they have been updated.
27
27
  CoinPayment.unpaid.stale.find_each do |payment|
28
- payment.update_coin_amount_due(coin_conversion: rates[payment.coin_type.to_sym].price)
28
+ payment.update_coin_amount_due(rate: rates[payment.coin_type.to_sym].price)
29
29
  end
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module CryptocoinPayable
2
- VERSION = '1.4.0'.freeze
2
+ VERSION = '1.4.1'.freeze
3
3
  end
@@ -18,33 +18,9 @@ describe CryptocoinPayable::PaymentProcessor do
18
18
  transactions
19
19
  end
20
20
 
21
- def create_tables
22
- ENV['RAILS_ENV'] = 'test'
23
- load 'spec/dummy/db/schema.rb'
24
- end
25
-
26
- def drop_tables
27
- %i[
28
- coin_payment_transactions
29
- coin_payments
30
- currency_conversions
31
- widgets
32
- ].each do |table_name|
33
- ActiveRecord::Base.connection.drop_table(table_name)
34
- end
35
- end
36
-
37
21
  context 'when testing performance of database interaction' do
38
- before(:all) do
39
- ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'cryptocoin_payable_test')
40
- create_tables
41
- GC.disable
42
- end
43
-
44
- after(:all) do
45
- GC.enable
46
- drop_tables
47
- end
22
+ before(:all) { GC.disable }
23
+ after(:all) { GC.enable }
48
24
 
49
25
  before do
50
26
  CryptocoinPayable::CurrencyConversion.create!(coin_type: :btc, currency: 1, price: 1)
@@ -0,0 +1,31 @@
1
+ require 'timecop'
2
+
3
+ describe CryptocoinPayable::PricingProcessor, vcr: true do
4
+ context 'when updating stale payments' do
5
+ before do
6
+ # Ensure we have a stale payment.
7
+ Timecop.freeze(3.days.from_now)
8
+
9
+ CryptocoinPayable::CurrencyConversion.create!(
10
+ coin_type: :btc,
11
+ currency: 1,
12
+ price: 1
13
+ )
14
+
15
+ CryptocoinPayable::CoinPayment.create!(
16
+ state: :pending,
17
+ coin_type: :btc,
18
+ price: 1,
19
+ reason: 'test'
20
+ )
21
+ end
22
+
23
+ after do
24
+ Timecop.return
25
+ end
26
+
27
+ it 'can update' do
28
+ subject.perform
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,205 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.coinbase.com/v2/prices/BTC-USD/spot
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Mon, 22 Oct 2018 12:03:43 GMT
23
+ Content-Type:
24
+ - application/json; charset=utf-8
25
+ Transfer-Encoding:
26
+ - chunked
27
+ Connection:
28
+ - keep-alive
29
+ Set-Cookie:
30
+ - __cfduid=d3e71f70698fb0777476e87de15b925f71540209823; expires=Tue, 22-Oct-19
31
+ 12:03:43 GMT; path=/; domain=.coinbase.com; HttpOnly
32
+ Cache-Control:
33
+ - public, max-age=30
34
+ Content-Disposition:
35
+ - attachment; filename=response.json
36
+ Content-Security-Policy:
37
+ - 'default-src ''self'' https://www.coinbase.com; child-src ''self'' https://www.coinbase.com
38
+ https://*.online-metrix.net https://*.wpstn.com https://netverify.com https://platform.twitter.com
39
+ https://www.google.com/recaptcha/ https://cdn.plaid.com/link/ https://*.doubleclick.net/
40
+ blob: https://coinbase.ada.support; connect-src ''self'' https://www.coinbase.com
41
+ https://api.coinbase.com https://api.mixpanel.com https://*.online-metrix.net
42
+ https://api.cloudinary.com https://ott9.wpstn.com/live https://api.amplitude.com/
43
+ static.coinbase.com wss://ws.coinbase.com wss://ws.coinbase.com:443 https://www.coinbase.com/api
44
+ https://coinbase.ada.support/api/; font-src ''self'' https://www.coinbase.com
45
+ https://assets.coinbase.com/ static.coinbase.com; img-src ''self'' data: https://www.coinbase.com
46
+ https://images.coinbase.com https://exceptions.coinbase.com https://coinbase-uploads.s3.amazonaws.com
47
+ https://s3.amazonaws.com/app-public/ https://maps.gstatic.com https://ssl.google-analytics.com
48
+ https://www.google.com https://maps.googleapis.com https://csi.gstatic.com
49
+ https://www.google-analytics.com https://res.cloudinary.com https://secure.gravatar.com
50
+ https://i2.wp.com https://*.online-metrix.net https://assets.coinbase.com/
51
+ https://hexagon-analytics.com https://api.mixpanel.com https://cb-brand.s3.amazonaws.com
52
+ https://googleads.g.doubleclick.net https://stats.g.doubleclick.net/r/collect
53
+ blob: static.coinbase.com https://d124s1zbdqkqqe.cloudfront.net https://www.facebook.com/tr;
54
+ media-src ''self'' https://www.coinbase.com blob:; object-src ''self'' data:
55
+ blob: https://www.coinbase.com https://cdn.siftscience.com https://*.online-metrix.net
56
+ https://www.gstatic.com https://www.google.com/recaptcha/api/; script-src
57
+ ''self'' ''unsafe-inline'' ''unsafe-eval'' https://www.coinbase.com https://cdn.siftscience.com
58
+ https://*.newrelic.com https://bam.nr-data.net https://*.google-analytics.com
59
+ https://www.google.com https://www.gstatic.com https://*.online-metrix.net
60
+ https://code.jquery.com https://chart.googleapis.com https://maps.googleapis.com
61
+ https://maps.gstatic.com https://netverify.com https://ajax.cloudflare.com
62
+ https://cdn.plaid.com/link/v2/stable/ https://www.googletagmanager.com/gtag/js
63
+ https://www.googletagmanager.com/gtm.js https://www.googleadservices.com https://googleads.g.doubleclick.net
64
+ https://assets.coinbase.com/ static.coinbase.com; style-src ''self'' ''unsafe-inline''
65
+ https://www.coinbase.com https://assets.coinbase.com/ static.coinbase.com;
66
+ report-uri /csp-report'
67
+ Etag:
68
+ - W/"50113d3b29ac6ba037f591afa45666d5"
69
+ Expect-Ct:
70
+ - enforce; max-age=86400; report-uri="https://coinbase.report-uri.io/r/default/ct/reportOnly"
71
+ Referrer-Policy:
72
+ - strict-origin-when-cross-origin
73
+ Strict-Transport-Security:
74
+ - max-age=31536000; includeSubDomains; preload
75
+ Vary:
76
+ - Origin,Accept-Encoding
77
+ X-Content-Type-Options:
78
+ - nosniff
79
+ X-Download-Options:
80
+ - noopen
81
+ X-Frame-Options:
82
+ - DENY
83
+ X-Permitted-Cross-Domain-Policies:
84
+ - none
85
+ X-Powered-By:
86
+ - Proof-of-Work
87
+ X-Request-Id:
88
+ - c4a1f140-cfaf-4fd5-b690-c8cbd93cdf98
89
+ X-Xss-Protection:
90
+ - 1; mode=block
91
+ Cf-Cache-Status:
92
+ - HIT
93
+ Expires:
94
+ - Mon, 22 Oct 2018 12:04:13 GMT
95
+ Server:
96
+ - cloudflare
97
+ Cf-Ray:
98
+ - 46dbd2859e5549a9-BKK
99
+ body:
100
+ encoding: ASCII-8BIT
101
+ string: '{"data":{"base":"BTC","currency":"USD","amount":"6399.36"}}'
102
+ http_version:
103
+ recorded_at: Thu, 25 Oct 2018 12:03:55 GMT
104
+ - request:
105
+ method: get
106
+ uri: https://api.coinbase.com/v2/prices/ETH-USD/spot
107
+ body:
108
+ encoding: US-ASCII
109
+ string: ''
110
+ headers:
111
+ Accept-Encoding:
112
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
113
+ Accept:
114
+ - "*/*"
115
+ User-Agent:
116
+ - Ruby
117
+ response:
118
+ status:
119
+ code: 200
120
+ message: OK
121
+ headers:
122
+ Date:
123
+ - Mon, 22 Oct 2018 12:03:45 GMT
124
+ Content-Type:
125
+ - application/json; charset=utf-8
126
+ Content-Length:
127
+ - '81'
128
+ Connection:
129
+ - keep-alive
130
+ Set-Cookie:
131
+ - __cfduid=d3e71f70698fb0777476e87de15b925f71540209823; expires=Tue, 22-Oct-19
132
+ 12:03:43 GMT; path=/; domain=.coinbase.com; HttpOnly
133
+ Cache-Control:
134
+ - public, max-age=30
135
+ Content-Disposition:
136
+ - attachment; filename=response.json
137
+ Content-Security-Policy:
138
+ - 'default-src ''self'' https://www.coinbase.com; child-src ''self'' https://www.coinbase.com
139
+ https://*.online-metrix.net https://*.wpstn.com https://netverify.com https://platform.twitter.com
140
+ https://www.google.com/recaptcha/ https://cdn.plaid.com/link/ https://*.doubleclick.net/
141
+ blob: https://coinbase.ada.support; connect-src ''self'' https://www.coinbase.com
142
+ https://api.coinbase.com https://api.mixpanel.com https://*.online-metrix.net
143
+ https://api.cloudinary.com https://ott9.wpstn.com/live https://api.amplitude.com/
144
+ static.coinbase.com wss://ws.coinbase.com wss://ws.coinbase.com:443 https://www.coinbase.com/api
145
+ https://coinbase.ada.support/api/; font-src ''self'' https://www.coinbase.com
146
+ https://assets.coinbase.com/ static.coinbase.com; img-src ''self'' data: https://www.coinbase.com
147
+ https://images.coinbase.com https://exceptions.coinbase.com https://coinbase-uploads.s3.amazonaws.com
148
+ https://s3.amazonaws.com/app-public/ https://maps.gstatic.com https://ssl.google-analytics.com
149
+ https://www.google.com https://maps.googleapis.com https://csi.gstatic.com
150
+ https://www.google-analytics.com https://res.cloudinary.com https://secure.gravatar.com
151
+ https://i2.wp.com https://*.online-metrix.net https://assets.coinbase.com/
152
+ https://hexagon-analytics.com https://api.mixpanel.com https://cb-brand.s3.amazonaws.com
153
+ https://googleads.g.doubleclick.net https://stats.g.doubleclick.net/r/collect
154
+ blob: static.coinbase.com https://d124s1zbdqkqqe.cloudfront.net https://www.facebook.com/tr;
155
+ media-src ''self'' https://www.coinbase.com blob:; object-src ''self'' data:
156
+ blob: https://www.coinbase.com https://cdn.siftscience.com https://*.online-metrix.net
157
+ https://www.gstatic.com https://www.google.com/recaptcha/api/; script-src
158
+ ''self'' ''unsafe-inline'' ''unsafe-eval'' https://www.coinbase.com https://cdn.siftscience.com
159
+ https://*.newrelic.com https://bam.nr-data.net https://*.google-analytics.com
160
+ https://www.google.com https://www.gstatic.com https://*.online-metrix.net
161
+ https://code.jquery.com https://chart.googleapis.com https://maps.googleapis.com
162
+ https://maps.gstatic.com https://netverify.com https://ajax.cloudflare.com
163
+ https://cdn.plaid.com/link/v2/stable/ https://www.googletagmanager.com/gtag/js
164
+ https://www.googletagmanager.com/gtm.js https://www.googleadservices.com https://googleads.g.doubleclick.net
165
+ https://assets.coinbase.com/ static.coinbase.com; style-src ''self'' ''unsafe-inline''
166
+ https://www.coinbase.com https://assets.coinbase.com/ static.coinbase.com;
167
+ report-uri /csp-report'
168
+ Etag:
169
+ - W/"efc1bc8e6732bdf6cba86c542ae05a3f"
170
+ Expect-Ct:
171
+ - enforce; max-age=86400; report-uri="https://coinbase.report-uri.io/r/default/ct/reportOnly"
172
+ Referrer-Policy:
173
+ - strict-origin-when-cross-origin
174
+ Strict-Transport-Security:
175
+ - max-age=31536000; includeSubDomains; preload
176
+ Vary:
177
+ - Origin,Accept-Encoding
178
+ X-Content-Type-Options:
179
+ - nosniff
180
+ X-Download-Options:
181
+ - noopen
182
+ X-Frame-Options:
183
+ - DENY
184
+ X-Permitted-Cross-Domain-Policies:
185
+ - none
186
+ X-Powered-By:
187
+ - Proof-of-Work
188
+ X-Request-Id:
189
+ - 12c5f4dc-a501-4d49-80f7-3bb02d826bfa
190
+ X-Xss-Protection:
191
+ - 1; mode=block
192
+ Cf-Cache-Status:
193
+ - HIT
194
+ Expires:
195
+ - Mon, 22 Oct 2018 12:04:15 GMT
196
+ Server:
197
+ - cloudflare
198
+ Cf-Ray:
199
+ - 46dbd286cf8849a9-BKK
200
+ body:
201
+ encoding: ASCII-8BIT
202
+ string: '{"data":{"base":"ETH","currency":"USD","amount":"201.96"}}'
203
+ http_version:
204
+ recorded_at: Thu, 25 Oct 2018 12:03:55 GMT
205
+ recorded_with: VCR 4.0.0
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,22 @@ VCR.configure do |config|
12
12
  config.configure_rspec_metadata!
13
13
  end
14
14
 
15
+ def create_tables
16
+ ENV['RAILS_ENV'] = 'test'
17
+ load 'spec/dummy/db/schema.rb'
18
+ end
19
+
20
+ def drop_tables
21
+ %i[
22
+ coin_payment_transactions
23
+ coin_payments
24
+ currency_conversions
25
+ widgets
26
+ ].each do |table_name|
27
+ ActiveRecord::Base.connection.drop_table(table_name)
28
+ end
29
+ end
30
+
15
31
  # This file was generated by the `rspec --init` command. Conventionally, all
16
32
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
17
33
  # The generated `.rspec` file contains `--require spec_helper` which will cause
@@ -61,6 +77,13 @@ RSpec.configure do |config|
61
77
  config.before(:suite) do
62
78
  CryptocoinPayable.configure do
63
79
  end
80
+
81
+ ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'cryptocoin_payable_test')
82
+ create_tables
83
+ end
84
+
85
+ config.after(:suite) do
86
+ drop_tables
64
87
  end
65
88
 
66
89
  config.include RSpec::Benchmark::Matchers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptocoin_payable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Salis
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-10-17 00:00:00.000000000 Z
12
+ date: 2018-10-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -165,6 +165,20 @@ dependencies:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
167
  version: '0.59'
168
+ - !ruby/object:Gem::Dependency
169
+ name: timecop
170
+ requirement: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0.9'
175
+ type: :development
176
+ prerelease: false
177
+ version_requirements: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - "~>"
180
+ - !ruby/object:Gem::Version
181
+ version: '0.9'
168
182
  - !ruby/object:Gem::Dependency
169
183
  name: vcr
170
184
  requirement: !ruby/object:Gem::Requirement
@@ -326,6 +340,7 @@ files:
326
340
  - spec/acceptance/adapters/bitcoin_spec.rb
327
341
  - spec/acceptance/adapters/ethereum_spec.rb
328
342
  - spec/acceptance/commands/payment_processor_spec.rb
343
+ - spec/acceptance/commands/pricing_processor_spec.rb
329
344
  - spec/dummy/README.rdoc
330
345
  - spec/dummy/Rakefile
331
346
  - spec/dummy/app/assets/images/.keep
@@ -382,6 +397,7 @@ files:
382
397
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/gets_an_empty_result_when_no_transactions_found.yml
383
398
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/gets_transactions_for_a_given_address.yml
384
399
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/raises_an_error_when_an_invalid_address_is_passed.yml
400
+ - spec/fixtures/vcr_cassettes/CryptocoinPayable_PricingProcessor/when_updating_stale_payments/can_update.yml
385
401
  - spec/spec_helper.rb
386
402
  homepage: ''
387
403
  licenses:
@@ -421,6 +437,7 @@ test_files:
421
437
  - spec/acceptance/adapters/bitcoin_spec.rb
422
438
  - spec/acceptance/adapters/ethereum_spec.rb
423
439
  - spec/acceptance/commands/payment_processor_spec.rb
440
+ - spec/acceptance/commands/pricing_processor_spec.rb
424
441
  - spec/dummy/README.rdoc
425
442
  - spec/dummy/Rakefile
426
443
  - spec/dummy/app/assets/images/.keep
@@ -477,4 +494,5 @@ test_files:
477
494
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/gets_an_empty_result_when_no_transactions_found.yml
478
495
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/gets_transactions_for_a_given_address.yml
479
496
  - spec/fixtures/vcr_cassettes/CryptocoinPayable_Adapters_Ethereum/raises_an_error_when_an_invalid_address_is_passed.yml
497
+ - spec/fixtures/vcr_cassettes/CryptocoinPayable_PricingProcessor/when_updating_stale_payments/can_update.yml
480
498
  - spec/spec_helper.rb