Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Make subscriptions cancellable #12

Merged
merged 1 commit into from

2 participants

@latentflip

Fixes: #11

Any problem with this? I tried to follow your coding/testing style as closely as possible.

Phil

@hmarr hmarr merged commit ee3cae4 into gocardless:master
@hmarr
Owner

Looks good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2012
  1. Make subscriptions cancellable

    Philip Roberts authored
This page is out of date. Refresh to see the latest.
Showing with 24 additions and 0 deletions.
  1. +6 −0 lib/gocardless/subscription.rb
  2. +18 −0 spec/subscription_spec.rb
View
6 lib/gocardless/subscription.rb
@@ -10,6 +10,12 @@ class Subscription < Resource
date_accessor :expires_at, :created_at
+
+ def cancel!
+ path = self.class.endpoint.gsub(':id', id.to_s) + '/cancel'
+ client.api_put(path)
+ end
+
end
end
View
18 spec/subscription_spec.rb
@@ -0,0 +1,18 @@
+require 'spec_helper'
+
+describe GoCardless::Subscription do
+ before :each do
+ @app_id = 'abc'
+ @app_secret = 'xyz'
+ GoCardless.account_details = {:app_id => @app_id, :app_secret => @app_secret,
+ :token => 'xxx manage_merchant:1'}
+ @client = GoCardless.client
+ end
+
+ it "should be cancellable" do
+ s = GoCardless::Subscription.new_with_client(@client, :id => '009988')
+ @client.expects(:api_put).with('/subscriptions/009988/cancel')
+ s.cancel!
+ end
+
+end
Something went wrong with that request. Please try again.