catarse_pagarme 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/app/models/catarse_pagarme/bank_account_concern.rb +58 -0
- data/catarse_pagarme.gemspec +1 -1
- data/lib/catarse_pagarme/version.rb +1 -1
- data/spec/models/catarse_pagarme/bank_account_concern_spec.rb +46 -0
- data/spec/support/factories.rb +8 -3
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82af437d4170d11ec0568aa0dd4213b0f004d87f
|
4
|
+
data.tar.gz: d90fccc765e6f0e94ddf5a9cdc4f651c1516eb4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b87260eb2c0d67658f85cce67e231f2b3c4681165b8c54e555a28568ad543245f29865455e37972d032e71fc326ef76a1e402343b9c71b8852933a29a575f7ad
|
7
|
+
data.tar.gz: ca702dbc70ecfd34497ca1becbb701dca9472f19a0d97cf40798421be344c2728ea81f048f999439c960291688a158c0be1a3bb75a824a14b3241887555e675c
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
catarse_pagarme (1.4.
|
5
|
-
pagarme (~> 1.9.
|
4
|
+
catarse_pagarme (1.4.4)
|
5
|
+
pagarme (~> 1.9.8)
|
6
6
|
rails (~> 4.0)
|
7
7
|
|
8
8
|
GEM
|
@@ -53,7 +53,7 @@ GEM
|
|
53
53
|
minitest (5.4.0)
|
54
54
|
multi_json (1.10.1)
|
55
55
|
netrc (0.8.0)
|
56
|
-
pagarme (1.9.
|
56
|
+
pagarme (1.9.8)
|
57
57
|
multi_json
|
58
58
|
rest-client
|
59
59
|
pg (0.17.1)
|
@@ -92,15 +92,15 @@ GEM
|
|
92
92
|
rspec-core (~> 2.14.0)
|
93
93
|
rspec-expectations (~> 2.14.0)
|
94
94
|
rspec-mocks (~> 2.14.0)
|
95
|
-
sprockets (2.12.
|
95
|
+
sprockets (2.12.3)
|
96
96
|
hike (~> 1.2)
|
97
97
|
multi_json (~> 1.0)
|
98
98
|
rack (~> 1.0)
|
99
99
|
tilt (~> 1.1, != 1.3.0)
|
100
|
-
sprockets-rails (2.
|
100
|
+
sprockets-rails (2.2.0)
|
101
101
|
actionpack (>= 3.0)
|
102
102
|
activesupport (>= 3.0)
|
103
|
-
sprockets (
|
103
|
+
sprockets (>= 2.8, < 4.0)
|
104
104
|
thor (0.19.1)
|
105
105
|
thread_safe (0.3.4)
|
106
106
|
tilt (1.4.1)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module CatarsePagarme::BankAccountConcern
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
|
6
|
+
validate :must_be_valid_on_pagarme
|
7
|
+
|
8
|
+
def must_be_valid_on_pagarme
|
9
|
+
pagarme_errors.each do |p_error|
|
10
|
+
_attr = attributes_parsed_from_pagarme[p_error.parameter_name.to_sym]
|
11
|
+
errors.add(_attr, :invalid)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def pagarme_errors
|
18
|
+
configure_pagarme
|
19
|
+
bank_account = ::PagarMe::BankAccount.new(attributes_parsed_to_pagarme)
|
20
|
+
|
21
|
+
begin
|
22
|
+
bank_account.create
|
23
|
+
|
24
|
+
true
|
25
|
+
rescue Exception => e
|
26
|
+
e.errors
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def attributes_parsed_to_pagarme
|
31
|
+
{
|
32
|
+
bank_code: self.bank.try(:code),
|
33
|
+
agencia: self.agency,
|
34
|
+
agencia_dv: self.agency_digit,
|
35
|
+
conta: self.account,
|
36
|
+
conta_dv: self.account_digit,
|
37
|
+
legal_name: self.owner_name,
|
38
|
+
document_number: self.owner_document
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def attributes_parsed_from_pagarme
|
43
|
+
{
|
44
|
+
bank_code: :bank,
|
45
|
+
agencia: :agency,
|
46
|
+
agencia_dv: :agency_digit,
|
47
|
+
conta: :account,
|
48
|
+
conta_dv: :account_digit,
|
49
|
+
legal_name: :owner_name,
|
50
|
+
document_number: :owner_document
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def configure_pagarme
|
55
|
+
::PagarMe.api_key = CatarsePagarme.configuration.api_key
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/catarse_pagarme.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
19
|
|
20
20
|
s.add_dependency "rails", "~> 4.0"
|
21
|
-
s.add_dependency "pagarme", "~> 1.9.
|
21
|
+
s.add_dependency "pagarme", "~> 1.9.8"
|
22
22
|
|
23
23
|
s.add_development_dependency "rspec-rails", "~> 2.14.0"
|
24
24
|
s.add_development_dependency "factory_girl_rails"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class FakeBankAccount < BankAccount
|
4
|
+
include CatarsePagarme::BankAccountConcern
|
5
|
+
end
|
6
|
+
|
7
|
+
describe FakeBankAccount do
|
8
|
+
let(:bank) { create(:bank) }
|
9
|
+
|
10
|
+
let(:valid_attr) do
|
11
|
+
vb = build(:bank_account, bank: bank)
|
12
|
+
vb.attributes
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:valid_attr_on_pagarme) do
|
16
|
+
{
|
17
|
+
bank_id: bank.id,
|
18
|
+
agency: '1732',
|
19
|
+
agency_dv: '8',
|
20
|
+
account: '25483',
|
21
|
+
account_dv: 'X',
|
22
|
+
owner_name: 'Lorem Ipsum',
|
23
|
+
owner_document: '111.111.111-11'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "validate :must_be_valid_on_pagarme" do
|
28
|
+
context "when bank account has invalid data on pagarme" do
|
29
|
+
let(:bank_account_on_pagarme) { FakeBankAccount.new(valid_attr) }
|
30
|
+
let(:local_bank_account) { BankAccount.new(valid_attr) }
|
31
|
+
|
32
|
+
it "local_bank_account should be valid" do
|
33
|
+
expect(local_bank_account.valid?).to be_true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "bank_account_on_pagarme should be not valid with these attrs" do
|
37
|
+
expect(bank_account_on_pagarme.valid?).to be_false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "bank_account_on_pagarme should be valid with another attrs" do
|
41
|
+
subject { FakeBankAccount.new(valid_attr_on_pagarme).valid? }
|
42
|
+
expect(subject).to be_true
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/support/factories.rb
CHANGED
@@ -32,14 +32,19 @@ FactoryGirl.define do
|
|
32
32
|
f.name_pt { generate(:name) }
|
33
33
|
end
|
34
34
|
|
35
|
+
factory :bank do |f|
|
36
|
+
f.name { generate(:uid) }
|
37
|
+
f.code { generate(:uid) }
|
38
|
+
end
|
39
|
+
|
35
40
|
factory :bank_account do |f|
|
36
|
-
f.
|
41
|
+
f.association :bank
|
37
42
|
f.account '1234'
|
38
43
|
f.account_digit '1'
|
39
44
|
f.agency '1'
|
40
45
|
f.agency_digit '2'
|
41
|
-
f.
|
42
|
-
f.
|
46
|
+
f.owner_name 'fooo'
|
47
|
+
f.owner_document '9889'
|
43
48
|
end
|
44
49
|
|
45
50
|
factory :project do |f|
|
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: 1.4.
|
4
|
+
version: 1.4.5
|
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: 2014-11-
|
12
|
+
date: 2014-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.9.
|
34
|
+
version: 1.9.8
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.9.
|
41
|
+
version: 1.9.8
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec-rails
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- app/controllers/catarse_pagarme/slip_controller.rb
|
111
111
|
- app/controllers/catarse_pagarme/subscriptions_controller.rb
|
112
112
|
- app/helpers/catarse_pagarme/application_helper.rb
|
113
|
+
- app/models/catarse_pagarme/bank_account_concern.rb
|
113
114
|
- app/models/catarse_pagarme/contribution_concern.rb
|
114
115
|
- app/models/catarse_pagarme/contribution_delegator.rb
|
115
116
|
- app/models/catarse_pagarme/credit_card_concern.rb
|
@@ -189,6 +190,7 @@ files:
|
|
189
190
|
- spec/dummy/public/500.html
|
190
191
|
- spec/dummy/public/favicon.ico
|
191
192
|
- spec/helpers/catarse_pagarme/application_helper_spec.rb
|
193
|
+
- spec/models/catarse_pagarme/bank_account_concern_spec.rb
|
192
194
|
- spec/models/catarse_pagarme/contribution_delegator_spec.rb
|
193
195
|
- spec/models/catarse_pagarme/credit_card_transaction_spec.rb
|
194
196
|
- spec/models/catarse_pagarme/slip_transaction_spec.rb
|
@@ -275,6 +277,7 @@ test_files:
|
|
275
277
|
- spec/dummy/public/500.html
|
276
278
|
- spec/dummy/public/favicon.ico
|
277
279
|
- spec/helpers/catarse_pagarme/application_helper_spec.rb
|
280
|
+
- spec/models/catarse_pagarme/bank_account_concern_spec.rb
|
278
281
|
- spec/models/catarse_pagarme/contribution_delegator_spec.rb
|
279
282
|
- spec/models/catarse_pagarme/credit_card_transaction_spec.rb
|
280
283
|
- spec/models/catarse_pagarme/slip_transaction_spec.rb
|