diff options
-rw-r--r-- | app/helpers/application_helper.rb | 5 | ||||
-rw-r--r-- | public/stylesheets/application.css | 1 | ||||
-rw-r--r-- | test/helpers/application_helper_test.rb | 26 | ||||
-rw-r--r-- | test/helpers/groups_helper_test.rb | 1 | ||||
-rw-r--r-- | test/helpers/members_helper_test.rb | 1 |
5 files changed, 33 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2fed8ee91..f94732fc6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 8f92c8e98..73e8b3484 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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;} diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 81e20c1b6..d076aba86 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -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)] diff --git a/test/helpers/groups_helper_test.rb b/test/helpers/groups_helper_test.rb index 0865daa56..8424cc450 100644 --- a/test/helpers/groups_helper_test.rb +++ b/test/helpers/groups_helper_test.rb @@ -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 diff --git a/test/helpers/members_helper_test.rb b/test/helpers/members_helper_test.rb index e4f2e1541..8858ab57d 100644 --- a/test/helpers/members_helper_test.rb +++ b/test/helpers/members_helper_test.rb @@ -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, |