added route to grab users profile picture if you know their username
This commit is contained in:
parent
be00536810
commit
049eb74ab2
3 changed files with 25 additions and 1 deletions
|
|
@ -7,7 +7,7 @@ class UsersController < ApplicationController
|
|||
require File.join(Rails.root, 'lib/diaspora/exporter')
|
||||
require File.join(Rails.root, 'lib/collect_user_photos')
|
||||
|
||||
before_filter :authenticate_user!, :except => [:new, :create, :public]
|
||||
before_filter :authenticate_user!, :except => [:new, :create, :public, :user_photo]
|
||||
|
||||
respond_to :html
|
||||
|
||||
|
|
@ -119,6 +119,16 @@ class UsersController < ApplicationController
|
|||
send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" )
|
||||
end
|
||||
|
||||
def user_photo
|
||||
username = params[:username].split('@')[0]
|
||||
user = User.find_by_username(username)
|
||||
if user.present?
|
||||
redirect_to user.profile.image_url
|
||||
else
|
||||
render :nothing => true, :status => 404
|
||||
end
|
||||
end
|
||||
|
||||
def confirm_email
|
||||
if current_user.confirm_email(params[:token])
|
||||
flash[:notice] = I18n.t('users.confirm_email.email_confirmed', :email => current_user.email)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ Diaspora::Application.routes.draw do
|
|||
delete "tag_followings" => "tag_followings#destroy"
|
||||
end
|
||||
|
||||
get '/user_photo/:username' => 'users#user_photo'
|
||||
|
||||
# get "tag_followings" => "tag_followings#index", :as => 'tag_followings'
|
||||
|
||||
get 'tags/:name' => 'tags#show', :as => 'tag'
|
||||
|
|
|
|||
|
|
@ -26,6 +26,18 @@ describe UsersController do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'user_photo' do
|
||||
it 'should return the url of the users profile photo' do
|
||||
get :user_photo, :username => @user.username
|
||||
response.should redirect_to(@user.profile.image_url)
|
||||
end
|
||||
|
||||
it 'should 404 if no user is found' do
|
||||
get :user_photo, :username => 'none'
|
||||
response.should_not be_success
|
||||
end
|
||||
end
|
||||
|
||||
describe '#public' do
|
||||
it 'renders xml if atom is requested' do
|
||||
sm = Factory(:status_message, :public => true, :author => @user.person)
|
||||
|
|
|
|||
Loading…
Reference in a new issue