]> source.dussan.org Git - redmine.git/commitdiff
Make use of #watched_by? in issue form.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 2 Dec 2009 19:17:42 +0000 (19:17 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 2 Dec 2009 19:17:42 +0000 (19:17 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3114 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/issues/_form.rhtml
vendor/plugins/acts_as_watchable/lib/acts_as_watchable.rb

index 5337b51be38e314c97d9dc17a35599fcf988452c..032d0820507d5ddadaed17f39925be87d8de4047 100644 (file)
@@ -23,7 +23,7 @@
 <% if @issue.new_record? && User.current.allowed_to?(:add_issue_watchers, @project) -%>
 <p><label><%= l(:label_issue_watchers) %></label>
 <% @issue.project.users.sort.each do |user| -%>
-<label class="floating"><%= check_box_tag 'issue[watcher_user_ids][]', user.id, @issue.watcher_user_ids.include?(user.id) %> <%=h user %></label>
+<label class="floating"><%= check_box_tag 'issue[watcher_user_ids][]', user.id, @issue.watched_by?(user) %> <%=h user %></label>
 <% end -%>
 </p>
 <% end %>
index 3d0de0dca3789900580aaaed715136129bdd1698..977ab4fc7dcf17d641ffe87f50a6db1a7b525e0d 100644 (file)
@@ -46,10 +46,9 @@ module Redmine
           watching ? add_watcher(user) : remove_watcher(user)
         end
         
-        # Returns if object is watched by user
+        # Returns true if object is watched by user
         def watched_by?(user)
-          !self.watchers.find(:first,
-                              :conditions => ["#{Watcher.table_name}.user_id = ?", user.id]).nil?
+          !!(user && self.watchers.detect {|w| w.user_id == user.id })
         end
         
         # Returns an array of watchers' email addresses