payanyway 2.2.2 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec20fa22eac6fe28a84e5b4b48993a54abe54c4d
4
- data.tar.gz: 271f6554266aa649a5c9088072bd830a9386cbd4
3
+ metadata.gz: 4e33b66444fe5d3e523b35f0c073aa7aea22980f
4
+ data.tar.gz: 332ff3a34247a16adb5e56cd2db721475c05e394
5
5
  SHA512:
6
- metadata.gz: b4e2a25a37505919c413f14bc8f5081f105fa1aec256d49df886f3f1bc791ac9e64ea76a0b9878bbf3ffea057d9382edaddf0d39396b4853418f9f9bc0208280
7
- data.tar.gz: 30d9598c5f03355870b1e22f4065be50abf7cc198052ca59caa3a306109156b77c01613ea23dca130c2d981dc5405614b16067468b72f04eca85e23e1163cb2e
6
+ metadata.gz: e1a4978bbc46b43539635e57124547da095d1341bb78edc3c11ea6ab78da1fe394c5a8865ec63fd59d9624468ae9927a0717d99467a03751d384668f2017e55c
7
+ data.tar.gz: 8591c4065a4096d72f12f6e8eec6b5388446006b978cc73c291f90c397b77fa2e636a6d610ae4b6f159a37485539d83f60807513f7a81732beb92085c9bf8086
@@ -1,8 +1,8 @@
1
1
  Payanyway::Engine.routes.draw do
2
2
  get 'success' => 'payanyway#success', as: :payanyway_on_success
3
- get 'pay' => 'payanyway#pay', as: :payanyway_pay
3
+ match 'pay' => 'payanyway#pay', as: :payanyway_pay, via: [:get, :post]
4
4
  get 'fail' => 'payanyway#fail', as: :payanyway_on_fail
5
5
  get 'return' => 'payanyway#return', as: :payanyway_on_return
6
6
  get 'in_progress' => 'payanyway#in_progress', as: :payanyway_in_progress
7
- get 'check' => 'payanyway#check', as: :payanyway_on_check
7
+ match 'check' => 'payanyway#check', as: :payanyway_on_check, via: [:get, :post]
8
8
  end
@@ -4,6 +4,11 @@ module Payanyway
4
4
 
5
5
  included do
6
6
  protect_from_forgery with: :null_session
7
+ if respond_to?(:skip_before_action)
8
+ skip_before_action :verify_authenticity_token
9
+ else
10
+ skip_before_filter :verify_authenticity_token
11
+ end
7
12
  end
8
13
 
9
14
  def pay
@@ -1,3 +1,3 @@
1
1
  module Payanyway
2
- VERSION = '2.2.2'
2
+ VERSION = '2.3.0'
3
3
  end
@@ -10,6 +10,15 @@ describe PayanywayController do
10
10
 
11
11
  end
12
12
 
13
+ describe 'POST #pay' do
14
+
15
+ it 'should render "FAIL" text' do
16
+ post :pay
17
+ expect(response.body).to eq('FAIL')
18
+ end
19
+
20
+ end
21
+
13
22
  describe 'GET #success' do
14
23
  it 'should add message to logger' do
15
24
  expect(Rails.logger).to receive(:info).with("PAYANYWAY: Called success payment url for order '676'").and_call_original
@@ -42,37 +51,53 @@ describe PayanywayController do
42
51
  end
43
52
  end
44
53
 
45
- describe 'GET #check' do
46
- context 'when empty params' do
47
- it 'should raise error' do
48
- expect{ get :check }.not_to raise_error
54
+ [:get, :post].each do |method|
55
+
56
+ describe "#{method.upcase} #check" do
57
+ context 'when empty params' do
58
+ it 'should raise error' do
59
+ expect{
60
+ public_send(method, :check)
61
+ }.not_to raise_error
62
+ end
49
63
  end
50
- end
51
64
 
52
- context 'when invalid signature' do
53
- it 'should raise error' do
54
- expect{ get(:check, { 'MNT_TRANSACTION_ID' => 676 }) }.to raise_error
65
+ context 'when invalid signature' do
66
+ it 'should raise error' do
67
+ expect{ public_send(method, :check, { 'MNT_TRANSACTION_ID' => 676 }) }.to raise_error
68
+ end
55
69
  end
56
- end
57
70
 
58
- context 'when valid signature' do
59
- it 'should add message to logger' do
60
- expect(Rails.logger).not_to receive(:info).with(/PAYANYWAY: XML response for check/)
61
- expect_any_instance_of(Payanyway::Controller).to receive(:check_implementation).and_return(amount: 12, state: :paid)
71
+ context 'when valid signature' do
72
+ it 'should add message to logger' do
73
+ expect(Rails.logger).not_to receive(:info).with(/PAYANYWAY: XML response for check/)
74
+ expect_any_instance_of(Payanyway::Controller).
75
+ to receive(:check_implementation).and_return(amount: 12, state: :paid)
62
76
 
63
- get :check, { 'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s, 'MNT_TRANSACTION_ID' => 676, 'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811' }
77
+ public_send method, :check, {
78
+ 'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s,
79
+ 'MNT_TRANSACTION_ID' => 676,
80
+ 'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811'
81
+ }
64
82
 
65
- expect(Nokogiri::XML(response.body).at_css('MNT_RESPONSE')).to be_present
83
+ expect(Nokogiri::XML(response.body).at_css('MNT_RESPONSE')).to be_present
84
+ end
66
85
  end
67
- end
68
-
69
- context 'when logger flag is true' do
70
- it 'should add message to logger' do
71
- expect(Rails.logger).to receive(:info).with(/PAYANYWAY: XML response for check/)
72
86
 
73
- expect_any_instance_of(Payanyway::Controller).to receive(:check_implementation).and_return(amount: 12, state: :paid, logger: true)
74
- get :check, { 'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s, 'MNT_TRANSACTION_ID' => 676, 'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811' }
87
+ context 'when logger flag is true' do
88
+ it 'should add message to logger' do
89
+ expect(Rails.logger).to receive(:info).with(/PAYANYWAY: XML response for check/)
90
+
91
+ expect_any_instance_of(Payanyway::Controller).
92
+ to receive(:check_implementation).and_return(amount: 12, state: :paid, logger: true)
93
+ public_send method, :check, {
94
+ 'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s,
95
+ 'MNT_TRANSACTION_ID' => 676,
96
+ 'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811'
97
+ }
98
+ end
75
99
  end
76
100
  end
101
+
77
102
  end
78
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payanyway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssnikolay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails