Skip to content

Commit

Permalink
Update ActionViewHelper to be compatible with Rails 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed Nov 23, 2008
1 parent d2d8afc commit 1bca16c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Make ActionViewHelper compatible with changes to concat method in ActionPack [cody]
* Remove PayPal and Payflow Name-Value gateways. PayPal is no longer terminating the Payflow XML API. [cody]
* Don't directly use the inflector in the action view helper [cody]
* Work around Rails Inflector change [cody]
Expand Down
20 changes: 17 additions & 3 deletions lib/active_merchant/billing/integrations/action_view_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ module ActionViewHelper
# <% service.cancel_return_url 'http://mystore.com' %>
# <% end %>
#
def payment_service_for(order, account, options = {}, &proc)
def payment_service_for(order, account, options = {}, &proc)
raise ArgumentError, "Missing block" unless block_given?

integration_module = ActiveMerchant::Billing::Integrations.const_get(options.delete(:service).to_s.classify)

concat(form_tag(integration_module.service_url, options.delete(:html) || {}), proc.binding)
if ignore_binding?
concat(form_tag(integration_module.service_url, options.delete(:html) || {}))
else
concat(form_tag(integration_module.service_url, options.delete(:html) || {}), proc.binding)
end
result = "\n"

service_class = integration_module.const_get('Helper')
Expand All @@ -57,7 +61,17 @@ def payment_service_for(order, account, options = {}, &proc)

result << "\n"
result << '</form>'
concat(result, proc.binding)

if ignore_binding?
concat(result)
else
concat(result, proc.binding)
end
end

private
def ignore_binding?
ActionPack::VERSION::MAJOR >= 2 && ActionPack::VERSION::MINOR >= 2
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/unit/integrations/action_view_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ActionViewHelperTest < Test::Unit::TestCase
include ActionView::Helpers::TagHelper
include ActionView::Helpers::TextHelper

attr_accessor :output_buffer

def setup
@controller = Class.new do
attr_reader :url_for_options
Expand All @@ -16,6 +18,7 @@ def url_for(options, *parameters_for_method_reference)
end
end
@controller = @controller.new
@output_buffer = ''
end


Expand Down

0 comments on commit 1bca16c

Please sign in to comment.