@@ -1134,7 +1134,7 module ApplicationHelper | |||||
1134 | # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>') |
|
1134 | # +user+ can be a User or a string that will be scanned for an email address (eg. 'joe <joe@foo.bar>') | |
1135 | def avatar(user, options = { }) |
|
1135 | def avatar(user, options = { }) | |
1136 | if Setting.gravatar_enabled? |
|
1136 | if Setting.gravatar_enabled? | |
1137 |
options.merge!({:ssl => ( |
|
1137 | options.merge!({:ssl => (request && request.ssl?), :default => Setting.gravatar_default}) | |
1138 | email = nil |
|
1138 | email = nil | |
1139 | if user.respond_to?(:mail) |
|
1139 | if user.respond_to?(:mail) | |
1140 | email = user.mail |
|
1140 | email = user.mail |
@@ -970,37 +970,25 RAW | |||||
970 | end |
|
970 | end | |
971 | end |
|
971 | end | |
972 |
|
972 | |||
973 |
def test_avatar |
|
973 | def test_avatar | |
974 | with_settings :gravatar_enabled => '1' do |
|
974 | # turn on avatars | |
975 | assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) |
|
975 | Setting.gravatar_enabled = '1' | |
976 |
|
|
976 | assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) | |
977 | # Default size is 50 |
|
977 | assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) | |
978 | assert avatar('jsmith <jsmith@somenet.foo>').include?('size=50') |
|
978 | # Default size is 50 | |
979 |
|
|
979 | assert avatar('jsmith <jsmith@somenet.foo>').include?('size=50') | |
980 | # Non-avatar options should be considered html options |
|
980 | assert avatar('jsmith <jsmith@somenet.foo>', :size => 24).include?('size=24') | |
981 | assert avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith').include?('title="John Smith"') |
|
981 | # Non-avatar options should be considered html options | |
982 | # The default class of the img tag should be gravatar |
|
982 | assert avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith').include?('title="John Smith"') | |
983 | assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"') |
|
983 | # The default class of the img tag should be gravatar | |
984 |
|
|
984 | assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"') | |
985 | assert_nil avatar('jsmith') |
|
985 | assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"') | |
986 |
|
|
986 | assert_nil avatar('jsmith') | |
987 | end |
|
987 | assert_nil avatar(nil) | |
988 | end |
|
988 | ||
989 |
|
989 | # turn off avatars | ||
990 | def test_avatar_should_use_ssl_if_protocol_is_https |
|
990 | Setting.gravatar_enabled = '0' | |
991 | with_settings :gravatar_enabled => '1', :protocol => 'https' do |
|
991 | assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) | |
992 | assert_include 'https://', avatar(User.find_by_mail('jsmith@somenet.foo')) |
|
|||
993 | end |
|
|||
994 |
|
||||
995 | with_settings :gravatar_enabled => '1', :protocol => 'http' do |
|
|||
996 | assert_include 'http://', avatar(User.find_by_mail('jsmith@somenet.foo')) |
|
|||
997 | end |
|
|||
998 | end |
|
|||
999 |
|
||||
1000 | def test_avatar_disabled |
|
|||
1001 | with_settings :gravatar_enabled => '0' do |
|
|||
1002 | assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) |
|
|||
1003 | end |
|
|||
1004 | end |
|
992 | end | |
1005 |
|
993 | |||
1006 | def test_link_to_user |
|
994 | def test_link_to_user |
General Comments 0
You need to be logged in to leave comments.
Login now