pagarme 1.3 → 1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Zjc2N2JjZjZhYWZhMTViNjViNDhlNmRiOGNlZjlkODM1OWY4MzNkNw==
4
+ OWU1ZGY0YjVkOGYwNjJmZGZmZjdlYzYxYjBiYzI4MjEwM2FjMGI0MQ==
5
5
  data.tar.gz: !binary |-
6
- YzEzNTNmYWY3NWQyZWRkYTMzODlkNjJhZjg5MjM1M2Q2ZjEwZTI3NQ==
6
+ NTFlNjZkOGI0MTM2MGM1YmM1ZGZiZDkwODg3NDZkNTA3ZjFlMTVjMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2VlMDYwMTIyZDA1MDk4ODdlNTg2ZmFhZjNjM2E2NGViYjcyY2YzNjEwYjMz
10
- ZmU2OTYxMWEzZTg3Y2FhZDQxOTk2ZGRmZTM4YmRmZjUyYzA4NTQ0ZDc4ZDdh
11
- ZTA2M2ZiNzcxNjM2YzMzMWRhNDNhNzJiMTc4NjA5NTQ2MjE0MjM=
9
+ OWIwNWEyN2ZhMjM4ODFmM2E3N2E0Yzk1MTU4YjlkZDFlMDYxMWUyZmRjNDIy
10
+ N2FlYWYwNzljNDkxZjM1NjZiZGZlYzYyZWJjMzRhZTU5Njk2YzRkNDIxYjc5
11
+ MTc4OGIzMDc3MDVkZDgwMjA5NWQ0MDA0OWY1YzVkODk0ZGYyZmU=
12
12
  data.tar.gz: !binary |-
13
- OTI1OTg5YzgzYjFhMmRlYTkxZTIyY2NjZWZmNTQwZGE5ZjY4ZWYzNjYwYmFm
14
- M2I5MjhlYWEzZTMyM2E3MzZjY2FmZGM1ZTVlY2UzMjM2YzhjMmVkZDQ4MzU1
15
- ZGViNjEzN2I1YWQwMWEwYTAwZDAyMTY2ZTM1YTlkYWZjYTUzZjU=
13
+ ZDQ1NjhkOWQ2MDZiMWM5NmU3MzE5NmVhYTg5OWVhNTAxNDc5ZTBjZmQxZjA0
14
+ MGMyMTQ5MjEwYmFiNDkxMDJkNTBlYzNjZTY3MmYyMDhjMjY2NDA4Yjk4OGQ0
15
+ MzEyMWYyOWNlNTMzYzI1YjYwM2M0Y2FkYjM1YjNhYWI3YTgyOWQ=
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pagarme (1.2)
4
+ pagarme (1.3)
5
5
  multi_json
6
6
  rest-client
7
7
 
@@ -27,7 +27,6 @@ module PagarMe
27
27
  def save
28
28
  request = PagarMe::Request.new(self.url, 'PUT')
29
29
  request.parameters = self.unsaved_values
30
- puts request.parameters.inspect
31
30
  response = request.run
32
31
  update(response)
33
32
  end
@@ -23,6 +23,12 @@ module PagarMe
23
23
  super
24
24
  end
25
25
 
26
+ def cancel
27
+ request = PagarMe::Request.new(self.url + '/cancel', 'POST')
28
+ response = request.run
29
+ update(response)
30
+ end
31
+
26
32
  def charge(amount)
27
33
  request = PagarMe::Request.new(self.url, 'POST')
