Permalink
Browse files

Moving the DEFAULT_AVATAR constant to application.rb rather than auth…

…or.rb
  • Loading branch information...
1 parent 43d482b commit bb40ea518c8f6b86a50f9921f893bfb34d91fdf2 @carols10cents carols10cents committed Jul 23, 2012
@@ -11,7 +11,7 @@ jQuery $ ->
# Replace images that 404 with the default avatar
replaceBrokenImages = ->
$("img").error ->
- $(this).attr("src", "<%= asset_path Author::DEFAULT_AVATAR %>")
+ $(this).attr("src", "<%= asset_path RstatUs::DEFAULT_AVATAR %>")
replaceBrokenImages()
@@ -19,7 +19,7 @@ def avatar
# Make sure we're using the asset path if the user's avatar is the default
# (local) avatar
def absolute_avatar_url
- if author.avatar_url.eql? Author::DEFAULT_AVATAR
+ if author.avatar_url.eql? RstatUs::DEFAULT_AVATAR
h.asset_path(author.avatar_url)
else
author.avatar_url
View
@@ -8,8 +8,9 @@ class Author
# Constants that are useful for avatars using gravatar
GRAVATAR = "gravatar.com"
GRAVATAR_SIGNUP = "http://gravatar.com/site/signup"
- DEFAULT_AVATAR = "avatar.png"
- ENCODED_DEFAULT_AVATAR = URI.encode_www_form_component(DEFAULT_AVATAR)
+ ENCODED_DEFAULT_AVATAR = URI.encode_www_form_component(
+ RstatUs::DEFAULT_AVATAR
+ )
# public keys are good for 4 weeks
PUBLIC_KEY_LEASE_DAYS = 28
@@ -152,7 +153,7 @@ def url
# We've got a couple of options here. If they have some sort of image from
# Twitter, we use that, and if they don't, we go with Gravatar.
- # If none of that is around, then we show the DEFAULT_AVATAR
+ # If none of that is around, then we show the RstatUs::DEFAULT_AVATAR
def avatar_url
# If the user has a twitter image, return it
@@ -165,7 +166,7 @@ def avatar_url
# Otherwise return the default avatar
else
- DEFAULT_AVATAR
+ RstatUs::DEFAULT_AVATAR
end
end
View
@@ -69,6 +69,8 @@ class Application < Rails::Application
end
+ DEFAULT_AVATAR = "avatar.png"
+
# Custom RstatUs exceptions
class InvalidSubscribeTo < StandardError; end
class InvalidSalmonMessage < StandardError; end
@@ -31,7 +31,7 @@
it "uses the default avatar if neither image_url nor email is set" do
@author.email = nil
- assert_equal Author::DEFAULT_AVATAR, @author.avatar_url
+ assert_equal RstatUs::DEFAULT_AVATAR, @author.avatar_url
end
end

0 comments on commit bb40ea5

Please sign in to comment.