chargify_api_ares 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile.lock +20 -19
- data/README.md +43 -2
- data/Rakefile +1 -2
- data/chargify_api_ares.gemspec +7 -7
- data/lib/chargify_api_ares.rb +3 -2
- data/lib/patches/activemodel_3_0_patch.rb +23 -0
- data/spec/remote/{spec_helper.rb → remote_helper.rb} +2 -9
- data/spec/remote/remote_spec.rb +1 -1
- data/spec/resources/coupon_spec.rb +5 -5
- data/spec/resources/customer_spec.rb +1 -1
- data/spec/resources/product_family_spec.rb +1 -1
- data/spec/resources/product_spec.rb +1 -1
- data/spec/resources/subscription_component_spec.rb +1 -1
- data/spec/resources/subscription_spec.rb +10 -10
- data/spec/resources/usage_spec.rb +5 -5
- data/spec/spec_helper.rb +14 -9
- data/spec/support/fake_resource.rb +69 -45
- metadata +129 -146
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chargify_api_ares (0.
|
5
|
-
activeresource (>=
|
4
|
+
chargify_api_ares (0.6.0)
|
5
|
+
activeresource (>= 3.0.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
@@ -19,8 +19,8 @@ GEM
|
|
19
19
|
builder (3.0.4)
|
20
20
|
coderay (1.0.8)
|
21
21
|
diff-lcs (1.1.3)
|
22
|
-
factory_girl (2.
|
23
|
-
activesupport
|
22
|
+
factory_girl (2.6.4)
|
23
|
+
activesupport (>= 2.3.9)
|
24
24
|
faker (1.1.2)
|
25
25
|
i18n (~> 0.5)
|
26
26
|
fakeweb (1.3.0)
|
@@ -31,8 +31,9 @@ GEM
|
|
31
31
|
pry (>= 0.9.10)
|
32
32
|
terminal-table (>= 1.4.3)
|
33
33
|
thor (>= 0.14.6)
|
34
|
-
guard-rspec (
|
35
|
-
guard (>=
|
34
|
+
guard-rspec (2.4.0)
|
35
|
+
guard (>= 1.1)
|
36
|
+
rspec (~> 2.11)
|
36
37
|
i18n (0.6.1)
|
37
38
|
listen (0.7.2)
|
38
39
|
lumberjack (1.0.2)
|
@@ -42,16 +43,16 @@ GEM
|
|
42
43
|
coderay (~> 1.0.5)
|
43
44
|
method_source (~> 0.8)
|
44
45
|
slop (~> 3.4)
|
45
|
-
rake (0.
|
46
|
+
rake (10.0.3)
|
46
47
|
rb-fsevent (0.9.3)
|
47
|
-
rspec (2.
|
48
|
-
rspec-core (~> 2.
|
49
|
-
rspec-expectations (~> 2.
|
50
|
-
rspec-mocks (~> 2.
|
51
|
-
rspec-core (2.
|
52
|
-
rspec-expectations (2.
|
53
|
-
diff-lcs (~> 1.1.
|
54
|
-
rspec-mocks (2.
|
48
|
+
rspec (2.12.0)
|
49
|
+
rspec-core (~> 2.12.0)
|
50
|
+
rspec-expectations (~> 2.12.0)
|
51
|
+
rspec-mocks (~> 2.12.0)
|
52
|
+
rspec-core (2.12.2)
|
53
|
+
rspec-expectations (2.12.1)
|
54
|
+
diff-lcs (~> 1.1.3)
|
55
|
+
rspec-mocks (2.12.2)
|
55
56
|
slop (3.4.3)
|
56
57
|
terminal-table (1.4.5)
|
57
58
|
thor (0.17.0)
|
@@ -61,11 +62,11 @@ PLATFORMS
|
|
61
62
|
|
62
63
|
DEPENDENCIES
|
63
64
|
chargify_api_ares!
|
64
|
-
factory_girl (~> 2.
|
65
|
+
factory_girl (~> 2.6)
|
65
66
|
faker (~> 1.1.2)
|
66
67
|
fakeweb (~> 1.3.0)
|
67
68
|
growl (~> 1.0.3)
|
68
|
-
guard-rspec (~>
|
69
|
-
rake (~> 0.
|
69
|
+
guard-rspec (~> 2.4.0)
|
70
|
+
rake (~> 10.0.3)
|
70
71
|
rb-fsevent (~> 0.9.2)
|
71
|
-
rspec (~> 2.
|
72
|
+
rspec (~> 2.12.0)
|
data/README.md
CHANGED
@@ -2,9 +2,9 @@ Chargify API wrapper for Ruby (using ActiveResource)
|
|
2
2
|
====================================================
|
3
3
|
[![build status](https://secure.travis-ci.org/chargify/chargify_api_ares.png)](http://travis-ci.org/chargify/chargify_api_ares)
|
4
4
|
|
5
|
-
|
5
|
+
**Please see important compatibility information at the bottom of this file.**
|
6
6
|
|
7
|
-
|
7
|
+
This is a Ruby wrapper for the [Chargify](http://chargify.com) API that leverages ActiveResource.
|
8
8
|
|
9
9
|
It allows you to interface with the Chargify API using simple ActiveRecord-like syntax, i.e.:
|
10
10
|
|
@@ -66,3 +66,44 @@ Now you'll have access to classes the interact with the Chargify API, such as:
|
|
66
66
|
* `Chargify::Subscription`
|
67
67
|
|
68
68
|
Check out the examples in the `examples` directory. If you're not familiar with how ActiveResource works, you may be interested in some [ActiveResource Documentation](http://apidock.com/rails/ActiveResource/Base)
|
69
|
+
|
70
|
+
### Compatibility
|
71
|
+
|
72
|
+
* Rails/ActiveResource 2.3.x, use 0.5.x
|
73
|
+
* Rails/ActiveResource 3.x, use 0.6 and up
|
74
|
+
|
75
|
+
| chargify_api_ares | Rails 2.3.x | Rails 3.0.0 - 3.0.19 | Rails 3.0.20 and up |
|
76
|
+
| ----------------- | ----------- | -------------------- | ------------------- |
|
77
|
+
| 0.5.x | OK | Incompatible | OK |
|
78
|
+
| 0.6.x | Incompatible | OK (Monkey-patched) | OK |
|
79
|
+
|
80
|
+
#### The problem with Rails/ActiveResource/ActiveModel 3.0.0 - 3.0.19
|
81
|
+
|
82
|
+
Prior to Feb 12, 2013, Chargify would silently refuse to parse XML which
|
83
|
+
contained data specified as YAML, such as:
|
84
|
+
|
85
|
+
```xml
|
86
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
87
|
+
<person>
|
88
|
+
<name>John</name>
|
89
|
+
<email type="yaml" nil="true"/></email>
|
90
|
+
</person>
|
91
|
+
```
|
92
|
+
|
93
|
+
After Feb 12, 2013, Chargify returns a `400 Bad Request` response if
|
94
|
+
your XML contains any `type="yaml"` attribute, since there is no valid
|
95
|
+
reason to send YAML serialized data to Chargify and doing so smells
|
96
|
+
strongly of an attempt to exploit
|
97
|
+
[CVE-2013-0156](https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/61bkgvnSGTQ).
|
98
|
+
|
99
|
+
However, Rails/ActiveModel versions 3.0.0 to 3.0.19 had a bug (see
|
100
|
+
<https://github.com/rails/rails/pull/8853>) where any nil attribute
|
101
|
+
would have a `type="yaml"` attribute added during XML serialization.
|
102
|
+
|
103
|
+
Using ActiveResource 3.0.0 - 3.0.19 along with 0.5.x or lower of this
|
104
|
+
gem may result in your sending `type="yaml"` XML to Chargify. Thus, your
|
105
|
+
requests will be rejected.
|
106
|
+
|
107
|
+
Version 0.6.x of this gem will attempt to patch your ActiveModel if you
|
108
|
+
have an incompatible version. To avoid this patch, you should use
|
109
|
+
3.0.20 or higher of ActiveResource.
|
data/Rakefile
CHANGED
data/chargify_api_ares.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.7'
|
5
5
|
|
6
6
|
s.name = 'chargify_api_ares'
|
7
|
-
s.version = '0.
|
8
|
-
s.date = '2013-02-
|
7
|
+
s.version = '0.6.0'
|
8
|
+
s.date = '2013-02-16'
|
9
9
|
s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
|
10
10
|
s.description = ''
|
11
11
|
s.authors = ["Michael Klett", "Nathan Verni", "Graham McIntire", "Rodrigo Franco", "Shay Frendt"]
|
@@ -17,15 +17,15 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = %w[lib]
|
18
18
|
|
19
19
|
# Runtime Dependencies
|
20
|
-
s.add_runtime_dependency('activeresource', '>=
|
20
|
+
s.add_runtime_dependency('activeresource', '>= 3.0.0')
|
21
21
|
|
22
22
|
# Development Dependencies
|
23
|
-
s.add_development_dependency('rake', '~> 0.
|
24
|
-
s.add_development_dependency('rspec', '~> 2.
|
25
|
-
s.add_development_dependency('factory_girl', '~> 2.
|
23
|
+
s.add_development_dependency('rake', '~> 10.0.3')
|
24
|
+
s.add_development_dependency('rspec', '~> 2.12.0')
|
25
|
+
s.add_development_dependency('factory_girl', '~> 2.6')
|
26
26
|
s.add_development_dependency('fakeweb', '~> 1.3.0')
|
27
27
|
s.add_development_dependency('faker', '~> 1.1.2')
|
28
|
-
s.add_development_dependency('guard-rspec', '~>
|
28
|
+
s.add_development_dependency('guard-rspec', '~> 2.4.0')
|
29
29
|
s.add_development_dependency('growl', '~> 1.0.3')
|
30
30
|
s.add_development_dependency('rb-fsevent', '~> 0.9.2')
|
31
31
|
end
|
data/lib/chargify_api_ares.rb
CHANGED
@@ -15,9 +15,10 @@ require 'chargify_api_ares/resources/transaction'
|
|
15
15
|
require 'chargify_api_ares/resources/usage'
|
16
16
|
require 'chargify_api_ares/resources/webhook'
|
17
17
|
|
18
|
+
require 'active_resource/version'
|
18
19
|
if defined?(::ActiveResource::VERSION::MAJOR) &&
|
19
20
|
::ActiveResource::VERSION::MAJOR == 3 &&
|
20
21
|
::ActiveResource::VERSION::MINOR == 0 &&
|
21
22
|
::ActiveResource::VERSION::TINY < 20
|
22
|
-
|
23
|
-
end
|
23
|
+
require 'patches/activemodel_3_0_patch.rb'
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
ActiveSupport::Deprecation.warn("The Chargify gem is patching your ActiveModel because it is less than version 3.0.20! (https://github.com/chargify/chargify_api_ares/blob/master/README.md)")
|
2
|
+
|
3
|
+
module ActiveModel
|
4
|
+
module Serializers
|
5
|
+
module Xml
|
6
|
+
class Serializer
|
7
|
+
class Attribute
|
8
|
+
protected
|
9
|
+
|
10
|
+
# Patch `compute_type` to avoid adding `type="yaml"` to
|
11
|
+
# nil attributes in < 3.0.20 ActiveModel
|
12
|
+
#
|
13
|
+
# See https://github.com/rails/rails/pull/8853
|
14
|
+
alias_method :compute_type_orig, :compute_type
|
15
|
+
def compute_type
|
16
|
+
return if value.nil?
|
17
|
+
compute_type_orig
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,9 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
require 'rspec'
|
3
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
1
|
+
require 'spec_helper'
|
5
2
|
|
6
|
-
|
3
|
+
FakeWeb.allow_net_connect = true
|
7
4
|
|
8
5
|
unless File.exists?(File.join(File.dirname(__FILE__), 'remote.yml'))
|
9
6
|
STDERR.puts "\nERROR: Make sure a remote.yml file exists at ./spec/remote/remote.yml\n\n"
|
@@ -11,10 +8,6 @@ unless File.exists?(File.join(File.dirname(__FILE__), 'remote.yml'))
|
|
11
8
|
end
|
12
9
|
|
13
10
|
RSpec.configure do |config|
|
14
|
-
config.filter_run :focused => true
|
15
|
-
config.run_all_when_everything_filtered = true
|
16
|
-
config.alias_example_to :fit, :focused => true
|
17
|
-
config.color_enabled = true
|
18
11
|
config.before(:all) do
|
19
12
|
Chargify.configure do |c|
|
20
13
|
c.api_key = remote_configuration['api_key']
|
data/spec/remote/remote_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chargify::Coupon do
|
3
|
+
describe Chargify::Coupon, :fake_resource do
|
4
4
|
context '.find_by_product_family_id_and_code' do
|
5
|
-
let(:existing_coupon) {
|
5
|
+
let(:existing_coupon) { build(:coupon, :code => '20OFF') }
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
FakeWeb.register_uri(:get, "#{test_domain}/coupons/lookup.xml?code=#{existing_coupon.code}&product_family_id=10", :body => existing_coupon.attributes.to_xml)
|
@@ -24,8 +24,8 @@ describe Chargify::Coupon do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
context '.find_all_by_product_family_id' do
|
27
|
-
let(:coupon_1) {
|
28
|
-
let(:coupon_2) {
|
27
|
+
let(:coupon_1) { build(:coupon, :product_family_id => 5) }
|
28
|
+
let(:coupon_2) { build(:coupon, :product_family_id => 5) }
|
29
29
|
|
30
30
|
before do
|
31
31
|
FakeWeb.register_uri(:get, "#{test_domain}/coupons.xml?product_family_id=5", :body => [coupon_1.attributes, coupon_2.attributes].to_xml)
|
@@ -39,7 +39,7 @@ describe Chargify::Coupon do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
context '.validate' do
|
42
|
-
let(:coupon_1) {
|
42
|
+
let(:coupon_1) { build(:coupon, :product_family_id => 6) }
|
43
43
|
|
44
44
|
before do
|
45
45
|
FakeWeb.register_uri(:get, "#{test_domain}/coupons/validate.xml?product_family_id=6&coupon_code=foobar123", :body => coupon_1.attributes.to_xml)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chargify::Subscription do
|
3
|
+
describe Chargify::Subscription, :fake_resource do
|
4
4
|
|
5
5
|
context 'strips nested association attributes before saving' do
|
6
6
|
before do
|
7
|
-
@subscription =
|
7
|
+
@subscription = build(:subscription_with_extra_attrs)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'strips customer' do
|
@@ -26,15 +26,15 @@ describe Chargify::Subscription do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "doesn't strip other attrs" do
|
29
|
-
subscription =
|
29
|
+
subscription = build(:subscription)
|
30
30
|
|
31
31
|
lambda { subscription.save! }.should_not change(subscription, :attributes)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'creates a one-time charge' do
|
36
|
-
id =
|
37
|
-
subscription =
|
36
|
+
id = generate(:subscription_id)
|
37
|
+
subscription = build(:subscription, :id => id)
|
38
38
|
subscription.stub!(:persisted?).and_return(true)
|
39
39
|
expected_response = {:charge => {:amount_in_cents => 1000, :memo => "one-time charge", :success => true}}.to_xml
|
40
40
|
FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/charges.xml", :status => 201, :body => expected_response)
|
@@ -46,8 +46,8 @@ describe Chargify::Subscription do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'finds by customer reference' do
|
49
|
-
customer =
|
50
|
-
subscription =
|
49
|
+
customer = build(:customer, :reference => 'roger', :id => 10)
|
50
|
+
subscription = build(:subscription, :id => 11, :customer_id => customer.id, :product => build(:product))
|
51
51
|
|
52
52
|
expected_response = [subscription.attributes].to_xml(:root => 'subscriptions')
|
53
53
|
FakeWeb.register_uri(:get, "#{test_domain}/subscriptions.xml?customer_id=#{customer.id}", :status => 200, :body => expected_response)
|
@@ -57,7 +57,7 @@ describe Chargify::Subscription do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'cancels the subscription' do
|
60
|
-
@subscription =
|
60
|
+
@subscription = build(:subscription, :id => 1)
|
61
61
|
find_subscription = lambda { Chargify::Subscription.find(1) }
|
62
62
|
|
63
63
|
FakeWeb.register_uri(:get, "#{test_domain}/subscriptions/1.xml", :body => @subscription.attributes.to_xml)
|
@@ -68,8 +68,8 @@ describe Chargify::Subscription do
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'migrates the subscription' do
|
71
|
-
id =
|
72
|
-
subscription =
|
71
|
+
id = generate(:subscription_id)
|
72
|
+
subscription = build(:subscription, :id => id)
|
73
73
|
subscription.stub!(:persisted?).and_return(true)
|
74
74
|
expected_response = [subscription.attributes].to_xml(:root => 'subscription')
|
75
75
|
FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/migrations.xml?migration%5Bproduct_handle%5D=upgraded-plan", :status => 201, :body => expected_response)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Chargify::Usage do
|
3
|
+
describe Chargify::Usage, :fake_resource do
|
4
4
|
context "create" do
|
5
5
|
before do
|
6
|
-
@subscription =
|
7
|
-
@component =
|
6
|
+
@subscription = build(:subscription)
|
7
|
+
@component = build(:component)
|
8
8
|
@now = DateTime.now.to_s
|
9
9
|
end
|
10
10
|
|
@@ -24,8 +24,8 @@ describe Chargify::Usage do
|
|
24
24
|
|
25
25
|
context "find" do
|
26
26
|
before do
|
27
|
-
@subscription =
|
28
|
-
@component =
|
27
|
+
@subscription = build(:subscription)
|
28
|
+
@component = build(:component)
|
29
29
|
@now = DateTime.now.to_s
|
30
30
|
end
|
31
31
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
$:.unshift File.expand_path('../lib', File.dirname(__FILE__))
|
2
2
|
|
3
|
-
require '
|
4
|
-
require
|
5
|
-
|
3
|
+
require 'bundler'
|
4
|
+
Bundler.require(:default, :development)
|
5
|
+
|
6
6
|
require 'support/fake_resource'
|
7
|
-
require 'factory_girl'
|
8
|
-
require 'faker'
|
9
|
-
require 'factories'
|
10
7
|
|
8
|
+
FactoryGirl.find_definitions
|
11
9
|
ActiveResource::Base.send :include, ActiveResource::FakeResource
|
12
10
|
FakeWeb.allow_net_connect = false
|
13
11
|
|
@@ -19,11 +17,18 @@ end
|
|
19
17
|
RSpec.configure do |config|
|
20
18
|
config.filter_run :focused => true
|
21
19
|
config.run_all_when_everything_filtered = true
|
20
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
22
21
|
config.alias_example_to :fit, :focused => true
|
23
22
|
config.color_enabled = true
|
24
|
-
|
25
|
-
config.
|
26
|
-
|
23
|
+
|
24
|
+
config.include FactoryGirl::Syntax::Methods
|
25
|
+
|
26
|
+
config.before(:each, :fake_resource) do
|
27
|
+
ActiveResource::FakeResource.enable
|
28
|
+
end
|
29
|
+
|
30
|
+
config.after(:each, :fake_resource) do
|
31
|
+
ActiveResource::FakeResource.disable
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Taken from https://gist.github.com/238158/487a411c392e1fb2a0c00347e32444320f5cdd49
|
2
2
|
module ActiveResource
|
3
|
-
|
3
|
+
|
4
4
|
#
|
5
5
|
# The FakeResource fakes ActiveResources so that no real resources are transferred. It catches the creation methods
|
6
6
|
# and stores the resources internally instead of sending to a remote service and responds these resources back on
|
@@ -10,71 +10,95 @@ module ActiveResource
|
|
10
10
|
# fake a back end service in the BDD cycle
|
11
11
|
#
|
12
12
|
module FakeResource
|
13
|
-
|
13
|
+
extend ActiveSupport::Concern
|
14
|
+
|
14
15
|
@@fake_resources = []
|
15
|
-
|
16
|
+
@@enabled = false
|
17
|
+
|
18
|
+
def self.enable
|
19
|
+
@@enabled = true
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.disable
|
23
|
+
@@enabled = false
|
24
|
+
self.clean
|
25
|
+
end
|
26
|
+
|
16
27
|
def self.clean
|
17
28
|
FakeWeb.clean_registry
|
18
29
|
@@fake_resources = []
|
19
30
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
def save
|
31
|
+
|
32
|
+
included do
|
33
|
+
def save_with_fake_resource
|
34
|
+
if @@enabled
|
25
35
|
@@fake_resources << self
|
26
36
|
update_fake_responses
|
37
|
+
else
|
38
|
+
save_without_fake_resource
|
27
39
|
end
|
28
|
-
|
29
|
-
|
40
|
+
end
|
41
|
+
alias_method_chain :save, :fake_resource
|
42
|
+
|
43
|
+
def destroy_with_fake_resource
|
44
|
+
if @@enabled
|
30
45
|
@@fake_resources.delete(self)
|
31
46
|
update_fake_responses
|
47
|
+
else
|
48
|
+
destroy_without_fake_resource
|
32
49
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
50
|
+
end
|
51
|
+
alias_method_chain :destroy, :fake_resource
|
52
|
+
|
53
|
+
def self.delete(id, options = {})
|
54
|
+
if @@enabled
|
36
55
|
@@fake_resources.delete_if {|r| r.id == id }
|
37
56
|
#update_fake_responses
|
57
|
+
else
|
58
|
+
super
|
38
59
|
end
|
39
|
-
|
40
|
-
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.exists?(id, options = {})
|
63
|
+
if @@enabled
|
41
64
|
not @@fake_resources.select {|r| r.id == id}.blank?
|
65
|
+
else
|
66
|
+
super
|
42
67
|
end
|
43
|
-
|
44
68
|
end
|
45
69
|
end
|
46
|
-
|
70
|
+
|
47
71
|
def save!
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
72
|
+
if @@enabled
|
73
|
+
save
|
74
|
+
else
|
75
|
+
super
|
76
|
+
end
|
53
77
|
end
|
54
|
-
|
78
|
+
|
55
79
|
private
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
FakeWeb.register_uri(:get, collection_uri, :body => @@fake_resources.to_xml)
|
65
|
-
end
|
66
|
-
|
67
|
-
def element_uri
|
68
|
-
"#{base_uri}#{element_path}"
|
69
|
-
end
|
70
|
-
|
71
|
-
def collection_uri
|
72
|
-
"#{base_uri}#{collection_path}"
|
73
|
-
end
|
74
|
-
|
75
|
-
def base_uri
|
76
|
-
"#{connection.site.scheme}://#{connection.user}:#{connection.password}@#{connection.site.host}:#{connection.site.port}"
|
80
|
+
|
81
|
+
def update_fake_responses
|
82
|
+
FakeWeb.clean_registry
|
83
|
+
|
84
|
+
@@fake_resources.each do |r|
|
85
|
+
FakeWeb.register_uri(:get, element_uri, :body => r.to_xml)
|
77
86
|
end
|
78
|
-
|
87
|
+
|
88
|
+
FakeWeb.register_uri(:get, collection_uri, :body => @@fake_resources.to_xml)
|
89
|
+
end
|
90
|
+
|
91
|
+
def element_uri
|
92
|
+
"#{base_uri}#{element_path}"
|
93
|
+
end
|
94
|
+
|
95
|
+
def collection_uri
|
96
|
+
"#{base_uri}#{collection_path}"
|
97
|
+
end
|
98
|
+
|
99
|
+
def base_uri
|
100
|
+
"#{connection.site.scheme}://#{connection.user}:#{connection.password}@#{connection.site.host}:#{connection.site.port}"
|
79
101
|
end
|
102
|
+
|
103
|
+
end
|
80
104
|
end
|
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargify_api_ares
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 4
|
10
|
-
version: 0.5.4
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Klett
|
14
9
|
- Nathan Verni
|
15
10
|
- Graham McIntire
|
@@ -18,162 +13,158 @@ authors:
|
|
18
13
|
autorequire:
|
19
14
|
bindir: bin
|
20
15
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
|
-
type: :runtime
|
16
|
+
date: 2013-02-16 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
26
19
|
name: activeresource
|
27
|
-
|
20
|
+
requirement: !ruby/object:Gem::Requirement
|
28
21
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
33
|
-
|
34
|
-
- 2
|
35
|
-
- 3
|
36
|
-
- 5
|
37
|
-
version: 2.3.5
|
38
|
-
requirement: *id001
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 3.0.0
|
26
|
+
type: :runtime
|
39
27
|
prerelease: false
|
40
|
-
|
41
|
-
|
28
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
- !ruby/object:Gem::Dependency
|
42
35
|
name: rake
|
43
|
-
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
44
37
|
none: false
|
45
|
-
requirements:
|
38
|
+
requirements:
|
46
39
|
- - ~>
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
|
49
|
-
segments:
|
50
|
-
- 0
|
51
|
-
- 9
|
52
|
-
- 2
|
53
|
-
version: 0.9.2
|
54
|
-
requirement: *id002
|
55
|
-
prerelease: false
|
56
|
-
- !ruby/object:Gem::Dependency
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 10.0.3
|
57
42
|
type: :development
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 10.0.3
|
50
|
+
- !ruby/object:Gem::Dependency
|
58
51
|
name: rspec
|
59
|
-
|
52
|
+
requirement: !ruby/object:Gem::Requirement
|
60
53
|
none: false
|
61
|
-
requirements:
|
54
|
+
requirements:
|
62
55
|
- - ~>
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
|
65
|
-
segments:
|
66
|
-
- 2
|
67
|
-
- 7
|
68
|
-
- 0
|
69
|
-
version: 2.7.0
|
70
|
-
requirement: *id003
|
71
|
-
prerelease: false
|
72
|
-
- !ruby/object:Gem::Dependency
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.12.0
|
73
58
|
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 2.12.0
|
66
|
+
- !ruby/object:Gem::Dependency
|
74
67
|
name: factory_girl
|
75
|
-
|
68
|
+
requirement: !ruby/object:Gem::Requirement
|
76
69
|
none: false
|
77
|
-
requirements:
|
70
|
+
requirements:
|
78
71
|
- - ~>
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
|
81
|
-
segments:
|
82
|
-
- 2
|
83
|
-
- 1
|
84
|
-
- 0
|
85
|
-
version: 2.1.0
|
86
|
-
requirement: *id004
|
87
|
-
prerelease: false
|
88
|
-
- !ruby/object:Gem::Dependency
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.6'
|
89
74
|
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.6'
|
82
|
+
- !ruby/object:Gem::Dependency
|
90
83
|
name: fakeweb
|
91
|
-
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
92
85
|
none: false
|
93
|
-
requirements:
|
86
|
+
requirements:
|
94
87
|
- - ~>
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
hash: 27
|
97
|
-
segments:
|
98
|
-
- 1
|
99
|
-
- 3
|
100
|
-
- 0
|
88
|
+
- !ruby/object:Gem::Version
|
101
89
|
version: 1.3.0
|
102
|
-
requirement: *id005
|
103
|
-
prerelease: false
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
90
|
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ~>
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.3.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
106
99
|
name: faker
|
107
|
-
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
108
101
|
none: false
|
109
|
-
requirements:
|
102
|
+
requirements:
|
110
103
|
- - ~>
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
hash: 23
|
113
|
-
segments:
|
114
|
-
- 1
|
115
|
-
- 1
|
116
|
-
- 2
|
104
|
+
- !ruby/object:Gem::Version
|
117
105
|
version: 1.1.2
|
118
|
-
requirement: *id006
|
119
|
-
prerelease: false
|
120
|
-
- !ruby/object:Gem::Dependency
|
121
106
|
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ~>
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: 1.1.2
|
114
|
+
- !ruby/object:Gem::Dependency
|
122
115
|
name: guard-rspec
|
123
|
-
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
124
117
|
none: false
|
125
|
-
requirements:
|
118
|
+
requirements:
|
126
119
|
- - ~>
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
|
129
|
-
segments:
|
130
|
-
- 0
|
131
|
-
- 5
|
132
|
-
- 0
|
133
|
-
version: 0.5.0
|
134
|
-
requirement: *id007
|
135
|
-
prerelease: false
|
136
|
-
- !ruby/object:Gem::Dependency
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 2.4.0
|
137
122
|
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ~>
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: 2.4.0
|
130
|
+
- !ruby/object:Gem::Dependency
|
138
131
|
name: growl
|
139
|
-
|
132
|
+
requirement: !ruby/object:Gem::Requirement
|
140
133
|
none: false
|
141
|
-
requirements:
|
134
|
+
requirements:
|
142
135
|
- - ~>
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
hash: 17
|
145
|
-
segments:
|
146
|
-
- 1
|
147
|
-
- 0
|
148
|
-
- 3
|
136
|
+
- !ruby/object:Gem::Version
|
149
137
|
version: 1.0.3
|
150
|
-
requirement: *id008
|
151
|
-
prerelease: false
|
152
|
-
- !ruby/object:Gem::Dependency
|
153
138
|
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.0.3
|
146
|
+
- !ruby/object:Gem::Dependency
|
154
147
|
name: rb-fsevent
|
155
|
-
|
148
|
+
requirement: !ruby/object:Gem::Requirement
|
156
149
|
none: false
|
157
|
-
requirements:
|
150
|
+
requirements:
|
158
151
|
- - ~>
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
hash: 63
|
161
|
-
segments:
|
162
|
-
- 0
|
163
|
-
- 9
|
164
|
-
- 2
|
152
|
+
- !ruby/object:Gem::Version
|
165
153
|
version: 0.9.2
|
166
|
-
|
154
|
+
type: :development
|
167
155
|
prerelease: false
|
168
|
-
|
156
|
+
version_requirements: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ~>
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: 0.9.2
|
162
|
+
description: ''
|
169
163
|
email: support@chargify.com
|
170
164
|
executables: []
|
171
|
-
|
172
165
|
extensions: []
|
173
|
-
|
174
166
|
extra_rdoc_files: []
|
175
|
-
|
176
|
-
files:
|
167
|
+
files:
|
177
168
|
- .gitignore
|
178
169
|
- .travis.yml
|
179
170
|
- Gemfile
|
@@ -205,10 +196,11 @@ files:
|
|
205
196
|
- lib/chargify_api_ares/resources/transaction.rb
|
206
197
|
- lib/chargify_api_ares/resources/usage.rb
|
207
198
|
- lib/chargify_api_ares/resources/webhook.rb
|
199
|
+
- lib/patches/activemodel_3_0_patch.rb
|
208
200
|
- spec/factories.rb
|
209
201
|
- spec/remote/remote.example.yml
|
202
|
+
- spec/remote/remote_helper.rb
|
210
203
|
- spec/remote/remote_spec.rb
|
211
|
-
- spec/remote/spec_helper.rb
|
212
204
|
- spec/resources/base_spec.rb
|
213
205
|
- spec/resources/coupon_spec.rb
|
214
206
|
- spec/resources/customer_spec.rb
|
@@ -223,42 +215,33 @@ files:
|
|
223
215
|
- spec/support/fake_resource.rb
|
224
216
|
homepage: http://github.com/chargify/chargify_api_ares
|
225
217
|
licenses: []
|
226
|
-
|
227
218
|
post_install_message:
|
228
219
|
rdoc_options: []
|
229
|
-
|
230
|
-
require_paths:
|
220
|
+
require_paths:
|
231
221
|
- lib
|
232
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
222
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
233
223
|
none: false
|
234
|
-
requirements:
|
235
|
-
- -
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
|
238
|
-
|
239
|
-
- 0
|
240
|
-
version: "0"
|
241
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
224
|
+
requirements:
|
225
|
+
- - ! '>='
|
226
|
+
- !ruby/object:Gem::Version
|
227
|
+
version: '0'
|
228
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
242
229
|
none: false
|
243
|
-
requirements:
|
244
|
-
- -
|
245
|
-
- !ruby/object:Gem::Version
|
246
|
-
|
247
|
-
segments:
|
248
|
-
- 0
|
249
|
-
version: "0"
|
230
|
+
requirements:
|
231
|
+
- - ! '>='
|
232
|
+
- !ruby/object:Gem::Version
|
233
|
+
version: '0'
|
250
234
|
requirements: []
|
251
|
-
|
252
235
|
rubyforge_project:
|
253
|
-
rubygems_version: 1.8.
|
236
|
+
rubygems_version: 1.8.23
|
254
237
|
signing_key:
|
255
238
|
specification_version: 3
|
256
239
|
summary: A Chargify API wrapper for Ruby using ActiveResource
|
257
|
-
test_files:
|
240
|
+
test_files:
|
258
241
|
- spec/factories.rb
|
259
242
|
- spec/remote/remote.example.yml
|
243
|
+
- spec/remote/remote_helper.rb
|
260
244
|
- spec/remote/remote_spec.rb
|
261
|
-
- spec/remote/spec_helper.rb
|
262
245
|
- spec/resources/base_spec.rb
|
263
246
|
- spec/resources/coupon_spec.rb
|
264
247
|
- spec/resources/customer_spec.rb
|