28
34
  request.parameters = {
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "pagarme"
7
- spec.version = 1.3
7
+ spec.version = 1.4
8
8
  spec.authors = ["Pedro Franceschi", "Henrique Dubugras"]
9
9
  spec.email = ["pedrohfranceschi@gmail.com", "henrique@pagar.me"]
10
10
  spec.description = %q{Pagar.me's ruby gem}
@@ -2,70 +2,62 @@
2
2
  require_relative '../test_helper'
3
3
 
4
4
  module PagarMe
5
- class SubscriptionTest < Test::Unit::TestCase
6
- should 'be able to create subscription with plan' do
7
- plan = test_plan
8
- plan.create
9
- subscription = test_subscription
10
- subscription.plan = plan
11
- subscription.create
12
- test_plan_response(subscription.plan)
13
- test_transaction_with_customer(subscription)
14
- end
5
+ class SubscriptionTest < Test::Unit::TestCase
6
+ should 'be able to create subscription with plan' do
7
+ plan = test_plan
8
+ plan.create
9
+ subscription = test_subscription
10
+ subscription.plan = plan
11
+ subscription.create
12
+ test_plan_response(subscription.plan)
13
+ test_transaction_with_customer(subscription)
14
+ end
15
15
 
16
- should 'be able to create subscription without plan' do
17
- subscription = test_subscription({:amount => 2000})
18
- subscription.create
19
- assert subscription.transactions.length == 1
20
- subscription.charge(2000)
21
- assert subscription.transactions.length == 2
22
- assert subscription.transactions.first.kind_of?(PagarMe::Transaction)
23
- subscription.transactions.each do |t|
24
- test_subscription_transaction_response(t)
25
- end
16
+ should 'be able to create subscription without plan' do
17
+ subscription = test_subscription({:amount => 2000})
18
+ subscription.create
19
+ assert subscription.transactions.length == 1
20
+ subscription.charge(2000)
21
+ assert subscription.transactions.length == 2
22
+ assert subscription.transactions.first.kind_of?(PagarMe::Transaction)
23
+ subscription.transactions.each do |t|
24
+ test_subscription_transaction_response(t)
26
25
  end
26
+ end
27
27
 
28
- should 'be able to change plans' do
29
- subscription = test_subscription
30
- plan = test_plan
31
- plan.create
32
-
33
- plan2 = PagarMe::Plan.new({
34
- :name => "Plano Silver",
35
- :days => 30,
36
- :amount => 3000
37
- });
38
- plan2.create
39
-
40
- subscription.plan = plan
41
- subscription.create
28
+ should 'be able to change plans' do
29
+ subscription = test_subscription
30
+ plan = test_plan
31
+ plan.create
42
32
 
43
- assert subscription.plan.id == plan.id
44
- subscription.plan = plan2
45
- subscription.save
33
+ plan2 = PagarMe::Plan.new({
34
+ :name => "Plano Silver",
35
+ :days => 30,
36
+ :amount => 3000
37
+ });
38
+ plan2.create
46
39
 
47
- assert subscription.plan.id == plan2.id
48
- end
40
+ subscription.plan = plan
41
+ subscription.create
49
42
 
50
- # should 'be able to change from a plan with trial to a plan without trial' do
51
- # subscription = test_subscription
52
- # plan = test_plan
53
- # plan.create
43
+ assert subscription.plan.id == plan.id
44
+ subscription.plan = plan2
45
+ subscription.save
54
46
 
55
- # plan2 = test_plan
56
- # plan2.trial_days = nil
47
+ assert subscription.plan.id == plan2.id
48
+ end
57
49
 
58
- # subscription.plan = plan
59
- # subscription.create
50
+ should 'be able to cancel a subscription' do
51
+ subscription = test_subscription
52
+ plan = test_plan
53
+ plan.create
60
54
 
61
- # assert subscription.plan_id == plan.id
55
+ subscription.plan = plan
56
+ subscription.create
62
57
 
63
- # subscription.plan = plan2
64
- # subscription.save
58
+ subscription.cancel
65
59
 
66
- # assert subscription.plan_id == plan2.id
67
- # p = PagarMe::Plan.find_by_id(subscription.plan_id)
68
- # assert p.trial_days == nil
69
- # end
60
+ assert subscription.status == 'canceled'
70
61
  end
62
+ end
71
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagarme
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.3'
4
+ version: '1.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Franceschi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-25 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler