Fixes #3428 - Trigger ignores changes on some Ticket attributes.
This commit is contained in:
parent
bf7f993a7a
commit
f80ac0e707
4 changed files with 88 additions and 15 deletions
|
@ -91,7 +91,6 @@ class App.UiElement.ticket_selector
|
||||||
|
|
||||||
else
|
else
|
||||||
for row in App[groupMeta.model].configure_attributes
|
for row in App[groupMeta.model].configure_attributes
|
||||||
|
|
||||||
# ignore passwords and relations
|
# ignore passwords and relations
|
||||||
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false
|
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false
|
||||||
config = _.clone(row)
|
config = _.clone(row)
|
||||||
|
@ -121,6 +120,10 @@ class App.UiElement.ticket_selector
|
||||||
translate: true
|
translate: true
|
||||||
operator: ['is', 'is not']
|
operator: ['is', 'is not']
|
||||||
|
|
||||||
|
# Remove 'has changed' operator from attributes which don't support the operator.
|
||||||
|
['ticket.created_at', 'ticket.updated_at'].forEach (element_name) ->
|
||||||
|
elements[element_name]['operator'] = elements[element_name]['operator'].filter (item) -> item != 'has changed'
|
||||||
|
|
||||||
elements['ticket.mention_user_ids'] =
|
elements['ticket.mention_user_ids'] =
|
||||||
name: 'mention_user_ids'
|
name: 'mention_user_ids'
|
||||||
display: 'Subscribe'
|
display: 'Subscribe'
|
||||||
|
|
|
@ -203,11 +203,6 @@ class TransactionDispatcher
|
||||||
real_changes = {}
|
real_changes = {}
|
||||||
record.changes_to_save.each do |key, value|
|
record.changes_to_save.each do |key, value|
|
||||||
next if key == 'updated_at'
|
next if key == 'updated_at'
|
||||||
next if key == 'first_response_at'
|
|
||||||
next if key == 'close_at'
|
|
||||||
next if key == 'last_contact_agent_at'
|
|
||||||
next if key == 'last_contact_customer_at'
|
|
||||||
next if key == 'last_contact_at'
|
|
||||||
next if key == 'article_count'
|
next if key == 'article_count'
|
||||||
next if key == 'create_article_type_id'
|
next if key == 'create_article_type_id'
|
||||||
next if key == 'create_article_sender_id'
|
next if key == 'create_article_sender_id'
|
||||||
|
|
|
@ -1704,6 +1704,59 @@ RSpec.describe Ticket, type: :model do
|
||||||
.to change { NotificationFactory::Mailer.already_sent?(ticket, agent, 'email') }.to(1)
|
.to change { NotificationFactory::Mailer.already_sent?(ticket, agent, 'email') }.to(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Ticket has changed attributes:' do
|
||||||
|
subject!(:ticket) { create(:ticket) }
|
||||||
|
|
||||||
|
let(:group) { create(:group) }
|
||||||
|
let(:condition_field) { nil }
|
||||||
|
|
||||||
|
shared_examples 'updated ticket group with trigger condition' do
|
||||||
|
it 'updated ticket group with has changed trigger condition' do
|
||||||
|
expect { TransactionDispatcher.commit }.to change { ticket.reload.group }.to(group)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
create(
|
||||||
|
:trigger,
|
||||||
|
condition: { "ticket.#{condition_field}" => { 'operator' => 'has changed', 'value' => 'create' } },
|
||||||
|
perform: { 'ticket.group_id' => { 'value' => group.id } }
|
||||||
|
)
|
||||||
|
|
||||||
|
ticket.update!(condition_field => Time.zone.now)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when changing 'first_response_at' attribute" do
|
||||||
|
let(:condition_field) { 'first_response_at' }
|
||||||
|
|
||||||
|
include_examples 'updated ticket group with trigger condition'
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when changing 'close_at' attribute" do
|
||||||
|
let(:condition_field) { 'close_at' }
|
||||||
|
|
||||||
|
include_examples 'updated ticket group with trigger condition'
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when changing 'last_contact_agent_at' attribute" do
|
||||||
|
let(:condition_field) { 'last_contact_agent_at' }
|
||||||
|
|
||||||
|
include_examples 'updated ticket group with trigger condition'
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when changing 'last_contact_customer_at' attribute" do
|
||||||
|
let(:condition_field) { 'last_contact_customer_at' }
|
||||||
|
|
||||||
|
include_examples 'updated ticket group with trigger condition'
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when changing 'last_contact_at' attribute" do
|
||||||
|
let(:condition_field) { 'last_contact_at' }
|
||||||
|
|
||||||
|
include_examples 'updated ticket group with trigger condition'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'Mentions:', sends_notification_emails: true do
|
describe 'Mentions:', sends_notification_emails: true do
|
||||||
|
@ -2127,5 +2180,4 @@ RSpec.describe Ticket, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,13 @@ require 'system/examples/pagination_examples'
|
||||||
|
|
||||||
RSpec.describe 'Manage > Trigger', type: :system do
|
RSpec.describe 'Manage > Trigger', type: :system do
|
||||||
|
|
||||||
|
def open_new_trigger_dialog
|
||||||
|
visit '/#manage/trigger'
|
||||||
|
click_on 'New Trigger'
|
||||||
|
|
||||||
|
modal_ready
|
||||||
|
end
|
||||||
|
|
||||||
context 'Selector' do
|
context 'Selector' do
|
||||||
|
|
||||||
context 'custom attribute', db_strategy: :reset do
|
context 'custom attribute', db_strategy: :reset do
|
||||||
|
@ -23,10 +30,7 @@ RSpec.describe 'Manage > Trigger', type: :system do
|
||||||
nulloption: true,
|
nulloption: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
visit '/#manage/trigger'
|
open_new_trigger_dialog
|
||||||
click '.page-header-meta .btn--success'
|
|
||||||
|
|
||||||
modal_ready
|
|
||||||
|
|
||||||
within '.modal .ticket_selector' do
|
within '.modal .ticket_selector' do
|
||||||
find('.js-attributeSelector select').select(attribute.display)
|
find('.js-attributeSelector select').select(attribute.display)
|
||||||
|
@ -57,10 +61,7 @@ RSpec.describe 'Manage > Trigger', type: :system do
|
||||||
it 'shows tag selection list in foreground' do
|
it 'shows tag selection list in foreground' do
|
||||||
tag_item = create :tag_item
|
tag_item = create :tag_item
|
||||||
|
|
||||||
visit '/#manage/trigger'
|
open_new_trigger_dialog
|
||||||
click_on 'New Trigger'
|
|
||||||
|
|
||||||
modal_ready
|
|
||||||
|
|
||||||
within '.modal .ticket_perform_action' do
|
within '.modal .ticket_perform_action' do
|
||||||
find('.js-attributeSelector select').select('Tags')
|
find('.js-attributeSelector select').select('Tags')
|
||||||
|
@ -77,4 +78,26 @@ RSpec.describe 'Manage > Trigger', type: :system do
|
||||||
context 'ajax pagination' do
|
context 'ajax pagination' do
|
||||||
include_examples 'pagination', model: :trigger, klass: Trigger, path: 'manage/trigger'
|
include_examples 'pagination', model: :trigger, klass: Trigger, path: 'manage/trigger'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with elements which do not support 'has changed' operator" do
|
||||||
|
it "check 'created_at' element" do
|
||||||
|
open_new_trigger_dialog
|
||||||
|
|
||||||
|
within '.modal .ticket_selector' do
|
||||||
|
find(".js-attributeSelector select option[value='ticket.created_at']").select_option
|
||||||
|
|
||||||
|
expect(page).to have_no_css('select[name="condition::ticket.created_at::operator"] option[value="has changed"]')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it "check 'updated_at' element" do
|
||||||
|
open_new_trigger_dialog
|
||||||
|
|
||||||
|
within '.modal .ticket_selector' do
|
||||||
|
find(".js-attributeSelector select option[value='ticket.updated_at']").select_option
|
||||||
|
|
||||||
|
expect(page).to have_no_css('select[name="condition::ticket.updated_at::operator"] option[value="has changed"]')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue