discourse/plugins/automation/spec/triggers/topic_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
901 B
Ruby
Raw Normal View History

# 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