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
preserve encrypted flag when cloning DSLDefined levels #27066
Conversation
level | ||
level_params = {} | ||
level_params[:encrypted] = encrypted if encrypted | ||
self.class.create_from_level_builder({dsl_text: new_dsl}, level_params) if new_dsl |
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.
[re-posting after adding another commit]
I refactored this to call create_from_level_builder
directly in order to make this unit-testable. Otherwise, level = super(new_name)
would return a level with the right value for encrypted
, but that value would be omitted when update!
--> assign_attributes
--> create_from_level_builder
--> rewrite_dsl_file
was called, causing the resulting dsl file not to be encrypted.
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.
More generally, this closes the gap between what levelbuilders will see on the levelbuilder machine (based on what's in the local db) and what will be seen in other environments (based on what gets output to the filesystem).
5bc1d95
to
b8fcc5d
Compare
@islemaster , please review! |
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.
🎉 Looks great.
Background
When scripts containing encrypted levels have been copied in the past, the new copies of those levels are not encrypted. for example:
code-dot-org/dashboard/config/scripts/u3l04_assessment2.multi
Lines 1 to 2 in 021454b
code-dot-org/dashboard/config/scripts/u3l04_assessment2_2018.multi
Lines 1 to 2 in 021454b
Generally speaking, Script copying works by calling
Script#clone_with_suffix
which callsLevel#clone_with_suffix
for each of its levels. For more background on script copying, see these PRs:Description
This PR preserves the
encrypted
flag when copying DSLDefined levels, and adds corresponding unit tests.Verification
In addition to the new unit tests, I've also manually verified that copying a script via
Script#clone_with_suffix
preserves theencrypted
flag on encrypted/unencrypted multi/match levels in that script.