stripe-rails 0.2.4 → 0.2.5

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: 807b4264116e9c6b4874be07b459d737157dcb0e
4
- data.tar.gz: 86193b53cf4881312abd3b3d7bb4d2e01c4dea54
3
+ metadata.gz: 659c7c36f43dc5ea3c5596a4a0b52d627c2d7246
4
+ data.tar.gz: 880df11f0ddffa5384c0be43f85b25e78d03a4c7
5
5
  SHA512:
6
- metadata.gz: 0f966aa2f92dc4de552755515a7961398d7edfcf152cf594d855c39fc2d3b1f1dcecd4d4a4032d593c9f29b9da85dda4668f7b6b1a0e3bf4e2117adbd5d9723d
7
- data.tar.gz: 5234276a006d7b0efdf5bc1b14256359ab7fd1832ce0505231c5f1d24ffdf0db74a1b9cb18c9bd590190eb871742cfa6c282628f87d9a980ed24cf57cc73589d
6
+ metadata.gz: 45449d368835770b267dd7f72e483ffbbd0c00c7c15ae016d82593c28e6899d71509a9876a48d57024a4fab4f749fd857203e62f1e84ecae85a213980c2d8217
7
+ data.tar.gz: 4f7cc37aaac434771fa96506b9f86055499bfbcee24db0ad5d5a8caa33784848d681cf2533a26cd8944bb0420975713d3bbe64b9973b9eaa057124cf681af621
@@ -1,3 +1,7 @@
1
+ ## 0.2.5 (2013-03-18)
2
+ * make the default max redemptions 1
3
+ * add stripe::coupons::reset! task to redefine all coupons
4
+
1
5
  ## 0.2.2 (2012-01-09)
2
6
  * bugfix allowing creation of coupons without max_redemptions
3
7
 
data/README.md CHANGED
@@ -115,7 +115,7 @@ NOTE: You must destroy plans manually from your stripe dashboard.
115
115
  ## Webhooks
116
116
 
117
117
  Stripe::Rails automatically sets up your application to receive webhooks from stripe.com whenever
118
- an payment event is generated. To enable this, you will need to configure your [stripe webooks][3] to
118
+ an payment event is generated. To enable this, you will need to configure your [stripe webhooks][3] to
119
119
  point back to your application. By default, the webhook controller is mounted at '/stripe/events' so
120
120
  you would want to enter in `http://myproductionapp.com/stripe/events` as your url for live mode,
121
121
  and `http://mystagingapp.com/stripe/events` for your test mode.
@@ -265,4 +265,4 @@ needs, including integration with stripe.com.
265
265
  [7]: http://thefrontside.net
266
266
  [8]: https://stripe.com/docs/api?lang=ruby#customers
267
267
  [9]: https://stripe.com/docs/api?lang=ruby#invoices
268
- [10]: https://stripe.com/docs/api?lang=ruby#charges
268
+ [10]: https://stripe.com/docs/api?lang=ruby#charges
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require "bundler/gem_tasks"
3
3
 
4
4
  desc "run minitests"
5
5
  task :spec do
6
- sh "bundle exec ruby -Itest test/*_spec.rb"
6
+ sh "bundle exec ruby -Itest test/all.rb"
7
7
  end
8
8
 
9
9
  task :default => :spec
@@ -39,6 +39,10 @@ module Stripe
39
39
  def put!
40
40
  all.each(&:put!)
41
41
  end
42
+
43
+ def reset!
44
+ all.each(&:reset!)
45
+ end
42
46
  end
43
47
  end
44
48
 
@@ -75,12 +79,20 @@ module Stripe
75
79
  end
76
80
  end
77
81
 
82
+ def reset!
83
+ if object = exists?
84
+ object.delete
85
+ end
86
+ object = @stripe_class.create({:id => @id}.merge create_options)
87
+ puts "[RESET] - #{@stripe_class}:#{object}" unless Stripe::Engine.testing
88
+ end
89
+
78
90
  def to_s
79
91
  @id.to_s
80
92
  end
81
93
 
82
94
  def exists?
83
- !!@stripe_class.retrieve(to_s)
95
+ @stripe_class.retrieve(to_s)
84
96
  rescue Stripe::InvalidRequestError
85
97
  false
86
98
  end
@@ -16,6 +16,7 @@ module Stripe
16
16
  def initialize(*args)
17
17
  super
18
18
  @currency = 'usd'
19
+ @max_redemptions = 1
19
20
  end
20
21
 
21
22
  def repeating?
@@ -19,6 +19,11 @@ namespace :stripe do
19
19
  Stripe::Coupons.put!
20
20
  end
21
21
 
22
+ desc 'delete and redefine all coupons defined in config/stripe/coupons.rb'
23
+ task 'coupons:reset!' => 'environment' do
24
+ Stripe::Coupons.reset!
25
+ end
26
+
22
27
  desc "create all plans and coupons defined in config/stripe/{plans|coupons}.rb"
