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="/images/avatar_large.png" />$}, image
13 image = user_image(user, :class => "foo")
14 assert_match %r{^<img class="foo" .* src="/images/avatar_large.png" />$}, 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="/images/avatar_small.png" />$}, image
30 image = user_thumbnail(user, :class => "foo")
31 assert_match %r{^<img class="foo" .* src="/images/avatar_small.png" />$}, 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="/images/avatar_small.png" />$}, image
47 image = user_thumbnail_tiny(user, :class => "foo")
48 assert_match %r{^<img class="foo" .* src="/images/avatar_small.png" />$}, 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
59 user.avatar.attach(:io => File.open("test/gpx/fixtures/a.gif"), :filename => "a.gif")
60 gravatar_user = create(:user, :image_use_gravatar => true)
62 url = user_image_url(user)
63 assert_match %r{^http://test.host/rails/active_storage/representations/[^/]+/[^/]+/a.gif$}, url
65 url = user_image_url(gravatar_user)
66 assert_match %r{^http://www.gravatar.com/avatar/}, url
71 assert_match %r{^<img .* class="openid_logo" src="/images/openid_small.png" />$}, logo
75 button = auth_button("google", "google")
76 assert_equal("<a class=\"auth_button\" title=\"Login with Google\" rel=\"nofollow\" data-method=\"post\" href=\"/auth/google\"><img alt=\"Login with a Google OpenID\" class=\"rounded-lg\" src=\"/images/google.svg\" /></a>", button)
78 button = auth_button("yahoo", "openid", :openid_url => "yahoo.com")
79 assert_equal("<a class=\"auth_button\" title=\"Login with Yahoo\" rel=\"nofollow\" data-method=\"post\" href=\"/auth/openid?openid_url=yahoo\.com\"><img alt=\"Login with a Yahoo OpenID\" class=\"rounded-lg\" src=\"/images/yahoo.svg\" /></a>", button)