mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: create an automation with forced_triggerable enabled (#29030)
When trying to create a new automation based on a scriptable that has "force_triggerable" enable, it would break because of a typo in the code. This fixes the typo and add a spec to ensure this code path is tested.
This commit is contained in:
parent
edcc581d43
commit
252dcfbfa6
|
@ -29,7 +29,7 @@ module DiscourseAutomation
|
|||
)
|
||||
|
||||
if automation.scriptable&.forced_triggerable
|
||||
automation.trigger = scriptable.forced_triggerable[:triggerable].to_s
|
||||
automation.trigger = automation.scriptable.forced_triggerable[:triggerable].to_s
|
||||
end
|
||||
|
||||
automation.save!
|
||||
|
|
|
@ -48,6 +48,48 @@ describe DiscourseAutomation::AdminAutomationsController do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#create" do
|
||||
let(:script) { "forced_triggerable" }
|
||||
|
||||
before do
|
||||
DiscourseAutomation::Scriptable.add(script) do
|
||||
triggerable! :recurring, { recurrence: { interval: 1, frequency: "day" } }
|
||||
end
|
||||
end
|
||||
|
||||
after { DiscourseAutomation::Scriptable.remove(script) }
|
||||
|
||||
context "when logged in as an admin" do
|
||||
before { sign_in(Fabricate(:admin)) }
|
||||
|
||||
it "creates the 'forced triggerable' automation" do
|
||||
post "/admin/plugins/discourse-automation/automations.json",
|
||||
params: {
|
||||
automation: {
|
||||
name: "foobar",
|
||||
script:,
|
||||
},
|
||||
}
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
context "when logged in as a regular user" do
|
||||
before { sign_in(Fabricate(:user)) }
|
||||
|
||||
it "raises a 404" do
|
||||
post "/admin/plugins/discourse-automation/automations.json",
|
||||
params: {
|
||||
automation: {
|
||||
name: "foobar",
|
||||
script:,
|
||||
},
|
||||
}
|
||||
expect(response.status).to eq(404)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#update" do
|
||||
context "when logged in as an admin" do
|
||||
before { sign_in(Fabricate(:admin)) }
|
||||
|
|
Loading…
Reference in New Issue
Block a user