@@ -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,8 +970,9 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 | Setting.gravatar_enabled = '1' | |||
975 |
|
|
976 | assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) | |
976 |
|
|
977 | assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) | |
977 |
|
|
978 | # Default size is 50 | |
@@ -984,24 +985,11 RAW | |||||
984 |
|
|
985 | assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"') | |
985 |
|
|
986 | assert_nil avatar('jsmith') | |
986 |
|
|
987 | assert_nil avatar(nil) | |
987 | end |
|
|||
988 | end |
|
|||
989 |
|
||||
990 | def test_avatar_should_use_ssl_if_protocol_is_https |
|
|||
991 | with_settings :gravatar_enabled => '1', :protocol => 'https' do |
|
|||
992 | assert_include 'https://', avatar(User.find_by_mail('jsmith@somenet.foo')) |
|
|||
993 | end |
|
|||
994 |
|
988 | |||
995 | with_settings :gravatar_enabled => '1', :protocol => 'http' do |
|
989 | # turn off avatars | |
996 | assert_include 'http://', avatar(User.find_by_mail('jsmith@somenet.foo')) |
|
990 | Setting.gravatar_enabled = '0' | |
997 | end |
|
|||
998 | end |
|
|||
999 |
|
||||
1000 | def test_avatar_disabled |
|
|||
1001 | with_settings :gravatar_enabled => '0' do |
|
|||
1002 |
|
|
991 | assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) | |
1003 |
|
|
992 | end | |
1004 | end |
|
|||
1005 |
|
993 | |||
1006 | def test_link_to_user |
|
994 | def test_link_to_user | |
1007 | user = User.find(2) |
|
995 | user = User.find(2) |
General Comments 0
You need to be logged in to leave comments.
Login now