FIX: allow local oneboxes to public topics/posts in PM

This commit is contained in:
Régis Hanol
2018-02-15 18:13:57 +01:00
parent 991dfadad7
commit 8e0da35857
2 changed files with 32 additions and 20 deletions

View File

@@ -100,35 +100,45 @@ describe OneboxController do
describe "local onebox" do
it 'does not cache local oneboxes' do
post1 = create_post
url = Discourse.base_url + post1.url
post = create_post
url = Discourse.base_url + post.url
get :show, params: { url: url, category_id: post1.topic.category_id }, format: :json
get :show, params: { url: url, category_id: post.topic.category_id }, format: :json
expect(response.body).to include('blockquote')
post1.trash!
post.trash!
get :show, params: { url: url, category_id: post1.topic.category_id }, format: :json
get :show, params: { url: url, category_id: post.topic.category_id }, format: :json
expect(response.body).not_to include('blockquote')
end
end
end
it 'does not onebox when you have no permission on category' do
log_in
it 'does not onebox when you have no permission on category' do
log_in
post = create_post
url = Discourse.base_url + post.url
post1 = create_post
url = Discourse.base_url + post1.url
get :show, params: { url: url, category_id: post.topic.category_id }, format: :json
expect(response.body).to include('blockquote')
get :show, params: { url: url, category_id: post1.topic.category_id }, format: :json
expect(response.body).to include('blockquote')
post.topic.category.set_permissions(staff: :full)
post.topic.category.save
post1.topic.category.set_permissions(staff: :full)
post1.topic.category.save
get :show, params: { url: url, category_id: post.topic.category_id }, format: :json
expect(response.body).not_to include('blockquote')
end
it 'allows onebox to public topics/posts in PM' do
log_in
post = create_post
url = Discourse.base_url + post.url
get :show, params: { url: url }, format: :json
expect(response.body).to include('blockquote')
end
get :show, params: { url: url, category_id: post1.topic.category_id }, format: :json
expect(response.body).not_to include('blockquote')
end
end