Skip to content
Extraits de code Groupes Projets
Valider a104f4e3 rédigé par Maxwell Salzberg's avatar Maxwell Salzberg
Parcourir les fichiers

if a user is logged in, redirect them to the proper authenticated view, not the public route

parent 4b0157f5
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,13 @@ class PostsController < ApplicationController
def show
@post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
#hax to upgrade logged in users who can comment
if @post
if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
redirect_to "/#{@post.class.to_s.pluralize.underscore}/#{@post.id}"
return
end
@landing_page = true
@person = @post.author
if @person.owner_id
......
......@@ -6,21 +6,28 @@ require 'spec_helper'
describe PostsController do
before do
@user = alice
alice
end
describe '#show' do
it 'shows a public post' do
status = @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
get :show, :id => status.id
response.status= 200
end
it 'does not show a private post' do
status = @user.post(:status_message, :text => "hello", :public => false, :to => 'all')
status = alice.post(:status_message, :text => "hello", :public => false, :to => 'all')
get :show, :id => status.id
response.status = 302
end
it 'redirects to the proper show page if the user has visibility of the post' do
status = alice.post(:status_message, :text => "hello", :public => true, :to => 'all')
sign_in bob
get :show, :id => status.id
response.should be_redirect
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter