diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-08-09 18:04:54 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-08-09 18:04:54 +0000 |
commit | cbfafcd5e2442ada23f655eba21cb600476228ac (patch) | |
tree | 3aa3b277debf4486a7201449fdbb789c77be31f4 /test/unit | |
parent | e06bf0c464184a457fa15efde1b7ddf8aede3f67 (diff) | |
download | redmine-cbfafcd5e2442ada23f655eba21cb600476228ac.tar.gz redmine-cbfafcd5e2442ada23f655eba21cb600476228ac.zip |
Use SSL for gravatars according to the protocol in settings (#9365).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10184 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/helpers/application_helper_test.rb | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/test/unit/helpers/application_helper_test.rb b/test/unit/helpers/application_helper_test.rb index b3757b092..edb01ea6d 100644 --- a/test/unit/helpers/application_helper_test.rb +++ b/test/unit/helpers/application_helper_test.rb @@ -970,25 +970,37 @@ RAW end end - def test_avatar - # turn on avatars - Setting.gravatar_enabled = '1' - assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) - assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) - # Default size is 50 - assert avatar('jsmith <jsmith@somenet.foo>').include?('size=50') - assert avatar('jsmith <jsmith@somenet.foo>', :size => 24).include?('size=24') - # Non-avatar options should be considered html options - assert avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith').include?('title="John Smith"') - # The default class of the img tag should be gravatar - assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"') - assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"') - assert_nil avatar('jsmith') - assert_nil avatar(nil) - - # turn off avatars - Setting.gravatar_enabled = '0' - assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) + def test_avatar_enabled + with_settings :gravatar_enabled => '1' do + assert avatar(User.find_by_mail('jsmith@somenet.foo')).include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) + assert avatar('jsmith <jsmith@somenet.foo>').include?(Digest::MD5.hexdigest('jsmith@somenet.foo')) + # Default size is 50 + assert avatar('jsmith <jsmith@somenet.foo>').include?('size=50') + assert avatar('jsmith <jsmith@somenet.foo>', :size => 24).include?('size=24') + # Non-avatar options should be considered html options + assert avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith').include?('title="John Smith"') + # The default class of the img tag should be gravatar + assert avatar('jsmith <jsmith@somenet.foo>').include?('class="gravatar"') + assert !avatar('jsmith <jsmith@somenet.foo>', :class => 'picture').include?('class="gravatar"') + assert_nil avatar('jsmith') + assert_nil avatar(nil) + end + end + + def test_avatar_should_use_ssl_if_protocol_is_https + with_settings :gravatar_enabled => '1', :protocol => 'https' do + assert_include 'https://', avatar(User.find_by_mail('jsmith@somenet.foo')) + end + + with_settings :gravatar_enabled => '1', :protocol => 'http' do + assert_include 'http://', avatar(User.find_by_mail('jsmith@somenet.foo')) + end + end + + def test_avatar_disabled + with_settings :gravatar_enabled => '0' do + assert_equal '', avatar(User.find_by_mail('jsmith@somenet.foo')) + end end def test_link_to_user |