catarse_pagarme 2.13.0 → 2.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/Gemfile.lock +28 -16
- data/app/controllers/catarse_pagarme/credit_cards_controller.rb +2 -3
- data/app/models/catarse_pagarme/antifraud_order_wrapper.rb +148 -0
- data/app/models/catarse_pagarme/balance_transfer_delegator.rb +5 -1
- data/app/models/catarse_pagarme/credit_card_transaction.rb +48 -11
- data/app/models/catarse_pagarme/payment_delegator.rb +7 -3
- data/catarse_pagarme.gemspec +2 -1
- data/lib/catarse_pagarme.rb +2 -1
- data/lib/catarse_pagarme/configuration.rb +2 -1
- data/lib/catarse_pagarme/version.rb +1 -1
- data/spec/dummy/app/models/payment.rb +4 -0
- data/spec/dummy/app/models/payment_engines.rb +4 -0
- data/spec/dummy/config/initializers/pagarme.rb +1 -0
- data/spec/models/catarse_pagarme/antifraud_order_wrapper_spec.rb +366 -0
- data/spec/models/catarse_pagarme/credit_card_transaction_spec.rb +225 -37
- data/spec/models/catarse_pagarme/payment_delegator_spec.rb +33 -15
- data/spec/support/factories.rb +5 -5
- metadata +34 -2
@@ -171,8 +171,7 @@ describe CatarsePagarme::PaymentDelegator do
|
|
171
171
|
|
172
172
|
|
173
173
|
describe "#change_status_by_transaction" do
|
174
|
-
|
175
|
-
%w(paid authorized).each do |status|
|
174
|
+
%w(paid).each do |status|
|
176
175
|
context "when status is #{status}" do
|
177
176
|
context "when payment is refunded" do
|
178
177
|
before do
|
@@ -219,33 +218,52 @@ describe CatarsePagarme::PaymentDelegator do
|
|
219
218
|
end
|
220
219
|
|
221
220
|
context "when status is pending_review" do
|
222
|
-
|
221
|
+
it 'notifies pending reviews' do
|
223
222
|
expect(payment).to receive(:notify_about_pending_review)
|
223
|
+
|
224
224
|
delegator.change_status_by_transaction('pending_review')
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'should keep state in current_status' do
|
228
|
-
expect
|
228
|
+
expect {
|
229
|
+
delegator.change_status_by_transaction('pending_review')
|
230
|
+
}.to_not change(payment, :state)
|
229
231
|
end
|
230
232
|
end
|
231
233
|
|
232
234
|
context "when status is refunded" do
|
233
|
-
context
|
234
|
-
before
|
235
|
-
|
236
|
-
|
237
|
-
|
235
|
+
context 'when payment state is pending' do
|
236
|
+
before { payment.stub(:pending?).and_return(true) }
|
237
|
+
|
238
|
+
it 'refuses payment' do
|
239
|
+
expect(payment).to receive(:refuse)
|
238
240
|
|
239
|
-
|
241
|
+
delegator.change_status_by_transaction('refunded')
|
242
|
+
end
|
240
243
|
end
|
241
244
|
|
242
|
-
context
|
243
|
-
before
|
244
|
-
|
245
|
-
|
245
|
+
context 'when payment state isn`t pending' do
|
246
|
+
before { payment.stub(:pending?).and_return(false) }
|
247
|
+
|
248
|
+
context 'when payment state is refunded' do
|
249
|
+
before { payment.stub(:refunded?).and_return(true) }
|
250
|
+
|
251
|
+
it 'doesn`t refund payment again' do
|
252
|
+
expect(payment).to_not receive(:refund)
|
253
|
+
|
254
|
+
delegator.change_status_by_transaction('refunded')
|
255
|
+
end
|
246
256
|
end
|
247
257
|
|
248
|
-
|
258
|
+
context 'when payment state isn`t refunded' do
|
259
|
+
before { payment.stub(:refunded?).and_return(false) }
|
260
|
+
|
261
|
+
it 'refunds payment' do
|
262
|
+
expect(payment).to receive(:refund)
|
263
|
+
|
264
|
+
delegator.change_status_by_transaction('refunded')
|
265
|
+
end
|
266
|
+
end
|
249
267
|
end
|
250
268
|
end
|
251
269
|
|
data/spec/support/factories.rb
CHANGED
@@ -42,13 +42,13 @@ FactoryGirl.define do
|
|
42
42
|
f.code { generate(:serial) }
|
43
43
|
end
|
44
44
|
|
45
|
-
factory :balance_transfer do |f|
|
45
|
+
factory :balance_transfer do |f|
|
46
46
|
f.association :user
|
47
47
|
f.association :project
|
48
48
|
f.amount 100
|
49
49
|
end
|
50
50
|
|
51
|
-
factory :balance_transaction do |f|
|
51
|
+
factory :balance_transaction do |f|
|
52
52
|
f.association :user
|
53
53
|
f.association :project
|
54
54
|
f.amount 100
|
@@ -87,7 +87,7 @@ FactoryGirl.define do
|
|
87
87
|
f.state 'online'
|
88
88
|
f.budget '1000'
|
89
89
|
f.uploaded_image File.open("#{Rails.root}/spec/support/testimg.png")
|
90
|
-
after :create do |project|
|
90
|
+
after :create do |project|
|
91
91
|
unless project.project_transitions.where(to_state: project.state).present?
|
92
92
|
FactoryGirl.create(:project_transition, to_state: project.state, project: project)
|
93
93
|
end
|
@@ -108,7 +108,7 @@ FactoryGirl.define do
|
|
108
108
|
f.association :project
|
109
109
|
f.state 'draft'
|
110
110
|
|
111
|
-
after :create do |flex_project|
|
111
|
+
after :create do |flex_project|
|
112
112
|
FactoryGirl.create(:flexible_project_transition, {
|
113
113
|
to_state: flex_project.state,
|
114
114
|
flexible_project: flex_project
|
@@ -153,7 +153,7 @@ FactoryGirl.define do
|
|
153
153
|
factory :contribution do |f|
|
154
154
|
f.association :project, factory: :project
|
155
155
|
f.association :user, factory: :user
|
156
|
-
f.phone_number '(33) 3333-3333'
|
156
|
+
# f.phone_number '(33) 3333-3333'
|
157
157
|
f.address_neighbourhood 'lorem'
|
158
158
|
f.address_number 'lnumber'
|
159
159
|
f.address_street 'lstreet lorem'
|
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.
|
4
|
+
version: 2.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antônio Roberto Silva
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: countries
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - '='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 3.0.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - '='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 3.0.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: rails
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,6 +53,20 @@ dependencies:
|
|
39
53
|
- - '='
|
40
54
|
- !ruby/object:Gem::Version
|
41
55
|
version: 2.1.4
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: konduto-ruby
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.1.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.1.0
|
42
70
|
- !ruby/object:Gem::Dependency
|
43
71
|
name: weekdays
|
44
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +174,7 @@ extensions: []
|
|
146
174
|
extra_rdoc_files: []
|
147
175
|
files:
|
148
176
|
- ".gitignore"
|
177
|
+
- ".ruby-gemset"
|
149
178
|
- ".ruby-version"
|
150
179
|
- Gemfile
|
151
180
|
- Gemfile.lock
|
@@ -160,6 +189,7 @@ files:
|
|
160
189
|
- app/controllers/catarse_pagarme/pagarme_controller.rb
|
161
190
|
- app/controllers/catarse_pagarme/slip_controller.rb
|
162
191
|
- app/helpers/catarse_pagarme/application_helper.rb
|
192
|
+
- app/models/catarse_pagarme/antifraud_order_wrapper.rb
|
163
193
|
- app/models/catarse_pagarme/balance_transfer_concern.rb
|
164
194
|
- app/models/catarse_pagarme/balance_transfer_delegator.rb
|
165
195
|
- app/models/catarse_pagarme/bank_account_concern.rb
|
@@ -248,6 +278,7 @@ files:
|
|
248
278
|
- spec/dummy/public/favicon.ico
|
249
279
|
- spec/dummy/spec/support/testimg.png
|
250
280
|
- spec/helpers/catarse_pagarme/application_helper_spec.rb
|
281
|
+
- spec/models/catarse_pagarme/antifraud_order_wrapper_spec.rb
|
251
282
|
- spec/models/catarse_pagarme/balance_transfer_delegator_spec.rb
|
252
283
|
- spec/models/catarse_pagarme/bank_account_concern_spec.rb
|
253
284
|
- spec/models/catarse_pagarme/credit_card_transaction_spec.rb
|
@@ -346,6 +377,7 @@ test_files:
|
|
346
377
|
- spec/dummy/public/favicon.ico
|
347
378
|
- spec/dummy/spec/support/testimg.png
|
348
379
|
- spec/helpers/catarse_pagarme/application_helper_spec.rb
|
380
|
+
- spec/models/catarse_pagarme/antifraud_order_wrapper_spec.rb
|
349
381
|
- spec/models/catarse_pagarme/balance_transfer_delegator_spec.rb
|
350
382
|
- spec/models/catarse_pagarme/bank_account_concern_spec.rb
|
351
383
|
- spec/models/catarse_pagarme/credit_card_transaction_spec.rb
|