Skip to content

Commit

Permalink
Fixes bug of validations response
Browse files Browse the repository at this point in the history
  • Loading branch information
m.yermolovich committed May 25, 2012
1 parent 0eb26cf commit 8ef2007
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/bank_audi.rb
Expand Up @@ -96,7 +96,7 @@ def valid_vpc_secure_hash?
end

def valid_vpc_txn_response_code?
!(vpc_txn_response_code == '7' || vpc_txn_response_code.blank?)
vpc_txn_response_code == '0'
end

def sort_keys(attributes)
Expand Down
2 changes: 1 addition & 1 deletion lib/bank_audi/version.rb
@@ -1,3 +1,3 @@
module BankAudi
VERSION = "0.2.3"
VERSION = "0.2.4"
end
20 changes: 16 additions & 4 deletions spec/bank_audi_spec.rb
Expand Up @@ -83,6 +83,13 @@ def valid(request)
@response = BankAudi::Response.new
end

def valid(response)
response.attributes = { :access_code => 'XXXXXX', :amount => 100, :merchant_txn_ref => 'merchant-txn-ref',
:merchant => 'XXXXXX', :order_info => 'order-info', :return_url => 'http://www.google.com',
:vpc_secure_hash => 'B2384E5659611034CFFC95842C66A4BA', :vpc_txn_response_code => '0' }
response
end

it 'should initialize with default attributes' do
[:secret_code].each do |attribute|
@response.send(attribute).should_not be_blank
Expand All @@ -96,14 +103,19 @@ def valid(request)
end

it 'should be valid' do
@response.attributes = { :access_code => 'XXXXXX', :amount => 100, :merchant_txn_ref => 'merchant-txn-ref',
:merchant => 'XXXXXX', :order_info => 'order-info', :return_url => 'http://www.google.com',
:vpc_secure_hash => '82688C2F8F74B120E20C05CE7E4DC4F7', :vpc_txn_response_code => 'M' }
@response.should be_valid
valid(@response).should be_valid
end

it 'should be invalid' do
@response.should_not be_valid

response = valid(@response)
response.attributes[:vpc_txn_response_code] = 'M'
response.should_not be_valid

response = valid(@response)
response.attributes[:amount] = 200
response.should_not be_valid
end
end

Expand Down

0 comments on commit 8ef2007

Please sign in to comment.