FIX: Allow expanding posts when anonymous, add specs

This commit is contained in:
Robin Ward
2014-04-03 11:30:43 -04:00
parent baff2c2fd7
commit 10d0320532
3 changed files with 29 additions and 9 deletions

View File

@ -490,4 +490,21 @@ describe PostsController do
end
describe 'expandable embedded posts' do
let(:post) { Fabricate(:post) }
it "raises an error when you can't see the post" do
Guardian.any_instance.expects(:can_see?).with(post).returns(false)
xhr :get, :expand_embed, id: post.id
response.should_not be_success
end
it "retrieves the body when you can see the post" do
Guardian.any_instance.expects(:can_see?).with(post).returns(true)
TopicEmbed.expects(:expanded_for).with(post).returns("full content")
xhr :get, :expand_embed, id: post.id
response.should be_success
::JSON.parse(response.body)['cooked'].should == "full content"
end
end
end