forked from zammad/zammad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrigger.rb
33 lines (26 loc) · 911 Bytes
/
trigger.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
FactoryBot.define do
factory :trigger do
sequence(:name) { |n| "Test trigger #{n}" }
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 }
end
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
end