From aba36642635df182827c396536eec00553507d16 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 5 May 2016 17:09:35 +0200 Subject: [PATCH] Fixed tests, applied new auto reply. --- db/migrate/20160503000002_update_trigger.rb | 6 +++- db/migrate/20160505000001_update_trigger2.rb | 33 +++++++++++++++++++ db/seeds.rb | 6 +++- .../agent_ticket_actions_level6_test.rb | 8 ++--- 4 files changed, 47 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20160505000001_update_trigger2.rb diff --git a/db/migrate/20160503000002_update_trigger.rb b/db/migrate/20160503000002_update_trigger.rb index aec04bb98..e1e19d39e 100644 --- a/db/migrate/20160503000002_update_trigger.rb +++ b/db/migrate/20160503000002_update_trigger.rb @@ -13,7 +13,7 @@ class UpdateTrigger < ActiveRecord::Migration }, 'ticket.state_id' => { 'operator' => 'is not', - 'value' => '4', + 'value' => Ticket::State.lookup(name: 'closed').id, }, 'article.type_id' => { 'operator' => 'is', @@ -23,6 +23,10 @@ class UpdateTrigger < ActiveRecord::Migration Ticket::Article::Type.lookup(name: 'web').id, ], }, + 'article.sender_id' => { + 'operator' => 'is', + 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id, + }, }, perform: { 'notification.email' => { diff --git a/db/migrate/20160505000001_update_trigger2.rb b/db/migrate/20160505000001_update_trigger2.rb new file mode 100644 index 000000000..f07f74159 --- /dev/null +++ b/db/migrate/20160505000001_update_trigger2.rb @@ -0,0 +1,33 @@ +class UpdateTrigger2 < ActiveRecord::Migration + def up + + # return if it's a new setup + return if !Setting.find_by(name: 'system_init_done') + trigger = Trigger.find_by(name: 'auto reply (on new tickets)') + return if !trigger + trigger.condition = { + 'ticket.action' => { + 'operator' => 'is', + 'value' => 'create', + }, + 'ticket.state_id' => { + 'operator' => 'is not', + 'value' => Ticket::State.lookup(name: 'closed').id, + }, + 'article.type_id' => { + 'operator' => 'is', + 'value' => [ + Ticket::Article::Type.lookup(name: 'email').id, + Ticket::Article::Type.lookup(name: 'phone').id, + Ticket::Article::Type.lookup(name: 'web').id, + ], + }, + 'article.sender_id' => { + 'operator' => 'is', + 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id, + }, + } + trigger.save + end + +end diff --git a/db/seeds.rb b/db/seeds.rb index 68f70ff35..7ad02242a 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3865,7 +3865,7 @@ Trigger.create_or_update( }, 'ticket.state_id' => { 'operator' => 'is not', - 'value' => '4', + 'value' => Ticket::State.lookup(name: 'closed').id, }, 'article.type_id' => { 'operator' => 'is', @@ -3875,6 +3875,10 @@ Trigger.create_or_update( Ticket::Article::Type.lookup(name: 'web').id, ], }, + 'article.sender_id' => { + 'operator' => 'is', + 'value' => Ticket::Article::Sender.lookup(name: 'Customer').id, + }, }, perform: { 'notification.email' => { diff --git a/test/browser/agent_ticket_actions_level6_test.rb b/test/browser/agent_ticket_actions_level6_test.rb index 46519354f..c7c80ec7d 100644 --- a/test/browser/agent_ticket_actions_level6_test.rb +++ b/test/browser/agent_ticket_actions_level6_test.rb @@ -121,11 +121,11 @@ class AgentTicketActionLevel6Test < TestCase value: 'test 6 - ticket 1-1', ) match_not( - css: '.active .ticket-article-item:nth-child(2) .attachments', + css: '.active .ticket-article-item:nth-child(3) .attachments', value: 'upload2.jpg', ) match( - css: '.active .ticket-article-item:nth-child(2) .attachments', + css: '.active .ticket-article-item:nth-child(3) .attachments', value: 'upload1.txt', ) @@ -176,11 +176,11 @@ class AgentTicketActionLevel6Test < TestCase }, ) match( - css: '.active .ticket-article-item:nth-child(3) .attachments', + css: '.active .ticket-article-item:nth-child(4) .attachments', value: 'upload2.jpg', ) match( - css: '.active .ticket-article-item:nth-child(3) .attachments', + css: '.active .ticket-article-item:nth-child(4) .attachments', value: 'upload1.txt', ) #