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

preserve encrypted flag when cloning DSLDefined levels #27066

Merged
merged 8 commits into from Feb 18, 2019

Conversation

davidsbailey
Copy link
Member

Background

When scripts containing encrypted levels have been copied in the past, the new copies of those levels are not encrypted. for example:

Generally speaking, Script copying works by calling Script#clone_with_suffix which calls Level#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 the encrypted flag on encrypted/unencrypted multi/match levels in that script.

level
level_params = {}
level_params[:encrypted] = encrypted if encrypted
self.class.create_from_level_builder({dsl_text: new_dsl}, level_params) if new_dsl
Copy link
Member Author

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.

Copy link
Member Author

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).

@davidsbailey
Copy link
Member Author

@islemaster , please review!

Copy link
Contributor

@islemaster islemaster left a comment

Choose a reason for hiding this comment

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

🎉 Looks great.

@davidsbailey davidsbailey merged commit 198a74d into staging Feb 18, 2019
@davidsbailey davidsbailey deleted the encrypt-cloned-dsl branch February 18, 2019 18:26
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.

None yet

2 participants