stripe-rails 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +5 -0
- data/README.md +4 -3
- data/lib/stripe/products.rb +10 -1
- data/lib/stripe/rails/version.rb +1 -1
- data/test/product_builder_spec.rb +20 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7db8795e52cc3f40773d7104222eb9f36ceea62a5d51ddc9a0f5215d2635021c
|
4
|
+
data.tar.gz: ee17376ed75a5f28e755a7bd7e4e8bcf4e91fb2de23b96226f0837b6f678afe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 007ca00d0dea9a363b5042fa2d82ce42e430a53c7773682b92b74a6c77ce4024756eab6df5b919b08f7b0699b45450b0cb69cb63e1546c6d429f427af520efc9
|
7
|
+
data.tar.gz: d37cfd7ffc037cf80d119c366993d89a1d90a7291bd9a1fe4477b0d120c24e7f550baf948ea4bbdb1ec86c2e05f2644c34bdcf308625078c4b8c1498fc53a2a2
|
data/Changelog.md
CHANGED
data/README.md
CHANGED
@@ -177,9 +177,10 @@ end
|
|
177
177
|
As are Products:
|
178
178
|
|
179
179
|
```ruby
|
180
|
-
Stripe.
|
181
|
-
|
182
|
-
|
180
|
+
Stripe.product :primo do |product|
|
181
|
+
product.name = 'PRIMO as a service'
|
182
|
+
product.type = 'service'
|
183
|
+
product.statement_descriptor = 'PRIMO'
|
183
184
|
end
|
184
185
|
```
|
185
186
|
|
data/lib/stripe/products.rb
CHANGED
@@ -11,19 +11,27 @@ module Stripe
|
|
11
11
|
:caption,
|
12
12
|
:metadata,
|
13
13
|
:shippable,
|
14
|
-
:url
|
14
|
+
:url,
|
15
|
+
:statement_descriptor
|
15
16
|
|
16
17
|
validates_presence_of :name, :type
|
17
18
|
|
19
|
+
validates :statement_descriptor, length: { maximum: 22 }
|
20
|
+
|
18
21
|
validates :active, :shippable, inclusion: { in: [true, false] }, allow_nil: true
|
19
22
|
validates :type, inclusion: { in: %w(service good) }
|
20
23
|
validates :caption, :description, :shippable, :url, absence: true, unless: :good?
|
24
|
+
validates :statement_descriptor, absence: true, unless: :service?
|
21
25
|
|
22
26
|
private
|
23
27
|
def good?
|
24
28
|
type == 'good'
|
25
29
|
end
|
26
30
|
|
31
|
+
def service?
|
32
|
+
type == 'service'
|
33
|
+
end
|
34
|
+
|
27
35
|
def create_options
|
28
36
|
{
|
29
37
|
name: name,
|
@@ -35,6 +43,7 @@ module Stripe
|
|
35
43
|
metadata: metadata,
|
36
44
|
shippable: shippable,
|
37
45
|
url: url,
|
46
|
+
statement_descriptor: statement_descriptor
|
38
47
|
}.delete_if{|_, v| v.nil? }
|
39
48
|
end
|
40
49
|
end
|
data/lib/stripe/rails/version.rb
CHANGED
@@ -8,6 +8,7 @@ describe 'building products' do
|
|
8
8
|
product.active = true
|
9
9
|
product.attributes = ['size', 'gender']
|
10
10
|
product.metadata = {:number_of_awesome_things => 5}
|
11
|
+
product.statement_descriptor = 'PRIMO'
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -32,12 +33,13 @@ describe 'building products' do
|
|
32
33
|
|
33
34
|
it 'creates the plan online' do
|
34
35
|
Stripe::Product.expects(:create).with(
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
36
|
+
id: :primo,
|
37
|
+
name: 'Acme as a service PRIMO',
|
38
|
+
type: 'service',
|
39
|
+
active: true,
|
40
|
+
attributes: ['size', 'gender'],
|
41
|
+
metadata: {:number_of_awesome_things => 5},
|
42
|
+
statement_descriptor: 'PRIMO'
|
41
43
|
)
|
42
44
|
Stripe::Products::PRIMO.put!
|
43
45
|
end
|
@@ -87,5 +89,17 @@ describe 'building products' do
|
|
87
89
|
}.must_raise Stripe::InvalidConfigurationError
|
88
90
|
end
|
89
91
|
end
|
92
|
+
|
93
|
+
describe 'when using an attribute only for services' do
|
94
|
+
it 'raises an exception during configuration' do
|
95
|
+
lambda {
|
96
|
+
Stripe.product :broken do |product|
|
97
|
+
product.name = 'Broken Good'
|
98
|
+
product.type = 'good'
|
99
|
+
product.statement_descriptor = 'SERVICE'
|
100
|
+
end
|
101
|
+
}.must_raise Stripe::InvalidConfigurationError
|
102
|
+
end
|
103
|
+
end
|
90
104
|
end
|
91
105
|
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.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Lowell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-10-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|