stripe-rails 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 1.0.2 (2017-08-15)
2
+
3
+ * Remove authenticity token check (thanks @lewispb)
4
+ * Adding timeout options to config (thanks @rgerard)
5
+ * Add 'day' as possible plan interval (thanks @vdragsic and @artemave)
6
+
1
7
  ## 1.0.1 (2017-08-08)
2
8
 
3
9
  * Fixes a bug with Stripe JS V3, i.e. `Stripe.setPublishableKey` is no longer a function. Thanks to @kartikluke for reporting this.
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
  [![Gem Version](https://badge.fury.io/rb/stripe-rails.png)](http://badge.fury.io/rb/stripe-rails)
3
3
  [![Build Status](https://travis-ci.org/Everapps/stripe-rails.png?branch=master)](https://travis-ci.org/Everapps/stripe-rails)
4
4
  [![Code Climate](https://codeclimate.com/github/Everapps/stripe-rails/badges/gpa.svg)](https://codeclimate.com/github/Everapps/stripe-rails)
5
+ [![Test Coverage](https://codeclimate.com/github/Everapps/stripe-rails/badges/coverage.svg)](https://codeclimate.com/github/Everapps/stripe-rails/coverage)
5
6
  [![Dependency Status](https://gemnasium.com/thefrontside/stripe-rails.png)](https://gemnasium.com/thefrontside/stripe-rails)
6
7
 
7
8
 
@@ -362,7 +363,12 @@ See the [complete listing of all stripe events][5], and the [webhook tutorial][6
362
363
 
363
364
  <a href="http://frontside.io">![Frontside](http://frontside.io/images/logo.svg)</a>
364
365
 
365
- `Stripe::Rails` was originally developed with love and fondess by your friends at [Frontside][7]. They are available for your custom software development needs, including integration with stripe.com.
366
+ `Stripe::Rails` was originally developed with love and fondness by your friends at [Frontside][7]. They are available for your custom software development needs, including integration with stripe.com.
367
+
368
+ <a href="https://www.evercondo.com">![Evercondo](https://dl.dropboxusercontent.com/s/m3ma9356uelep53/evercondo.png)</a>
369
+
370
+ `Stripe::Rails` has also been supported by the fine folks at [Evercondo][11], the next generation condo management software.
371
+
366
372
 
367
373
  [1]: https://stripe.com/docs/stripe.js
368
374
  [2]: https://manage.stripe.com/#account/apikeys
@@ -374,6 +380,7 @@ See the [complete listing of all stripe events][5], and the [webhook tutorial][6
374
380
  [8]: https://stripe.com/docs/api?lang=ruby#customers
375
381
  [9]: https://stripe.com/docs/api?lang=ruby#invoices
376
382
  [10]: https://stripe.com/docs/api?lang=ruby#charges
383
+ [11]: https://www.evercondo.com
377
384
 
378
385
 
379
386
  ## Code of Conduct
@@ -1,5 +1,6 @@
1
1
  module Stripe
2
2
  class ApplicationController < ActionController::Base
3
+ skip_before_action(:verify_authenticity_token) if protect_from_forgery.any?
3
4
  # is anything stripe wide?
4
5
  end
5
6
  end
@@ -14,7 +14,7 @@
14
14
  # # currency to use for the plan (default 'usd')
15
15
  # plan.currency = 'usd'
16
16
  #
17
- # # interval must be either 'week', 'month' or 'year'
17
+ # # interval must be either 'day', 'week', 'month' or 'year'
18
18
  # plan.interval = 'month'
19
19
  #
20
20
  # # only bill once every three months (default 1)
data/lib/stripe/engine.rb CHANGED
@@ -8,7 +8,7 @@ module Stripe
8
8
  attr_accessor :testing
9
9
  end
10
10
 
11
- stripe_config = config.stripe = Struct.new(:api_base, :api_version, :secret_key, :verify_ssl_certs, :publishable_key, :endpoint, :debug_js, :auto_mount, :eager_load).new
11
+ stripe_config = config.stripe = Struct.new(:api_base, :api_version, :secret_key, :verify_ssl_certs, :publishable_key, :endpoint, :debug_js, :auto_mount, :eager_load, :open_timeout, :read_timeout).new
12
12
 
13
13
  def stripe_config.api_key=(key)
14
14
  warn "[DEPRECATION] to align with stripe nomenclature, stripe.api_key has been renamed to config.stripe.secret_key"
@@ -27,7 +27,7 @@ module Stripe
27
27
  end
28
28
 
29
29
  initializer 'stripe.configure' do |app|
30
- [:api_base, :verify_ssl_certs, :api_version].each do |key|
30
+ [:api_base, :verify_ssl_certs, :api_version, :open_timeout, :read_timeout].each do |key|
31
31
  value = app.config.stripe.send(key)
32
32
  Stripe.send("#{key}=", value) unless value.nil?
33
33
  end
data/lib/stripe/plans.rb CHANGED
@@ -8,8 +8,8 @@ module Stripe
8
8
 
9
9
  validates_presence_of :id, :amount, :currency, :name
10
10
 
11
- validates_inclusion_of :interval, :in => %w(week month year),
12
- :message => "'%{value}' is not one of 'week', 'month' or 'year'"
11
+ validates_inclusion_of :interval, :in => %w(day week month year),
12
+ :message => "'%{value}' is not one of 'day', 'week', 'month' or 'year'"
13
13
 
14
14
  validates :statement_descriptor, :length => { :maximum => 22 }
15
15
 
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
@@ -1,4 +1,3 @@
1
- require 'minitest/autorun'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Stripe::Callbacks do
@@ -174,10 +173,13 @@ describe Stripe::Callbacks do
174
173
  end
175
174
  end
176
175
 
177
- describe 'when there are eager loaded callbacks in the configuration (config/environment/test.rb)' do
178
- it 'should be eager loaded' do
179
- Dummy.const_defined?(:ModelWithCallbacks).must_equal true
180
- Dummy.const_defined?(:ModuleWithCallbacks).must_equal true
176
+ describe 'with forgery protection enabled' do
177
+ before do
178
+ ActionController::Base.allow_forgery_protection = true
179
+ ActionController::Base.protect_from_forgery with: :exception
181
180
  end
181
+ after { ActionController::Base.allow_forgery_protection = false }
182
+
183
+ it { subject } # must_not raise error
182
184
  end
183
185
  end
@@ -1,4 +1,3 @@
1
- require 'minitest/autorun'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe 'building coupons' do
@@ -1,10 +1,4 @@
1
1
  Dummy::Application.configure do
2
-
3
- config.stripe.api_base = 'http://localhost:5000'
4
- config.stripe.verify_ssl_certs = false
5
- config.stripe.eager_load = 'dummy/model_with_callbacks', 'dummy/module_with_callbacks'
6
- config.stripe.api_version = '2015-10-16'
7
-
8
2
  # Settings specified here will take precedence over those in config/application.rb
9
3
 
10
4
  # The test environment is used exclusively to run your application's
@@ -1,4 +1,3 @@
1
- require 'minitest/autorun'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Stripe::JavascriptHelper do
@@ -21,6 +20,7 @@ describe Stripe::JavascriptHelper do
21
20
 
22
21
  describe 'when the debug flag is enabled' do
23
22
  before { Rails.application.config.stripe.debug_js = true }
23
+ after { Rails.application.config.stripe.debug_js = false }
24
24
  it 'should render the debug js' do
25
25
  view.stripe_javascript_tag(:v1).must_include 'https://js.stripe.com/v1/stripe-debug.js'
26
26
  end
@@ -1,4 +1,3 @@
1
- require 'minitest/autorun'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe Stripe::PingsController do
@@ -1,4 +1,3 @@
1
- require 'minitest/autorun'
2
1
  require 'spec_helper'
3
2
 
4
3
  describe 'building plans' do
@@ -32,6 +31,16 @@ describe 'building plans' do
32
31
  Stripe::Plans['primo'].must_equal Stripe::Plans::PRIMO
33
32
  end
34
33
 
34
+ it 'accepts a billing interval of a day' do
35
+ Stripe.plan :daily do |plan|
36
+ plan.name = 'Acme as a service daily'
37
+ plan.amount = 100
38
+ plan.interval = 'day'
39
+ end
40
+
41
+ Stripe::Plans::DAILY.wont_be_nil
42
+ end
43
+
35
44
  it 'accepts a billing interval of a week' do
36
45
  Stripe.plan :weekly do |plan|
37
46
  plan.name = 'Acme as a service weekly'
data/test/spec_helper.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  require "simplecov"
2
- SimpleCov.start
2
+ SimpleCov.start do
3
+ add_filter "/test/"
4
+ end
5
+
6
+ require 'minitest/autorun'
3
7
 
4
8
  # Configure Rails Environment
5
9
  ENV["RAILS_ENV"] = "test"
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Configuring the stripe engine" do
4
+ i_suck_and_my_tests_are_order_dependent! # the default test must be run first!
5
+
6
+ # NOTE: skipped `stripe.plans_and_coupons` to prevent warnings about constants
7
+ STRIPE_INITIALIZER_NAMES = %w{ stripe.configure.defaults stripe.configure stripe.callbacks.eager_load stripe.javascript_helper }
8
+
9
+ let(:app) { Rails.application }
10
+ let(:initializers) { STRIPE_INITIALIZER_NAMES.map{|name| app.initializers.find{|ini| ini.name == name } } }
11
+
12
+ def rerun_initializers!; initializers.each{|init| init.run(app) }; end
13
+
14
+ describe 'Stripe configurations' do
15
+ it "will have valid default values" do
16
+ Stripe.api_base.must_equal 'https://api.stripe.com'
17
+ Stripe.api_key.must_equal 'XYZ'
18
+ Stripe.api_version.must_be_nil
19
+ Stripe.verify_ssl_certs.must_equal true
20
+ Stripe.open_timeout.must_equal 30
21
+ Stripe.read_timeout.must_equal 80
22
+
23
+ app.config.stripe.endpoint.must_equal '/stripe'
24
+ app.config.stripe.auto_mount.must_equal true
25
+ app.config.stripe.debug_js.must_equal false
26
+ end
27
+
28
+ subject do
29
+ app.config.stripe.api_base = 'http://localhost:5000'
30
+ app.config.stripe.secret_key = 'SECRET_XYZ'
31
+ app.config.stripe.verify_ssl_certs = false
32
+ app.config.stripe.api_version = '2015-10-16'
33
+ app.config.stripe.open_timeout = 33
34
+ app.config.stripe.read_timeout = 88
35
+ rerun_initializers!
36
+ end
37
+
38
+ it "reads values that is set in the environment" do
39
+ subject
40
+
41
+ Stripe.api_base.must_equal 'http://localhost:5000'
42
+ Stripe.api_key.must_equal 'SECRET_XYZ'
43
+ Stripe.verify_ssl_certs.must_equal false
44
+ Stripe.api_version.must_equal '2015-10-16'
45
+ Stripe.open_timeout.must_equal 33
46
+ Stripe.read_timeout.must_equal 88
47
+ end
48
+ end
49
+
50
+ describe 'eager loaded callbacks' do
51
+ subject do
52
+ app.config.stripe.eager_load = 'dummy/model_with_callbacks', 'dummy/module_with_callbacks'
53
+ rerun_initializers!
54
+ end
55
+
56
+ it 'should be eager loaded' do
57
+ subject
58
+
59
+ Dummy.const_defined?(:ModelWithCallbacks).must_equal true
60
+ Dummy.const_defined?(:ModuleWithCallbacks).must_equal true
61
+ end
62
+ end
63
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-08-08 00:00:00.000000000 Z
12
+ date: 2017-08-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -60,7 +60,9 @@ executables: []
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
+ - ".codeclimate.yml"
63
64
  - ".gitignore"
65
+ - ".rubocop.yml"
64
66
  - ".travis.yml"
65
67
  - CODE_OF_CONDUCT.md
66
68
  - Changelog.md
@@ -139,7 +141,7 @@ files:
139
141
  - test/pings_controller_spec.rb
140
142
  - test/plan_builder_spec.rb
141
143
  - test/spec_helper.rb
142
- - test/stripe_rails_spec.rb
144
+ - test/stripe_initializers_spec.rb
143
145
  - test/support/application_system_test_case.rb
144
146
  - test/support/callback_helpers.rb
145
147
  - test/support/null_system_test_case.rb
@@ -215,7 +217,7 @@ test_files:
215
217
  - test/pings_controller_spec.rb
216
218
  - test/plan_builder_spec.rb
217
219
  - test/spec_helper.rb
218
- - test/stripe_rails_spec.rb
220
+ - test/stripe_initializers_spec.rb
219
221
  - test/support/application_system_test_case.rb
220
222
  - test/support/callback_helpers.rb
221
223
  - test/support/null_system_test_case.rb
@@ -1,11 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'spec_helper'
3
-
4
- describe "Configuring the stripe engine" do
5
- it "reads the api key that is set in the environment" do
6
- Stripe.api_base.must_equal 'http://localhost:5000'
7
- Stripe.api_key.must_equal 'XYZ'
8
- Stripe.api_version.must_equal '2015-10-16'
9
- Stripe.verify_ssl_certs.must_equal false
10
- end
11
- end