Skip to content

Conversation

@nicolasfranck
Copy link
Contributor

Fixes #2860

Changes proposed in this PR:

  • when button "unpublish" is clicked, and that template is published and that template is used by one or more plans, a new version should be created, instead of risking to alter the structure of existing plans
  • select and update should happen within the same transaction

Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me. Thanks @nicolasfranck

Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

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

Thanks for patching this @nicolasfranck. Rubocop has one complaint. If you can switch that if statement to a one-liner it should make Rubocop happy

flash[:alert] = _("Unable to unpublish your #{template_type(template)}.")
Template.transaction do
# expected: template is latest
if template.published? && template.plans.any?
Copy link
Contributor

Choose a reason for hiding this comment

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

Change this to a one-liner template.generate_version! if template.published? && template.plans.any? to make Rubocop happy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants