]> source.dussan.org Git - redmine.git/commitdiff
Makes #watcher_link return an empty string when given nil.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Feb 2014 12:04:44 +0000 (12:04 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 9 Feb 2014 12:04:44 +0000 (12:04 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@12869 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/watchers_helper.rb
test/unit/helpers/watchers_helper_test.rb

index f1cc0702d5502e673294387d5243a496e69cf006..28f912bbcd0b90c9ba121e42d448c8184c0d4f54 100644 (file)
@@ -27,6 +27,7 @@ module WatchersHelper
   def watcher_link(objects, user)
     return '' unless user && user.logged?
     objects = Array.wrap(objects)
+    return '' unless objects.any?
 
     watched = Watcher.any_watched?(objects, user)
     css = [watcher_css(objects), watched ? 'icon icon-fav' : 'icon icon-fav-off'].join(' ')
index def4ffad81ae99f515955a416b20a69b15220361..bf8740cd8dc621cce66f44e3dfe4c9422b4b95eb 100644 (file)
@@ -57,6 +57,10 @@ class WatchersHelperTest < ActionView::TestCase
     assert_equal expected, watcher_link([Issue.find(1), Issue.find(3)], User.find(1))
   end
 
+  def test_watcher_link_with_nil_should_return_empty_string
+    assert_equal '', watcher_link(nil, User.find(1))
+  end
+
   test '#watcher_link with a watched object' do
     Watcher.create!(:watchable => Issue.find(1), :user => User.find(1))