catarse_pagarme 2.7.6 → 2.7.7

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: f6cf63973dd886ba8c5d27c0b298f30812ffe9e9
4
- data.tar.gz: 3ffbcb1761d21d21cbc5ad41015d277d6af966f9
3
+ metadata.gz: 8e8bbb31e0174af0ee3e4de0efaea4c10fb0384b
4
+ data.tar.gz: 75c632f18a64aceddbad27ce548ec4550f5bb048
5
5
  SHA512:
6
- metadata.gz: ab663e3744a0c647dedf9aaf15e4be62174213a7d833b0625816871797e1c5d6235bec1c87061997d95d567ea4e347a59b613f5e60a4c055d198bf02f2fb6109
7
- data.tar.gz: 02bdb171b420db9455e647dc4d522bc78f51cb8a645835540af593bc31d059e04af7ca9488845e50a10575ca33b39c4150f2a67fbc0e8f3e970ff64a1080973a
6
+ metadata.gz: 517aed8b6eb577a19a2d7d35d9f35c6049b0bf95b896c83da29f3e023fc73c4d15095d367faf5e2e9cb3c07b596a871250f58c813b8a4e6d20566c880a7edb90
7
+ data.tar.gz: b50189ff5a90b837c01f5b4db758f95b308be91c32c7f8cec04c865d71a89291ce2657c001f9e153b1492749612c300dc16df4a8f17c7e99a70e4a894524126e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.7.6)
4
+ catarse_pagarme (2.7.7)
5
5
  pagarme (= 1.10.0)
6
6
  rails (~> 4.0)
7
7
  sidekiq
@@ -19,7 +19,7 @@ module CatarsePagarme::FeeCalculatorConcern
19
19
 
20
20
  def get_card_fee
21
21
  return nil if self.payment.gateway_data["acquirer_name"].blank? # Here we depend on the acquirer name
22
- if self.payment.gateway_data["acquirer_name"] == 'stone'
22
+ if %w(stone pagarme).include? self.payment.gateway_data["acquirer_name"]
23
23
  get_stone_fee
24
24
  else
25
25
  get_cielo_fee
@@ -69,12 +69,15 @@ module CatarsePagarme
69
69
  end
70
70
 
71
71
  def transaction
72
- @transaction ||= ::PagarMe::Transaction.find_by_id(self.payment.gateway_id)
73
- if @transaction.kind_of?(Array)
74
- @transaction.last
75
- else
76
- @transaction
77
- end
72
+ gateway_id = self.payment.gateway_id
73
+ raise "no gateway_id present" unless gateway_id.present?
74
+
75
+ @transaction ||= ::PagarMe::Transaction.find_by_id(gateway_id)
76
+ _transaction = @transaction.kind_of?(Array) ? @transaction.last : @transaction
77
+
78
+ raise "transaction gateway not match" unless _transaction.id == gateway_id
79
+
80
+ _transaction
78
81
  end
79
82
 
80
83
  def get_installment(installment_number)
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.7.6"
2
+ VERSION = "2.7.7"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe CatarsePagarme::NotificationsController do
4
- let(:fake_transaction) { double("fake transaction", card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
4
+ let(:fake_transaction) { double("fake transaction", id: payment.gateway_id, card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
5
5
 
6
6
  before do
7
7
  PagarMe.stub(:validate_fingerprint).and_return(true)
@@ -10,8 +10,8 @@ describe CatarsePagarme::NotificationsController do
10
10
 
11
11
  let(:project) { create(:project, goal: 10_000, state: 'online') }
12
12
  let(:contribution) { create(:contribution, value: 10, project: project) }
13
- let(:payment) {
14
- p = contribution.payments.first
13
+ let(:payment) {
14
+ p = contribution.payments.first
15
15
  p.update_attributes gateway_id: 'abcd'
16
16
  p
17
17
  }
@@ -4,7 +4,7 @@ describe CatarsePagarme::PaymentDelegator do
4
4
  let(:contribution) { create(:contribution, value: 10) }
5
5
  let(:payment) { contribution.payments.first }
6
6
  let(:delegator) { payment.pagarme_delegator }
7
- let(:fake_transaction) { double("fake transaction", card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
7
+ let(:fake_transaction) { double("fake transaction", id: payment.gateway_id, card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
8
8
 
9
9
  before do
10
10
  CatarsePagarme.configuration.stub(:slip_tax).and_return(2.00)
@@ -100,6 +100,43 @@ describe CatarsePagarme::PaymentDelegator do
100
100
  end
101
101
  end
102
102
 
103
+ describe "#transaction" do
104
+ before do
105
+ delegator.unstub(:transaction)#.and_return(fake_transaction)
106
+ allow(PagarMe::Transaction).to receive(:find_by_id).and_return(fake_transaction)
107
+ end
108
+
109
+ context "when payment.gateway id is null" do
110
+ before do
111
+ allow(payment).to receive(:gateway_id).and_return(nil)
112
+ end
113
+
114
+ it "expect to raises an error" do
115
+ expect {
116
+ delegator.transaction
117
+ }.to raise_error("no gateway_id present")
118
+ end
119
+ end
120
+
121
+ context "when transaction.id dont match with gateway_id" do
122
+ before do
123
+ allow(fake_transaction).to receive(:id).and_return("123")
124
+ end
125
+
126
+ it "expect to raises an error" do
127
+ expect {
128
+ delegator.transaction
129
+ }.to raise_error("transaction gateway not match")
130
+ end
131
+ end
132
+
133
+ context "when have correct transaction" do
134
+ it "should return the transaction object" do
135
+ expect(delegator.transaction).to eq(fake_transaction)
136
+ end
137
+ end
138
+ end
139
+
103
140
  describe "#transfer_funds" do
104
141
  let(:admin_user) { create(:user, admin: true) }
105
142
  let(:transfer_mock) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catarse_pagarme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.6
4
+ version: 2.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antônio Roberto Silva
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-11 00:00:00.000000000 Z
12
+ date: 2015-08-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails