Commit 5ef63ec4 authored by Felix Schäfer's avatar Felix Schäfer

Fix option parsing for gravatars #1034

In addition to that:
* the default size was 50px in the old lib, this has been restored
* some tests to test the default and option parsing
parent f8ec89b9
......@@ -959,7 +959,9 @@ module ApplicationHelper
def gravatar(email, options={})
gravatarify_options = {}
gravatarify_options[:secure] = options.delete :ssl
[:default, :size, :rating, :filetype].each {|key| gravatarify_options[:key] = options.delete :key}
[:default, :size, :rating, :filetype].each {|key| gravatarify_options[key] = options.delete key}
# Default size is 50x50 px
gravatarify_options[:size] ||= 50
gravatarify_options[:html] = options
gravatar_tag email, gravatarify_options
end
......
......@@ -664,6 +664,11 @@ RAW
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?('s=50')
assert avatar('jsmith <jsmith@somenet.foo>', :size => 24).include?('s=24')
# Non-avatar options should be considered html options
assert avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith').include?('title="John Smith"')
assert_nil avatar('jsmith')
assert_nil avatar(nil)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment