Patch by Takenori TAKAKI. git-svn-id: http://svn.redmine.org/redmine/trunk@19626 e93f8b46-1217-0410-a6f0-8f06a7374b81tags/4.2.0
@@ -579,7 +579,10 @@ module ApplicationHelper | |||
def principals_check_box_tags(name, principals) | |||
s = +'' | |||
principals.each do |principal| | |||
s << "<label>#{ check_box_tag name, principal.id, false, :id => nil } <span class='name icon icon-#{principal.class.name.downcase}'></span>#{h principal}</label>\n" | |||
s << content_tag('label', | |||
check_box_tag(name, principal.id, false, :id => nil) + | |||
(avatar(principal, :size => 16).presence || content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}")) + | |||
principal) | |||
end | |||
s.html_safe | |||
end |
@@ -415,6 +415,7 @@ td.center {text-align:center;} | |||
#watchers select {width: 95%; display: block;} | |||
#watchers img.gravatar {margin: 0 4px 2px 0;} | |||
#users_for_watcher img.gravatar {padding-bottom: 2px; margin-right: 4px;} | |||
span#watchers_inputs {overflow:auto; display:block;} | |||
span.search_for_watchers {display:block;} |
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__) | |||
class ApplicationHelperTest < Redmine::HelperTest | |||
include ERB::Util | |||
include Rails.application.routes.url_helpers | |||
include AvatarsHelper | |||
fixtures :projects, :enabled_modules, | |||
:users, :email_addresses, | |||
@@ -1704,6 +1705,31 @@ class ApplicationHelperTest < Redmine::HelperTest | |||
end | |||
end | |||
def test_principals_check_box_tag_with_avatar | |||
principals = [User.find(1), Group.find(10)] | |||
with_settings :gravatar_enabled => '1' do | |||
tags = principals_check_box_tags("watcher[user_ids][]", principals) | |||
principals.each do |principal| | |||
assert_include avatar(principal, :size => 16), tags | |||
assert_not_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags | |||
end | |||
end | |||
end | |||
def test_principals_check_box_tag_without_avatar | |||
principals = [User.find(1), Group.find(10)] | |||
Setting.gravatar_enabled = '1' | |||
avatar_tags = principals.collect{|p| avatar(p, :size => 16) } | |||
with_settings :gravatar_enabled => '0' do | |||
tags = principals_check_box_tags(name, principals) | |||
principals.each_with_index do |principal, i| | |||
assert_not_include avatar_tags[i], tags | |||
assert_include content_tag('span', nil, :class => "name icon icon-#{principal.class.name.downcase}"), tags | |||
end | |||
end | |||
end | |||
def test_principals_options_for_select_with_users | |||
User.current = nil | |||
users = [User.find(2), User.find(4)] |
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__) | |||
class GroupsHelperTest < Redmine::HelperTest | |||
include ERB::Util | |||
include GroupsHelper | |||
include AvatarsHelper | |||
include Rails.application.routes.url_helpers | |||
fixtures :users |
@@ -22,6 +22,7 @@ require File.expand_path('../../test_helper', __FILE__) | |||
class MembersHelperTest < Redmine::HelperTest | |||
include ERB::Util | |||
include MembersHelper | |||
include AvatarsHelper | |||
include Rails.application.routes.url_helpers | |||
fixtures :projects, :users, :members, :member_roles, |