use absolute url for avatar in notifications

fixes CNVS-14251

test plan
- cause a notification with an avatar to be sent (discussion,
 conversation, or submission comment)
- ensure that the avatar image src attribute is an absolute url

Change-Id: I6992de1f4b83ecfdf838725a42e09feb1ca5e1c9
Reviewed-on: https://gerrit.instructure.com/37729
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Matthew Wheeler <mwheeler@instructure.com>
Product-Review: Matthew Wheeler <mwheeler@instructure.com>
Tested-by: Matthew Wheeler <mwheeler@instructure.com>
QA-Review: Steven Shepherd <sshepherd@instructure.com>
This commit is contained in:
Joel Hough 2014-07-15 16:37:20 -06:00 committed by Matthew Wheeler
parent 35bc72f55f
commit 0c80487238
2 changed files with 11 additions and 1 deletions

View File

@ -195,7 +195,8 @@ class Message < ActiveRecord::Base
end
def author_avatar_url
author.try(:avatar_url)
url = author.try(:avatar_url)
URI.join("#{HostUrl.protocol}://#{HostUrl.context_host(author_account)}", url).to_s if url
end
def author_short_name

View File

@ -362,6 +362,15 @@ describe Message do
authorless_message.author_avatar_url.should be_nil
end
it "uses an absolute url for avatar src" do
user.avatar_image_url = user.avatar_path
user.save!
message = Message.new(context: convo_message)
message.author_short_name.should == user.short_name
message.author_email_address.should == user.email
message.author_avatar_url.should == "#{HostUrl.protocol}://#{HostUrl.context_host(user.account)}#{user.avatar_path}"
end
describe 'author_account' do
it 'is nil if there is no author' do
authorless_message.author_account.should be_nil