BUGFIX: could not see the revisions of a post in a deleted topic

This commit is contained in:
Régis Hanol
2014-05-12 16:30:10 +02:00
parent 312bc6bff9
commit fca6738212
5 changed files with 34 additions and 20 deletions

View File

@ -192,7 +192,6 @@ class PostsController < ApplicationController
def revisions
post_revision = find_post_revision_from_params
guardian.ensure_can_see!(post_revision)
post_revision_serializer = PostRevisionSerializer.new(post_revision, scope: guardian, root: false)
render_json_dump(post_revision_serializer)
end
@ -302,6 +301,8 @@ class PostsController < ApplicationController
# Include deleted posts if the user is staff
finder = finder.with_deleted if current_user.try(:staff?)
post = finder.first
# load deleted topic
post.topic = Topic.with_deleted.find(post.topic_id) if current_user.try(:staff?)
guardian.ensure_can_see!(post)
post
end