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

fix: escape stage name when running ensure_record_type task #3827

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cumulusci/tasks/salesforce/EnsureRecordTypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from xml.sax.saxutils import escape

from cumulusci.core.exceptions import TaskOptionsError
from cumulusci.core.utils import process_bool_arg
Expand Down Expand Up @@ -152,7 +153,7 @@ def _build_package(self):
record_type_developer_name=self.options[
"record_type_developer_name"
],
stage_name=self.options["stage_name"],
stage_name=escape(self.options["stage_name"]),
default=default,
)
business_process_link = BUSINESS_PROCESS_LINK.format(
Expand Down
11 changes: 5 additions & 6 deletions cumulusci/tasks/salesforce/tests/test_EnsureRecordTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<fullName>NPSP_Default</fullName>
<isActive>true</isActive>
<values>
<fullName>Test</fullName>
<fullName>Identify &amp; Qualify</fullName>
<default>false</default>
</values>
</businessProcesses>
Expand Down Expand Up @@ -79,7 +79,7 @@
"name": "StageName",
"picklistValues": [
{"value": "Bad", "active": False},
{"value": "Test", "active": True},
{"value": "Identify & Qualify", "active": True},
],
},
],
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_infers_correct_business_process(self):

assert task.options["generate_business_process"]
assert task.options["generate_record_type"]
assert task.options["stage_name"] == "Test"
assert task.options["stage_name"] == "Identify & Qualify"

def test_no_business_process_where_unneeded(self):
task = create_task(
Expand Down Expand Up @@ -178,7 +178,6 @@ def test_generates_record_type_and_business_process(self):
with open(os.path.join("objects", "Opportunity.object"), "r") as f:
opp_contents = f.read()
assert OPPORTUNITY_METADATA == opp_contents
assert OPPORTUNITY_METADATA == opp_contents
with open(os.path.join("package.xml"), "r") as f:
pkg_contents = f.read()
assert PACKAGE_XML == pkg_contents
Expand All @@ -203,8 +202,8 @@ def test_generates_record_type_and_business_process__case(self):
with temporary_dir():
task._build_package()
with open(os.path.join("objects", "Case.object"), "r") as f:
opp_contents = f.read()
assert CASE_METADATA == opp_contents
case_contents = f.read()
assert CASE_METADATA == case_contents
with open(os.path.join("package.xml"), "r") as f:
pkg_contents = f.read()
assert PACKAGE_XML == pkg_contents
Expand Down
Loading