3 class UserHelperTest < ActionView::TestCase
8 gravatar_user = create(:user, :image_use_gravatar => true)
10 image = user_image(user)
11 assert_match %r{^<img class="user_image" .* src="/assets/users/images/large-.*" />$}, image
13 image = user_image(user, :class => "foo")
14 assert_match %r{^<img class="foo" .* src="/assets/users/images/large-.*" />$}, image
16 image = user_image(gravatar_user)
17 assert_match %r{^<img class="user_image" .* src="http://www.gravatar.com/avatar/.*" />$}, image
19 image = user_image(gravatar_user, :class => "foo")
20 assert_match %r{^<img class="foo" .* src="http://www.gravatar.com/avatar/.*" />$}, image
23 def test_user_thumbnail
25 gravatar_user = create(:user, :image_use_gravatar => true)
27 image = user_thumbnail(user)
28 assert_match %r{^<img class="user_thumbnail" .* src="/assets/users/images/small-.*" />$}, image
30 image = user_thumbnail(user, :class => "foo")
31 assert_match %r{^<img class="foo" .* src="/assets/users/images/small-.*" />$}, image
33 image = user_thumbnail(gravatar_user)
34 assert_match %r{^<img class="user_thumbnail" .* src="http://www.gravatar.com/avatar/.*" />$}, image
36 image = user_thumbnail(gravatar_user, :class => "foo")
37 assert_match %r{^<img class="foo" .* src="http://www.gravatar.com/avatar/.*" />$}, image
40 def test_user_thumbnail_tiny
42 gravatar_user = create(:user, :image_use_gravatar => true)
44 image = user_thumbnail_tiny(user)
45 assert_match %r{^<img class="user_thumbnail_tiny" .* src="/assets/users/images/small-.*" />$}, image
47 image = user_thumbnail_tiny(user, :class => "foo")
48 assert_match %r{^<img class="foo" .* src="/assets/users/images/small-.*" />$}, image
50 image = user_thumbnail_tiny(gravatar_user)
51 assert_match %r{^<img class="user_thumbnail_tiny" .* src="http://www.gravatar.com/avatar/.*" />$}, image
53 image = user_thumbnail_tiny(gravatar_user, :class => "foo")
54 assert_match %r{^<img class="foo" .* src="http://www.gravatar.com/avatar/.*" />$}, image
57 def test_user_image_url
58 user = create(:user, :image_file_name => "test.jpg", :image_fingerprint => "d41d8cd98f00b204e9800998ecf8427e")
59 gravatar_user = create(:user, :image_use_gravatar => true)
61 url = user_image_url(user)
62 assert_match %r{^/attachments/users/images/\d{3}/\d{3}/\d{3}/large/d41d8cd98f00b204e9800998ecf8427e.jpg$}, url
64 url = user_image_url(gravatar_user)
65 assert_match %r{^http://www.gravatar.com/avatar/}, url
70 assert_match %r{^<img .* class="openid_logo" src="/images/openid_small.png" />$}, logo
74 button = auth_button("google", "google")
75 assert_equal button, "<a class=\"auth_button\" title=\"Login with Google\" href=\"/auth/google\"><img alt=\"Login with a Google OpenID\" src=\"/images/google.png\" /></a>"
77 button = auth_button("yahoo", "openid", :openid_url => "yahoo.com")
78 assert_equal button, "<a class=\"auth_button\" title=\"Login with Yahoo\" href=\"/auth/openid?openid_url=yahoo\.com\"><img alt=\"Login with a Yahoo OpenID\" src=\"/images/yahoo.png\" /></a>"