Commit b67c05a56c1905dd3350fabddaac1f014e2b7e6f

Authored by AntonioTerceiro
1 parent a61b1b26

ActionItem250: fixing button helper method: don't throw away upstream

class


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1589 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/application_helper.rb
@@ -248,7 +248,11 @@ module ApplicationHelper @@ -248,7 +248,11 @@ module ApplicationHelper
248 end 248 end
249 249
250 def button(type, label, url, html_options = {}) 250 def button(type, label, url, html_options = {})
251 - button_without_text type, label, url, html_options.merge(:class=>'with-text') 251 + the_class = 'with-text'
  252 + if html_options.has_key?(:class)
  253 + the_class << ' ' << html_options[:class]
  254 + end
  255 + button_without_text type, label, url, html_options.merge(:class => the_class)
252 end 256 end
253 257
254 def button_without_text(type, label, url, html_options = {}) 258 def button_without_text(type, label, url, html_options = {})
test/unit/application_helper_test.rb
@@ -50,6 +50,11 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase @@ -50,6 +50,11 @@ class ApplicationHelperTest &lt; Test::Unit::TestCase
50 assert_equal '', show_time(nil) 50 assert_equal '', show_time(nil)
51 end 51 end
52 52
  53 + should 'append with-text class and keep existing classes' do
  54 + expects(:button_without_text).with('type', 'label', 'url', { :class => 'with-text class1'})
  55 + button('type', 'label', 'url', { :class => 'class1' })
  56 + end
  57 +
53 protected 58 protected
54 59
55 def content_tag(tag, content, options) 60 def content_tag(tag, content, options)