Anons should be able to see post history

This commit is contained in:
Neil Lalonde 2013-06-19 16:43:16 -04:00
parent d5643551cc
commit e263bb3c0a
2 changed files with 11 additions and 8 deletions

View File

@ -4,7 +4,7 @@ require_dependency 'post_destroyer'
class PostsController < ApplicationController
# Need to be logged in for all actions here
before_filter :ensure_logged_in, except: [:show, :replies, :by_number, :short_link]
before_filter :ensure_logged_in, except: [:show, :replies, :by_number, :short_link, :versions]
skip_before_filter :store_incoming_links, only: [:short_link]
skip_before_filter :check_xhr, only: [:markdown,:short_link]

View File

@ -56,13 +56,7 @@ describe PostsController do
describe 'versions' do
it 'raises an exception when not logged in' do
lambda { xhr :get, :versions, post_id: 123 }.should raise_error(Discourse::NotLoggedIn)
end
describe 'when logged in' do
let(:post) { Fabricate(:post, user: log_in) }
shared_examples 'posts_controller versions examples' do
it "raises an error if the user doesn't have permission to see the post" do
Guardian.any_instance.expects(:can_see?).with(post).returns(false)
xhr :get, :versions, post_id: post.id
@ -73,7 +67,16 @@ describe PostsController do
xhr :get, :versions, post_id: post.id
::JSON.parse(response.body).should be_present
end
end
context 'when not logged in' do
let(:post) { Fabricate(:post) }
include_examples 'posts_controller versions examples'
end
context 'when logged in' do
let(:post) { Fabricate(:post, user: log_in) }
include_examples 'posts_controller versions examples'
end
end