0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Add spec for action callbacks

Dieser Commit ist enthalten in:
Angus McLeod 2022-09-23 17:00:41 +02:00
Ursprung aa288b19e2
Commit 12e5bef372

Datei anzeigen

@ -298,4 +298,23 @@ describe CustomWizard::Action do
updater.update updater.update
expect(updater.result[:redirect_on_next]).to eq("https://google.com") expect(updater.result[:redirect_on_next]).to eq("https://google.com")
end end
it 'registers callbacks' do
wizard = CustomWizard::Builder.new(@template[:id], user).build
described_class.register_callback(:before_create_topic) do |params, wizard, action, submission|
params[:topic_opts][:custom_fields]["topic_custom_field"] = true
params
end
action = CustomWizard::Action.new(
wizard: wizard,
action: create_topic.with_indifferent_access,
submission: wizard.current_submission
)
action.perform
expect(action.result.success?).to eq(true)
expect(Topic.find(action.result.output).custom_fields["topic_custom_field"]).to eq("t")
end
end end