Commit 06ff6031fd114d89cd62c0e841591a2381526fb4

Authored by JoenioCosta
1 parent e66e02bf

ActionItem359: ouch! was missing the tests

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1766 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/helpers/application_helper.rb
@@ -493,7 +493,7 @@ module ApplicationHelper @@ -493,7 +493,7 @@ module ApplicationHelper
493 content_tag('div', result) 493 content_tag('div', result)
494 end 494 end
495 495
496 - def theme_option( opt=nil ) 496 + def theme_option(opt = nil)
497 conf = RAILS_ROOT.to_s() + 497 conf = RAILS_ROOT.to_s() +
498 '/public/designs/themes/' + 498 '/public/designs/themes/' +
499 current_theme.to_s() + 499 current_theme.to_s() +
@@ -528,8 +528,10 @@ module ApplicationHelper @@ -528,8 +528,10 @@ module ApplicationHelper
528 end 528 end
529 529
530 def theme_javascript 530 def theme_javascript
  531 + option = theme_option(:js)
  532 + return if option.nil?
531 html = [] 533 html = []
532 - theme_option(:js).each do |file| 534 + option.each do |file|
533 file = '/designs/themes/'+ current_theme.to_s() + 535 file = '/designs/themes/'+ current_theme.to_s() +
534 '/javascript/'+ file +'.js' 536 '/javascript/'+ file +'.js'
535 if File.exists? RAILS_ROOT.to_s() +'/public'+ file 537 if File.exists? RAILS_ROOT.to_s() +'/public'+ file
test/unit/application_helper_test.rb
@@ -71,6 +71,35 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -71,6 +71,35 @@ class ApplicationHelperTest < Test::Unit::TestCase
71 assert_same result, link_to_category(cat) 71 assert_same result, link_to_category(cat)
72 end 72 end
73 73
  74 + should 'get current theme' do
  75 + assert_equal 'default', current_theme()
  76 + end
  77 +
  78 + should 'nil theme option when no exists theme' do
  79 + File.expects(:exists?).returns(false)
  80 + assert_nil theme_option()
  81 + end
  82 +
  83 + should 'not nil to ecosol theme option' do
  84 + expects(:current_theme).returns('ecosol')
  85 + assert_not_nil theme_option()
  86 + end
  87 +
  88 + should 'not nil to zen3 theme option' do
  89 + expects(:current_theme).returns('zen3')
  90 + assert_not_nil theme_option()
  91 + end
  92 +
  93 + should 'nil javascript theme when no exists theme' do
  94 + File.expects(:exists?).returns(false)
  95 + assert_nil theme_javascript
  96 + end
  97 +
  98 + should 'not nil javascript theme to ecosol theme' do
  99 + expects(:current_theme).returns('ecosol')
  100 + assert_not_nil theme_javascript
  101 + end
  102 +
74 protected 103 protected
75 104
76 def content_tag(tag, content, options) 105 def content_tag(tag, content, options)