Browse Source

Makes #watcher_link return an empty string when given nil.

git-svn-id: http://svn.redmine.org/redmine/trunk@12869 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/2.5.0
Jean-Philippe Lang 10 years ago
parent
commit
ff46e9d0a4
2 changed files with 5 additions and 0 deletions
  1. 1
    0
      app/helpers/watchers_helper.rb
  2. 4
    0
      test/unit/helpers/watchers_helper_test.rb

+ 1
- 0
app/helpers/watchers_helper.rb View 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(' ')

+ 4
- 0
test/unit/helpers/watchers_helper_test.rb View 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))


Loading…
Cancel
Save