From 44a704f10c6eb39863a0742ec6cdcb52e961ebfd Mon Sep 17 00:00:00 2001 From: Cody Fauser Date: Fri, 12 Nov 2010 09:50:24 -0600 Subject: [PATCH] [ruby19-compat] Updates to get tests passing in Ruby 1.9.2 --- Rakefile | 6 ++-- .../billing/gateways/first_pay.rb | 2 +- .../billing/gateways/paybox_direct.rb | 2 -- .../integrations/quickpay/notification.rb | 2 +- lib/active_merchant/common/country.rb | 2 +- lib/support/gateway_support.rb | 2 +- test/unit/gateways/secure_net_test.rb | 2 +- .../integrations/action_view_helper_test.rb | 29 +++++-------------- 8 files changed, 17 insertions(+), 30 deletions(-) diff --git a/Rakefile b/Rakefile index 572d2e7dc21..a40fec6c691 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,12 @@ +$:.unshift File.expand_path('../lib', __FILE__) + require 'rubygems' require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'rake/gempackagetask' -require 'lib/support/gateway_support' -require 'lib/support/outbound_hosts' +require 'support/gateway_support' +require 'support/outbound_hosts' desc "Run the unit test suite" task :default => 'test:units' diff --git a/lib/active_merchant/billing/gateways/first_pay.rb b/lib/active_merchant/billing/gateways/first_pay.rb index 8d748862d53..e107e0fcd39 100644 --- a/lib/active_merchant/billing/gateways/first_pay.rb +++ b/lib/active_merchant/billing/gateways/first_pay.rb @@ -89,7 +89,7 @@ def add_address(post, options) end def add_invoice(post, options) - post[:trackid] = rand(Time.now) + post[:trackid] = rand(Time.now.to_i) end def add_creditcard(post, creditcard) diff --git a/lib/active_merchant/billing/gateways/paybox_direct.rb b/lib/active_merchant/billing/gateways/paybox_direct.rb index 78f0466d81b..c66ecb74f69 100644 --- a/lib/active_merchant/billing/gateways/paybox_direct.rb +++ b/lib/active_merchant/billing/gateways/paybox_direct.rb @@ -147,8 +147,6 @@ def commit(action, money = nil, parameters = nil) :timestamp => parameters[:dateq]), :test => test?, :authorization => response[:numappel].to_s + response[:numtrans].to_s, - :cvv_result => '', - :avs_result => '', :fraud_review => fraud_review?(response), :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)} ) diff --git a/lib/active_merchant/billing/integrations/quickpay/notification.rb b/lib/active_merchant/billing/integrations/quickpay/notification.rb index d9a62425232..18d602d889d 100644 --- a/lib/active_merchant/billing/integrations/quickpay/notification.rb +++ b/lib/active_merchant/billing/integrations/quickpay/notification.rb @@ -18,7 +18,7 @@ def transaction_id end def received_at - Time.local(*params['time'].scan(/../)) + Time.parse("20#{params['time']}") end def gross diff --git a/lib/active_merchant/common/country.rb b/lib/active_merchant/common/country.rb index 8d47cd63557..b59237fc8ba 100644 --- a/lib/active_merchant/common/country.rb +++ b/lib/active_merchant/common/country.rb @@ -46,7 +46,7 @@ def initialize(options = {}) end def code(format) - @codes.select{|c| c.format == format} + @codes.detect{|c| c.format == format} end def ==(other) diff --git a/lib/support/gateway_support.rb b/lib/support/gateway_support.rb index 9325beb5d06..9f1ed4dec1a 100644 --- a/lib/support/gateway_support.rb +++ b/lib/support/gateway_support.rb @@ -1,6 +1,6 @@ require 'rubygems' require 'active_support' -require 'lib/active_merchant' +require 'active_merchant' class GatewaySupport #:nodoc: diff --git a/test/unit/gateways/secure_net_test.rb b/test/unit/gateways/secure_net_test.rb index 1b35b9109b1..da2615aa102 100644 --- a/test/unit/gateways/secure_net_test.rb +++ b/test/unit/gateways/secure_net_test.rb @@ -122,7 +122,7 @@ def test_supported_card_types def test_failure_without_response_reason_text assert_nothing_raised do - assert_equal '', @gateway.send(:message_from, '') + assert_equal '', @gateway.send(:message_from, {}) end end diff --git a/test/unit/integrations/action_view_helper_test.rb b/test/unit/integrations/action_view_helper_test.rb index 8caa66c9319..ddad13cfdd9 100644 --- a/test/unit/integrations/action_view_helper_test.rb +++ b/test/unit/integrations/action_view_helper_test.rb @@ -24,17 +24,10 @@ def url_for(options, *parameters_for_method_reference) def test_basic_payment_service payment_service_for('order-1','test', :service => :bogus){} - - expected = [ - /^/, - //, - /<\/form>/ - ] - - @output_buffer.split("\n").reject(&:blank?).each_with_index do |line, index| - assert_match expected[index], line.chomp, "Failed to match #{line}" - end + assert_match(/^/, @output_buffer) + assert_match(//, @output_buffer) + assert_match(/<\/form>/, @output_buffer) end def test_payment_service_no_block_given @@ -81,16 +74,10 @@ def test_html_safety with_routes do get :payment_action - expected = [ - /^/, - //, - /<\/form>/ - ] - - @response.body.split("\n").reject(&:blank?).each_with_index do |line, index| - assert_match expected[index], line.chomp, "Failed to match #{line}" - end + assert_match(/^/, @response.body) + assert_match(//, @response.body) + assert_match(/<\/form>/, @response.body) end end