Commit d3ade2770098e468309a816a17045627d56ec2fa

Authored by Antonio Terceiro
1 parent 536e6100

ChatController: fix assumption about default avatar

app/controllers/public/chat_controller.rb
@@ -19,9 +19,13 @@ class ChatController < PublicController @@ -19,9 +19,13 @@ class ChatController < PublicController
19 def avatar 19 def avatar
20 profile = environment.profiles.find_by_identifier(params[:id]) 20 profile = environment.profiles.find_by_identifier(params[:id])
21 filename, mimetype = profile_icon(profile, :minor, true) 21 filename, mimetype = profile_icon(profile, :minor, true)
22 - data = File.read(File.join(Rails.root, 'public', filename))  
23 - render :text => data, :layout => false, :content_type => mimetype  
24 - expires_in 24.hours 22 + if filename =~ /^https?:/
  23 + redirect_to filename
  24 + else
  25 + data = File.read(File.join(Rails.root, 'public', filename))
  26 + render :text => data, :layout => false, :content_type => mimetype
  27 + expires_in 24.hours
  28 + end
25 end 29 end
26 30
27 def index 31 def index
test/functional/chat_controller_test.rb
@@ -26,8 +26,7 @@ class ChatControllerTest < ActionController::TestCase @@ -26,8 +26,7 @@ class ChatControllerTest < ActionController::TestCase
26 26
27 get :avatar, :id => 'testuser' 27 get :avatar, :id => 'testuser'
28 28
29 - assert_equal 'image/png', @response.content_type  
30 - assert @response.body.index('PNG') 29 + assert_response :redirect
31 end 30 end
32 31
33 should 'get avatar from community' do 32 should 'get avatar from community' do