Fix.
This commit is contained in:
parent
eafb6dd236
commit
2b9f5c85c6
2 changed files with 17 additions and 12 deletions
|
@ -591,6 +591,22 @@ condition example
|
||||||
selector['value'] = selector['value'].split(/,/).collect(&:strip)
|
selector['value'] = selector['value'].split(/,/).collect(&:strip)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if selector['operator'].include?('in working time')
|
||||||
|
next if attributes[1] != 'calendar_id'
|
||||||
|
raise 'Please enable execution_time feature to use it (currently only allowed for triggers and schedulers)' if !options[:execution_time]
|
||||||
|
|
||||||
|
biz = Calendar.lookup(id: selector['value'])&.biz
|
||||||
|
next if biz.blank?
|
||||||
|
|
||||||
|
if ( selector['operator'] == 'is in working time' && !biz.in_hours?(Time.zone.now) ) || ( selector['operator'] == 'is not in working time' && biz.in_hours?(Time.zone.now) )
|
||||||
|
no_result = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
# skip to next condition
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
if query != ''
|
if query != ''
|
||||||
query += ' AND '
|
query += ' AND '
|
||||||
end
|
end
|
||||||
|
@ -828,17 +844,6 @@ condition example
|
||||||
raise "Unknown selector attributes '#{selector.inspect}'"
|
raise "Unknown selector attributes '#{selector.inspect}'"
|
||||||
end
|
end
|
||||||
bind_params.push time
|
bind_params.push time
|
||||||
elsif selector['operator'].include?('in working time')
|
|
||||||
next if attributes[1] != 'calendar_id'
|
|
||||||
raise 'Please enable execution_time feature to use it (currently only allowed for triggers and schedulers)' if !options[:execution_time]
|
|
||||||
|
|
||||||
biz = Calendar.lookup(id: selector['value'])&.biz
|
|
||||||
next if biz.blank?
|
|
||||||
|
|
||||||
if ( selector['operator'] == 'is in working time' && !biz.in_hours?(Time.zone.now) ) || ( selector['operator'] == 'is not in working time' && biz.in_hours?(Time.zone.now) )
|
|
||||||
no_result = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
raise "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
|
raise "Invalid operator '#{selector['operator']}' for '#{selector['value'].inspect}'"
|
||||||
end
|
end
|
||||||
|
|
|
@ -166,7 +166,7 @@ RSpec.describe Trigger, type: :model do
|
||||||
|
|
||||||
context 'is in working time' do
|
context 'is in working time' do
|
||||||
let(:condition) do
|
let(:condition) do
|
||||||
{ 'execution_time.calendar_id' => { 'operator' => 'is in working time', 'value' => calendar.id } }
|
{ 'ticket.state_id' => { 'operator' => 'is', 'value' => Ticket::State.all.pluck(:id) }, 'execution_time.calendar_id' => { 'operator' => 'is in working time', 'value' => calendar.id } }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does trigger only in working time' do
|
it 'does trigger only in working time' do
|
||||||
|
|
Loading…
Reference in a new issue