23
28
  task 'prepare' => ['plans:prepare', 'coupons:prepare']
24
29
  end
@@ -1,5 +1,5 @@
1
1
  module Stripe
2
2
  module Rails
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ Dir['**/*_spec.rb'].each {|f| load f}
@@ -1,7 +1,23 @@
1
1
  require 'minitest/autorun'
2
2
  require 'spec_helper'
3
3
 
4
- describe 'building plans' do
4
+ describe 'building coupons' do
5
+ before do
6
+ Stripe::Coupons.configurations.clear
7
+ end
8
+ describe 'default values' do
9
+ before do
10
+ @coupon = Stripe.coupon(:firesale) do |coupon|
11
+ coupon.duration = 'once'
12
+ coupon.duration_in_months = 100
13
+ coupon.amount_off = 100
14
+ end
15
+ end
16
+ it "allows a single redemption by default" do
17
+ @coupon.max_redemptions.must_equal 1
18
+ end
19
+ end
20
+
5
21
  describe 'simply' do
6
22
  before do
7
23
  @now = Time.now.utc
@@ -54,8 +70,51 @@ describe 'building plans' do
54
70
  end
55
71
  end
56
72
  end
57
- end
58
73
 
74
+ describe 'reseting' do
75
+ describe 'when it does not exist on stripe.com'do
76
+ before do
77
+ Stripe::Coupon.stubs(:retrieve).raises(Stripe::InvalidRequestError.new("not found", "id"))
78
+ end
79
+ it 'creates the plan' do
80
+ Stripe::Coupon.expects(:create).with(
81
+ :id => :gold25,
82
+ :duration => 'repeating',
83
+ :duration_in_months => 10,
84
+ :amount_off => 100,
85
+ :currency => 'USD',
86
+ :max_redemptions => 3,
87
+ :percent_off => 25,
88
+ :redeem_by => @now
89
+ )
90
+ Stripe::Coupons.reset!
91
+ end
92
+ end
93
+ describe 'when it does exist on stripe.com already' do
94
+ before do
95
+ @coupon = Stripe::Coupon.construct_from({
96
+ :id => :gold25,
97
+ })
98
+ Stripe::Coupon.stubs(:retrieve).returns(@coupon)
99
+ end
100
+ it 'first deletes the coupon then re-adds it' do
101
+ @coupon.expects(:delete)
102
+ Stripe::Coupon.expects(:create).with(
103
+ :id => :gold25,
104
+ :duration => 'repeating',
105
+ :duration_in_months => 10,
106
+ :amount_off => 100,
107
+ :currency => 'USD',
108
+ :max_redemptions => 3,
109
+ :percent_off => 25,
110
+ :redeem_by => @now
111
+ )
112
+ Stripe::Coupons.reset!
113
+ end
114
+ end
115
+ end
116
+
117
+ end
59
118
  describe 'with missing mandatory values' do
60
119
  it 'raises an exception after configuring it' do
61
120
  proc {Stripe.coupon(:bad) {}}.must_raise Stripe::InvalidConfigurationError
@@ -8,12 +8,3 @@ describe "Configuring the stripe engine" do
8
8
  Stripe.verify_ssl_certs.must_equal false
9
9
  end
10
10
  end
11
-
12
- describe 'initializing plans' do
13
- require 'rake'
14
- load 'stripe/rails/tasks.rake'
15
- it 'creates any plans that do not exist on stripe.com' do
16
- Stripe::Plans.expects(:put!)
17
- Rake::Task['stripe:plans:prepare'].invoke
18
- end
19
- 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: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubygeek
@@ -29,7 +29,7 @@ cert_chain:
29
29
  UgImJlChAzCoDP9zi9tdm6jAr7ttF25R9PPYr11ILb7dYe3qUzlNlM6zJx/nb31b
30
30
  IhdyRVup4qLcqYSTPsm6u7VA
31
31
  -----END CERTIFICATE-----
32
- date: 2013-03-11 00:00:00.000000000 Z
32
+ date: 2013-03-18 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: rails
@@ -137,6 +137,7 @@ files:
137
137
  - lib/stripe/rails/version.rb
138
138
  - stripe-rails.gemspec
139
139
  - test/.DS_Store
140
+ - test/all.rb
140
141
  - test/callbacks_spec.rb
141
142
  - test/coupon_builder_spec.rb
142
143
  - test/dummy/README.rdoc
@@ -201,6 +202,7 @@ specification_version: 4
201
202
  summary: A gem to integrate stripe into your rails app
202
203
  test_files:
203
204
  - test/.DS_Store
205
+ - test/all.rb
204
206
  - test/callbacks_spec.rb
205
207
  - test/coupon_builder_spec.rb
206
208
  - test/dummy/README.rdoc