]> source.dussan.org Git - redmine.git/commitdiff
Adds 'assigned-to-my-group' css class to issues that are assigned to a user's group...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 11 Jul 2013 19:35:40 +0000 (19:35 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 11 Jul 2013 19:35:40 +0000 (19:35 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12006 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/issue.rb
test/unit/issue_test.rb

index e68dc02f7baea1819ba11b8850b1f0ada257bc7f..ccedcfd4c5b77a2325e858bbfaf4d8c9a9349eda 100644 (file)
@@ -1041,15 +1041,18 @@ class Issue < ActiveRecord::Base
   end
 
   # Returns a string of css classes that apply to the issue
-  def css_classes
+  def css_classes(user=User.current)
     s = "issue tracker-#{tracker_id} status-#{status_id} #{priority.try(:css_classes)}"
     s << ' closed' if closed?
     s << ' overdue' if overdue?
     s << ' child' if child?
     s << ' parent' unless leaf?
     s << ' private' if is_private?
-    s << ' created-by-me' if User.current.logged? && author_id == User.current.id
-    s << ' assigned-to-me' if User.current.logged? && assigned_to_id == User.current.id
+    if user.logged?
+      s << ' created-by-me' if author_id == user.id
+      s << ' assigned-to-me' if assigned_to_id == user.id
+      s << ' assigned-to-my-group' if user.groups.any? {|g| g.id = assigned_to_id}
+    end
     s
   end
 
index ecebb262ee0445a86a9c437b42bd6f0e5b6de771..ce5c50ac77e15409ca465ab1d6fd0a5742906e37 100644 (file)
@@ -2169,6 +2169,18 @@ class IssueTest < ActiveSupport::TestCase
     assert_include 'priority-highest', classes
   end
 
+  def test_css_classes_should_include_user_assignment
+    issue = Issue.generate(:assigned_to_id => 2)
+    assert_include 'assigned-to-me', issue.css_classes(User.find(2))
+    assert_not_include 'assigned-to-me', issue.css_classes(User.find(3))
+  end
+
+  def test_css_classes_should_include_user_group_assignment
+    issue = Issue.generate(:assigned_to_id => 10)
+    assert_include 'assigned-to-my-group', issue.css_classes(Group.find(10).users.first)
+    assert_not_include 'assigned-to-my-group', issue.css_classes(User.find(3))
+  end
+
   def test_save_attachments_with_hash_should_save_attachments_in_keys_order
     set_tmp_attachments_directory
     issue = Issue.generate!