summaryrefslogtreecommitdiffstats
path: root/test/helpers/application_helper_test.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2018-04-07 09:56:35 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2018-04-07 09:56:35 +0000
commit82c65a5a98250d7bc7df6252a9b9ffea07fa5a58 (patch)
treecdaec8dcde8805e3d6e60eb0947ed91bbf874a47 /test/helpers/application_helper_test.rb
parent5fefb1445b8780d001d16a97a007a046e5d13002 (diff)
downloadredmine-82c65a5a98250d7bc7df6252a9b9ffea07fa5a58.tar.gz
redmine-82c65a5a98250d7bc7df6252a9b9ffea07fa5a58.zip
Avatar tests cleanup.
git-svn-id: http://svn.redmine.org/redmine/trunk@17283 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/helpers/application_helper_test.rb')
-rw-r--r--test/helpers/application_helper_test.rb70
1 files changed, 54 insertions, 16 deletions
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index d8e468741..78a4822f1 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1286,25 +1286,63 @@ RAW
end
end
- def test_avatar_enabled
+ def test_avatar_with_user
+ with_settings :gravatar_enabled => '1' do
+ assert_include Digest::MD5.hexdigest('jsmith@somenet.foo'), avatar(User.find_by_mail('jsmith@somenet.foo'))
+ end
+ end
+
+ def test_avatar_with_email_string
+ with_settings :gravatar_enabled => '1' do
+ assert_include Digest::MD5.hexdigest('jsmith@somenet.foo'), avatar('jsmith <jsmith@somenet.foo>')
+ end
+ end
+
+ def test_avatar_with_anonymous_user
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)
- # Avatar for anonymous user
assert_match %r{src="/images/anonymous.png(\?\d+)?"}, avatar(User.anonymous)
- # No avatar for groups
+ end
+ end
+
+ def test_avatar_with_group
+ with_settings :gravatar_enabled => '1' do
assert_nil avatar(Group.first)
- assert avatar(User.anonymous, :size => 24).include?('width="24" height="24"')
+ end
+ end
+
+ def test_avatar_with_invalid_arg_should_return_nil
+ with_settings :gravatar_enabled => '1' do
+ assert_nil avatar('jsmith')
+ assert_nil avatar(nil)
+ end
+ end
+
+ def test_avatar_default_size_should_be_50
+ with_settings :gravatar_enabled => '1' do
+ assert_include 'size=50', avatar('jsmith <jsmith@somenet.foo>')
+ end
+ end
+
+ def test_avatar_with_size_option
+ with_settings :gravatar_enabled => '1' do
+ assert_include 'size=24', avatar('jsmith <jsmith@somenet.foo>', :size => 24)
+ assert_include 'width="24" height="24"', avatar(User.anonymous, :size => 24)
+ end
+ end
+
+ def test_avatar_with_html_option
+ with_settings :gravatar_enabled => '1' do
+ # Non-avatar options should be considered html options
+ assert_include 'title="John Smith"', avatar('jsmith <jsmith@somenet.foo>', :title => 'John Smith')
+ end
+ end
+
+ def test_avatar_css_class
+ with_settings :gravatar_enabled => '1' do
+ # The default class of the img tag should be gravatar
+ assert_include 'class="gravatar"', avatar('jsmith <jsmith@somenet.foo>')
+ assert_not_include 'class="gravatar"', avatar('jsmith <jsmith@somenet.foo>', :class => 'picture')
+ assert_include 'class="picture"', avatar('jsmith <jsmith@somenet.foo>', :class => 'picture')
end
end