Code review comment for lp:~rpadovani/launchpad/unhide-comments

Revision history for this message
Colin Watson (cjwatson) wrote :

The fact that you're modifying something in lib/lp/coop/answersbugs/ should be a clue that you need to go and look in lib/lp/answers/ for users of the same test. In this case your change is going to make TestQuestionMessageVisibility fail. As it happens, questions already behave the right way here, and there's a specific test for that. I would suggest removing TestQuestionMessageVisibility.test_commenter_can_see_comments in favour of your coop test, and adjusting TestQuestionMessageVisibility.makeHiddenMessage to match, something like this:

    if comment_owner is None:
        comment_owner = self.factory.makePerson()
    with celebrity_logged_in('admin'):
        question = self.factory.makeQuestion()
        comment = question.addComment(comment_owner, self.comment_text)
        removeSecurityProxy(comment).message.visible = False
    return question

The other thing you need to do is to do something about the presentation. Users should see their self-hidden comments in the same way that admins do, which requires having the adminHiddenContent class set (slightly inaccurate name, but no matter). That will require changing BugComment.show_for_admin; you probably want to change BugComment.__init__ to save user_owns_comment as an instance attribute, and then you can test that in show_for_admin. As far as testing for that goes, you're probably best off editing the existing pagetest in lib/lp/bugs/stories/bugs/xx-bug-hidden-comments.txt, which is the only place that tests the presence of the adminHiddenComment class at the moment.

review: Needs Fixing

« Back to merge proposal