2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2018-07-18 07:30:50 +00:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :trigger do
|
|
|
|
sequence(:name) { |n| "Test trigger #{n}" }
|
2019-02-26 11:00:46 +00:00
|
|
|
condition { { 'ticket.state_id' => { 'operator' => 'is not', 'value' => 4 } } }
|
|
|
|
perform { { 'ticket.state_id' => { 'value' => 4 } } }
|
|
|
|
active { true }
|
|
|
|
created_by_id { 1 }
|
|
|
|
updated_by_id { 1 }
|
2018-07-18 07:30:50 +00:00
|
|
|
end
|
2021-08-19 17:31:15 +00:00
|
|
|
|
|
|
|
trait :conditionable do
|
|
|
|
transient do
|
|
|
|
condition_ticket_action { nil }
|
|
|
|
end
|
|
|
|
|
|
|
|
condition { {} }
|
|
|
|
|
|
|
|
callback(:after_stub, :before_create) do |object, context|
|
|
|
|
hash = object.condition
|
|
|
|
|
|
|
|
hash['ticket.action'] = { 'operator' => 'is', 'value' => context.condition_ticket_action.to_s } if context.condition_ticket_action
|
|
|
|
|
|
|
|
object.condition = hash
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# empty trigger to help to test atomically
|
|
|
|
trait :no_perform do
|
|
|
|
perform { { null: true } }
|
|
|
|
end
|
2018-07-18 07:30:50 +00:00
|
|
|
end
|