DEV: Move array type custom fields to JSON type in automation (#26939)

The automation plugin has 4 custom field types that are array typed. However, array typed custom fields are deprecated and should be migrated to JSON type.

This commit does a couple of things:

1. Migrate all four custom fields to JSON
2. Fix a couple of small bugs that have been discovered while migrating the custom fields to JSON (see the comments on this commit's PR for details https://github.com/discourse/discourse/pull/26939)
This commit is contained in:
Osama Sayegh
2024-05-10 18:47:12 +03:00
committed by GitHub
parent 4e22b505c5
commit 3be4924b99
17 changed files with 264 additions and 103 deletions

View File

@ -14,7 +14,9 @@ describe "TopicRequiredWords" do
context "when updating trigger" do
it "updates the custom field" do
automation.upsert_field!("restricted_topic", "text", { value: topic.id }, target: "trigger")
expect(topic.custom_fields["discourse_automation_ids"]).to eq([automation.id])
expect(topic.custom_fields[DiscourseAutomation::AUTOMATION_IDS_CUSTOM_FIELD]).to eq(
[automation.id],
)
new_topic = create_topic
automation.upsert_field!(
@ -23,7 +25,9 @@ describe "TopicRequiredWords" do
{ value: new_topic.id },
target: "trigger",
)
expect(new_topic.custom_fields["discourse_automation_ids"]).to eq([automation.id])
expect(new_topic.custom_fields[DiscourseAutomation::AUTOMATION_IDS_CUSTOM_FIELD]).to eq(
[automation.id],
)
end
end
end