Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use an empty list instead of [None] if revision.user doesn't exists #8685

Closed
wants to merge 3 commits into from

Conversation

yvess
Copy link
Contributor

@yvess yvess commented Jun 15, 2022

this fixes #7879

Please check the following:

  • Do the tests still pass?1
  • Does the code comply with the style guide?
    • Run make lint from the Wagtail root.
  • For Python changes: Have you added tests to cover the new/fixed behaviour?
  • For front-end changes: Did you test on all of Wagtail’s supported environments?2
    • Please list the exact browser and operating system versions you tested:
    • Please list which assistive technologies 3 you tested:
  • For new features: Has the documentation been updated accordingly?

Please describe additional details for testing this change.

As described in #7879:

Steps to Reproduce

  • Enter the Django shell and import the page model.
  • Execute page.save_revision(submitted_for_moderation=True)
  • See your revision in the moderation queue (as a moderator user), and attempt to accept the revision

Now it passes, before it showed a 500 error

Footnotes

  1. Development Testing

  2. Browser and device support

  3. Accessibility Target

@squash-labs
Copy link

squash-labs bot commented Jun 15, 2022

Manage this branch in Squash

Test this branch here: https://yvessfix7879-revision-without-1l311.squash.io

@gasman
Copy link
Collaborator

gasman commented Jun 15, 2022

Thanks @yvess!
We should definitely add a test for this case in test_moderation.py, to verify that this has been fixed and ensure that the bug doesn't get re-introduced in future code changes.

Essentially we want a test case that performs the steps described in #7879, and I think we can get there by copying the setUp and test_approve_moderation_view functions into a new class - named something like TestApproveRejectModerationWithoutUser - and removing the user argument from the line self.page.save_revision(user=self.submitter, submitted_for_moderation=True). When I try that locally on an unpatched copy of Wagtail, the test then fails with AttributeError: 'NoneType' object has no attribute 'is_active' which I think is the error we're expecting.

Copy link
Collaborator

@gasman gasman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - thanks!

@gasman
Copy link
Collaborator

gasman commented Jun 16, 2022

Merged in e2e356d.

@gasman gasman closed this Jun 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accepting a revision without a user causes a server error
3 participants