-
Notifications
You must be signed in to change notification settings - Fork 524
add rails validation to prevent unlaunching a stable course #70092
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
Conversation
| validates :link, presence: true | ||
| validates :published_state, acceptance: {accept: Curriculum::SharedCourseConstants::PUBLISHED_STATE.to_h.values, message: 'must be in_development, pilot, beta, preview or stable'} | ||
| validate :validate_family_name_and_version_year | ||
| validate :prevent_unlaunch_stable_courses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do sometimes need to move curriculum back into in_development so curriculum writers can make changes. How does this validation affect that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this provide enough detail?
# In the case where you really do want to unpublish a course, such as to allow
# curriculum writers to make edits to the course on levelbuilder, you can work
# around this validation by first changing the published_state to another
# state before changing it to in_development.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we could just do validate: false as well 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went to update the comment, but then I realized that .save(validate: false) and .update_columns are slightly riskier because they skip other validations, such as ensuring that the new value is a valid published state and not a misspelling like development. People who know about the other shortcuts can still feel free to use them at their own risk. Let's try going with what we have here and we can update it later if it becomes a stumbling block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we want to make this more dev-user-friendly in the future, one idea would be to add an attribute like our existing skip_name_format_validation, so that it can be inlined into an update! call and also preserve existing validations.
We've had 2 instances of a stable course inexplicably changing to in_development as part of a levelbuilder scoop:
In the second case, the AIF 2025 course was unpublished in production and became unavailable to end users.
This PR adds a validation specifically to give an error if a stable course changes to in_development again in any environment. this serves a few purposes:
Testing story
I am relying on existing test coverage to ensure this doesn't break any flows we care about. I'm open to other checks to perform before shipping this if any reviewers have specific ideas.