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

Latest changes to manual are always published even if made after clicking "Publish" button #1177

Open
floehopper opened this issue Jun 16, 2017 · 0 comments
Labels

Comments

@floehopper
Copy link
Contributor

The VersionMismatchError exception will be raised if ManualPublishTask#version_number does not match Manual#version_number retrieved from the database when PublishManualWorker#perform takes a ManualPublishTask off the "queue" and invokes Manual::PublishService#call.

This commit note says:

As we are now queueing manuals for publishing we need to protect against changes happening between an editor clicking Publish and the worker actually performing the publish.

This suggests to me that if I do the following, I should see the VersionMismatchError exception being raised:

  1. Disable PublishManualWorker
  2. Publish manual
  3. See that manual has been queued for publishing, but not actually published
  4. Edit manual
  5. Makes some changes to the manual
  6. Save manual as draft
  7. Enable PublishManualWorker
  8. Wait for the relevant ManualPublishTask to be processed

However, I do not see the exception and the latest content is saved and published to the Publishing API. I don't think this is what was intended.

I think the problem is that ManualRecord#new_or_existing_draft_edition does not build a new edition if the manual is in the "draft" state. The manual will be in the "draft" state until the relevant ManualPublishTask is processed by PublishManualWorker and so no new edition will be built until the manual is actually published. Thus Manual#version_number will not be incremented and the condition in Manual::PublishService#call will always be true and the exception will never be raised.

Note that all of the tests around this supposed protection mechanism are stubbing the raising of the exception and not exercising the check in a realistic context which explains why we don't see any tests failing.

We could fix this by discriminating between a draft and a draft awaiting publication, but I have a feeling this might be quite complicated. It might be simpler to head things off at the pass by preventing editing of a manual which is a draft awaiting publication.

@floehopper floehopper added the bug label Jun 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant