From b67c05a56c1905dd3350fabddaac1f014e2b7e6f Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 19 Mar 2008 13:20:54 +0000 Subject: [PATCH] ActionItem250: fixing button helper method: don't throw away upstream class --- app/helpers/application_helper.rb | 6 +++++- test/unit/application_helper_test.rb | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6d04dcc..412c1dd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -248,7 +248,11 @@ module ApplicationHelper end def button(type, label, url, html_options = {}) - button_without_text type, label, url, html_options.merge(:class=>'with-text') + the_class = 'with-text' + if html_options.has_key?(:class) + the_class << ' ' << html_options[:class] + end + button_without_text type, label, url, html_options.merge(:class => the_class) end def button_without_text(type, label, url, html_options = {}) diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 11f12bd..8dd0345 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -50,6 +50,11 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_equal '', show_time(nil) end + should 'append with-text class and keep existing classes' do + expects(:button_without_text).with('type', 'label', 'url', { :class => 'with-text class1'}) + button('type', 'label', 'url', { :class => 'class1' }) + end + protected def content_tag(tag, content, options) -- libgit2 0.21.2