mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:43:33 +08:00
FIX: Allow expanding posts when anonymous, add specs
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user