mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 21:19:41 -06:00
3be4924b99
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)
34 lines
901 B
Ruby
34 lines
901 B
Ruby
# frozen_string_literal: true
|
|
|
|
describe "TopicRequiredWords" do
|
|
fab!(:user)
|
|
fab!(:topic)
|
|
fab!(:automation) do
|
|
Fabricate(
|
|
:automation,
|
|
script: DiscourseAutomation::Scripts::TOPIC_REQUIRED_WORDS,
|
|
trigger: DiscourseAutomation::Triggers::TOPIC,
|
|
)
|
|
end
|
|
|
|
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[DiscourseAutomation::AUTOMATION_IDS_CUSTOM_FIELD]).to eq(
|
|
[automation.id],
|
|
)
|
|
|
|
new_topic = create_topic
|
|
automation.upsert_field!(
|
|
"restricted_topic",
|
|
"text",
|
|
{ value: new_topic.id },
|
|
target: "trigger",
|
|
)
|
|
expect(new_topic.custom_fields[DiscourseAutomation::AUTOMATION_IDS_CUSTOM_FIELD]).to eq(
|
|
[automation.id],
|
|
)
|
|
end
|
|
end
|
|
end
|