diff --git a/app/assets/javascripts/app/controllers/_ui_element/richtext_search.coffee b/app/assets/javascripts/app/controllers/_ui_element/richtext_search.coffee new file mode 100644 index 000000000..9a5f05581 --- /dev/null +++ b/app/assets/javascripts/app/controllers/_ui_element/richtext_search.coffee @@ -0,0 +1,4 @@ +# coffeelint: disable=camel_case_classes +class App.UiElement.richtext_search + @render: (attribute) -> + $( App.view('generic/input')( attribute: attribute ) ) diff --git a/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.coffee b/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.coffee index a88901169..f3a7dbe11 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/ticket_selector.coffee @@ -25,6 +25,7 @@ class App.UiElement.ticket_selector '^radio$': ['is', 'is not'] '^select$': ['is', 'is not'] '^input$': ['contains', 'contains not'] + '^richtext$': ['contains', 'contains not'] '^textarea$': ['contains', 'contains not'] '^tag$': ['contains all', 'contains one', 'contains all not', 'contains one not'] @@ -37,6 +38,7 @@ class App.UiElement.ticket_selector '^radio$': ['is', 'is not', 'has changed'] '^select$': ['is', 'is not', 'has changed'] '^input$': ['contains', 'contains not', 'has changed'] + '^richtext$': ['contains', 'contains not', 'has changed'] '^textarea$': ['contains', 'contains not', 'has changed'] '^tag$': ['contains all', 'contains one', 'contains all not', 'contains one not'] diff --git a/test/unit/ticket_trigger_test.rb b/test/unit/ticket_trigger_test.rb index 1529e1260..c649c7c58 100644 --- a/test/unit/ticket_trigger_test.rb +++ b/test/unit/ticket_trigger_test.rb @@ -151,15 +151,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -236,7 +235,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(2, ticket1.articles.count, 'ticket1.articles verify') assert_equal(%w[aa abc], ticket1.tag_list) - ticket2 = Ticket.create( + ticket2 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), @@ -245,7 +244,6 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - assert(ticket2, 'ticket2 created') assert_equal('some title äöüß', ticket2.title, 'ticket2.title verify') assert_equal('Users', ticket2.group.name, 'ticket2.group verify') @@ -264,7 +262,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(0, ticket2.articles.count, 'ticket2.articles verify') assert_equal([], ticket2.tag_list) - ticket3 = Ticket.create( + ticket3 = Ticket.create!( title: "some title\n äöüß3", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), @@ -273,7 +271,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ) assert(ticket3, 'ticket3 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket3.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -318,7 +316,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_match('Thanks for your inquiry - 1234 check (some title äöüß3)!', article3.subject) assert_equal('text/html', article3.content_type) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket3.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -343,7 +341,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(4, ticket3.articles.count, 'ticket3.articles verify') assert_equal(%w[aa abc article_create_trigger], ticket3.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket3.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -368,7 +366,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(5, ticket3.articles.count, 'ticket3.articles verify') assert_equal(%w[aa abc article_create_trigger], ticket3.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket3.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -423,14 +421,13 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') assert_equal('some title äöüß', ticket1.title, 'ticket1.title verify') assert_equal('Users', ticket1.group.name, 'ticket1.group verify') @@ -517,14 +514,13 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') assert_equal('some title äöüß', ticket1.title, 'ticket1.title verify') assert_equal('Users', ticket1.group.name, 'ticket1.group verify') @@ -732,7 +728,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('2 normal', ticket_p.priority.name, 'ticket_p.priority verify') assert_equal(2, ticket_p.articles.count, 'ticket_p.articles verify') - article_p = Ticket::Article.create( + article_p = Ticket::Article.create!( ticket_id: ticket_p.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -752,7 +748,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('2 normal', ticket_p.priority.name, 'ticket_p.priority verify') assert_equal(3, ticket_p.articles.count, 'ticket_p.articles verify') - article_p = Ticket::Article.create( + article_p = Ticket::Article.create!( ticket_id: ticket_p.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -772,7 +768,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('2 normal', ticket_p.priority.name, 'ticket_p.priority verify') assert_equal(4, ticket_p.articles.count, 'ticket_p.articles verify') - article_p = Ticket::Article.create( + article_p = Ticket::Article.create!( ticket_id: ticket_p.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -803,7 +799,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ticket_p.state = Ticket::State.lookup(name: 'open') ticket_p.save! - article_p = Ticket::Article.create( + article_p = Ticket::Article.create!( ticket_id: ticket_p.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1207,7 +1203,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', owner: agent, group: Group.lookup(name: 'Users'), @@ -1215,7 +1211,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1240,7 +1236,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(1, ticket1.articles.count) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1283,7 +1279,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1342,7 +1338,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', #owner: agent, group: Group.lookup(name: 'Users'), @@ -1350,7 +1346,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1374,7 +1370,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal([], ticket1.tag_list) UserInfo.current_user_id = agent.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1467,14 +1463,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', group: Group.lookup(name: 'Users'), customer: customer, updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1500,7 +1496,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ticket1.update!(customer: User.lookup(email: 'nicole.braun@zammad.org') ) UserInfo.current_user_id = agent.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1578,14 +1574,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1611,7 +1607,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ticket1.update!(customer: customer ) UserInfo.current_user_id = agent.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1691,7 +1687,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', #owner: agent, group: Group.lookup(name: 'Users'), @@ -1699,7 +1695,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1723,7 +1719,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal([], ticket1.tag_list) UserInfo.current_user_id = agent1.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1762,7 +1758,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal([], ticket1.tag_list) UserInfo.current_user_id = agent1.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1801,7 +1797,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal([], ticket1.tag_list) UserInfo.current_user_id = agent1.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1872,7 +1868,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', #owner: agent, group: Group.lookup(name: 'Users'), @@ -1880,7 +1876,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -1904,7 +1900,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal([], ticket1.tag_list) UserInfo.current_user_id = agent.id - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2019,7 +2015,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', owner: agent, customer: customer, @@ -2027,7 +2023,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2065,7 +2061,7 @@ class TicketTriggerTest < ActiveSupport::TestCase customer.vip = false customer.save! - ticket2 = Ticket.create( + ticket2 = Ticket.create!( title: 'test 123', owner: agent, customer: customer, @@ -2073,7 +2069,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket2.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2157,14 +2153,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2291,7 +2287,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', owner: agent, customer: customer, @@ -2299,7 +2295,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2325,7 +2321,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(2, ticket1.articles.count, 'ticket1.articles verify') assert_equal([], ticket1.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2350,7 +2346,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(3, ticket1.articles.count, 'ticket1.articles verify') assert_equal([], ticket1.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2377,7 +2373,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ticket1.priority = Ticket::Priority.find_by(name: '3 high') ticket1.save! - article = Ticket::Article.create( + article = Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2416,7 +2412,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(6, ticket1.articles.count, 'ticket1.articles verify') assert_equal([], ticket1.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2574,7 +2570,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 123', #owner: agent, customer: customer, @@ -2582,7 +2578,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2624,7 +2620,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(3, ticket1.articles.count, 'ticket1.articles verify') assert_equal([], ticket1.tag_list) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -2718,14 +2714,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient+from@example.com', @@ -2775,14 +2771,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender+from@example.com', to: 'some_recipient@example.com', @@ -2844,14 +2840,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, to: 'some_recipient@example.com', subject: 'some subject', @@ -2913,14 +2909,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, to: 'some_recipient@example.com', subject: 'some subject', @@ -2979,7 +2975,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), @@ -2987,7 +2983,7 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient+from@example.com', @@ -3038,14 +3034,14 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient+from@example.com', @@ -3101,15 +3097,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'loop try 1', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3136,7 +3131,7 @@ class TicketTriggerTest < ActiveSupport::TestCase ticket1.reload assert_equal(2, ticket1.articles.count) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3157,7 +3152,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[2].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[3].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3178,7 +3173,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[4].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[5].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3199,7 +3194,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[6].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[7].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3220,7 +3215,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[8].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[9].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3241,7 +3236,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[10].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[11].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3262,7 +3257,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[12].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[13].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3283,7 +3278,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[14].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[15].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3304,7 +3299,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[16].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[17].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3325,7 +3320,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal('some_loop_sender@example.com', ticket1.articles[18].from) assert_equal('nicole.braun@zammad.org', ticket1.articles[19].to) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3345,7 +3340,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(21, ticket1.articles.count) assert_equal('some_loop_sender@example.com', ticket1.articles[20].from) - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_loop_sender@example.com', to: 'some_loop_recipient@example.com', @@ -3431,15 +3426,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: "some title\n äöüß", group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'some_sender@example.com', to: 'some_recipient@example.com', @@ -3559,15 +3553,14 @@ class TicketTriggerTest < ActiveSupport::TestCase updated_by_id: 1, ) - ticket1 = Ticket.create( + ticket1 = Ticket.create!( title: 'test 1', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket1, 'ticket1 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket1.id, from: 'sender1@example.com', to: 'some_recipient@example.com', @@ -3597,15 +3590,14 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(1, ticket1.articles.count, 'ticket1.articles verify') assert_equal(%w[sender1], ticket1.tag_list) - ticket2 = Ticket.create( + ticket2 = Ticket.create!( title: 'test 2', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), updated_by_id: 1, created_by_id: 1, ) - assert(ticket2, 'ticket2 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket2.id, from: 'sender2@example.com', to: 'some_recipient@example.com', @@ -3637,7 +3629,7 @@ class TicketTriggerTest < ActiveSupport::TestCase assert_equal(1, ticket2.articles.count, 'ticket2.articles verify') assert_equal(%w[sender2], ticket2.tag_list) - ticket3 = Ticket.create( + ticket3 = Ticket.create!( title: 'test 3', group: Group.lookup(name: 'Users'), customer: User.lookup(email: 'nicole.braun@zammad.org'), @@ -3645,7 +3637,7 @@ class TicketTriggerTest < ActiveSupport::TestCase created_by_id: 1, ) assert(ticket3, 'ticket3 created') - Ticket::Article.create( + Ticket::Article.create!( ticket_id: ticket3.id, from: 'sender0@example.com', to: 'some_recipient@example.com', @@ -3677,4 +3669,240 @@ class TicketTriggerTest < ActiveSupport::TestCase article1 = ticket3.articles.last end + + test 'article.body' do + trigger1 = Trigger.create_or_update( + name: 'auto reply', + condition: { + 'ticket.action' => { + 'operator' => 'is', + 'value' => 'create', + }, + 'ticket.state_id' => { + 'operator' => 'is', + 'value' => Ticket::State.lookup(name: 'new').id.to_s, + }, + 'article.body' => { + 'operator' => 'contains', + 'value' => 'hello', + }, + }, + perform: { + 'notification.email' => { + 'body' => 'some text
#{ticket.customer.lastname}
#{ticket.title}
#{article.body}', + 'recipient' => 'ticket_customer', + 'subject' => 'Thanks for your inquiry (#{ticket.title})!', + }, + 'ticket.tags' => { + 'operator' => 'add', + 'value' => 'aa, kk', + }, + }, + disable_notification: true, + active: true, + created_by_id: 1, + updated_by_id: 1, + ) + + ticket1 = Ticket.create!( + title: 'test 1', + group: Group.lookup(name: 'Users'), + customer: User.lookup(email: 'nicole.braun@zammad.org'), + updated_by_id: 1, + created_by_id: 1, + ) + Ticket::Article.create!( + ticket_id: ticket1.id, + from: 'some_sender@example.com', + to: 'some_recipient@example.com', + subject: 'some subject', + message_id: 'some@id', + body: 'some message note hello ', + internal: false, + sender: Ticket::Article::Sender.find_by(name: 'Agent'), + type: Ticket::Article::Type.find_by(name: 'note'), + updated_by_id: 1, + created_by_id: 1, + ) + + ticket1.reload + assert_equal('test 1', ticket1.title, 'ticket1.title verify') + assert_equal('Users', ticket1.group.name, 'ticket1.group verify') + assert_equal('new', ticket1.state.name, 'ticket1.state verify') + assert_equal('2 normal', ticket1.priority.name, 'ticket1.priority verify') + assert_equal(1, ticket1.articles.count, 'ticket1.articles verify') + assert_equal([], ticket1.tag_list) + + Observer::Transaction.commit + + ticket1.reload + assert_equal('test 1', ticket1.title, 'ticket1.title verify') + assert_equal('Users', ticket1.group.name, 'ticket1.group verify') + assert_equal('new', ticket1.state.name, 'ticket1.state verify') + assert_equal(2, ticket1.articles.count, 'ticket1.articles verify') + assert_equal(%w[aa kk], ticket1.tag_list) + article1 = ticket1.articles.last + assert_match('Zammad ', article1.from) + assert_match('nicole.braun@zammad.org', article1.to) + assert_match('Thanks for your inquiry (test 1)!', article1.subject) + assert_match('some message', article1.body) + assert_match('> some message <b>note</b> hello', article1.body) + assert_equal('text/html', article1.content_type) + + ticket2 = Ticket.create!( + title: 'test 1', + group: Group.lookup(name: 'Users'), + customer: User.lookup(email: 'nicole.braun@zammad.org'), + updated_by_id: 1, + created_by_id: 1, + ) + Ticket::Article.create!( + ticket_id: ticket2.id, + from: 'some_sender@example.com', + to: 'some_recipient@example.com', + subject: 'some subject', + message_id: 'some@id', + body: 'some message note', + internal: false, + sender: Ticket::Article::Sender.find_by(name: 'Agent'), + type: Ticket::Article::Type.find_by(name: 'note'), + updated_by_id: 1, + created_by_id: 1, + ) + + ticket2.reload + assert_equal('test 1', ticket2.title, 'ticket2.title verify') + assert_equal('Users', ticket2.group.name, 'ticket2.group verify') + assert_equal('new', ticket2.state.name, 'ticket2.state verify') + assert_equal('2 normal', ticket2.priority.name, 'ticket2.priority verify') + assert_equal(1, ticket2.articles.count, 'ticket2.articles verify') + assert_equal([], ticket2.tag_list) + + Observer::Transaction.commit + + ticket2.reload + assert_equal('test 1', ticket2.title, 'ticket2.title verify') + assert_equal('Users', ticket2.group.name, 'ticket2.group verify') + assert_equal('new', ticket2.state.name, 'ticket2.state verify') + assert_equal(1, ticket2.articles.count, 'ticket2.articles verify') + assert_equal(%w[], ticket2.tag_list) + + trigger1 = Trigger.create_or_update( + name: 'auto reply', + condition: { + 'ticket.action' => { + 'operator' => 'is', + 'value' => 'create', + }, + 'ticket.state_id' => { + 'operator' => 'is', + 'value' => Ticket::State.lookup(name: 'new').id.to_s, + }, + 'article.body' => { + 'operator' => 'contains not', + 'value' => 'hello', + }, + }, + perform: { + 'notification.email' => { + 'body' => 'some text
#{ticket.customer.lastname}
#{ticket.title}
#{article.body}', + 'recipient' => 'ticket_customer', + 'subject' => 'Thanks for your inquiry (#{ticket.title})!', + }, + 'ticket.tags' => { + 'operator' => 'add', + 'value' => 'aa, kk', + }, + }, + disable_notification: true, + active: true, + created_by_id: 1, + updated_by_id: 1, + ) + + ticket3 = Ticket.create!( + title: 'test 1', + group: Group.lookup(name: 'Users'), + customer: User.lookup(email: 'nicole.braun@zammad.org'), + updated_by_id: 1, + created_by_id: 1, + ) + Ticket::Article.create!( + ticket_id: ticket3.id, + from: 'some_sender@example.com', + to: 'some_recipient@example.com', + subject: 'some subject', + message_id: 'some@id', + body: 'some message note hello ', + internal: false, + sender: Ticket::Article::Sender.find_by(name: 'Agent'), + type: Ticket::Article::Type.find_by(name: 'note'), + updated_by_id: 1, + created_by_id: 1, + ) + + ticket3.reload + assert_equal('test 1', ticket3.title, 'ticket3.title verify') + assert_equal('Users', ticket3.group.name, 'ticket3.group verify') + assert_equal('new', ticket3.state.name, 'ticket3.state verify') + assert_equal('2 normal', ticket3.priority.name, 'ticket3.priority verify') + assert_equal(1, ticket3.articles.count, 'ticket3.articles verify') + assert_equal([], ticket3.tag_list) + + Observer::Transaction.commit + + ticket3.reload + assert_equal('test 1', ticket3.title, 'ticket3.title verify') + assert_equal('Users', ticket3.group.name, 'ticket3.group verify') + assert_equal('new', ticket3.state.name, 'ticket3.state verify') + assert_equal(1, ticket3.articles.count, 'ticket3.articles verify') + assert_equal(%w[], ticket3.tag_list) + + ticket4 = Ticket.create!( + title: 'test 1', + group: Group.lookup(name: 'Users'), + customer: User.lookup(email: 'nicole.braun@zammad.org'), + updated_by_id: 1, + created_by_id: 1, + ) + Ticket::Article.create!( + ticket_id: ticket4.id, + from: 'some_sender@example.com', + to: 'some_recipient@example.com', + subject: 'some subject', + message_id: 'some@id', + body: 'some message note 2', + internal: false, + sender: Ticket::Article::Sender.find_by(name: 'Agent'), + type: Ticket::Article::Type.find_by(name: 'note'), + updated_by_id: 1, + created_by_id: 1, + ) + + ticket4.reload + assert_equal('test 1', ticket4.title, 'ticket4.title verify') + assert_equal('Users', ticket4.group.name, 'ticket4.group verify') + assert_equal('new', ticket4.state.name, 'ticket4.state verify') + assert_equal('2 normal', ticket4.priority.name, 'ticket4.priority verify') + assert_equal(1, ticket4.articles.count, 'ticket4.articles verify') + assert_equal([], ticket4.tag_list) + + Observer::Transaction.commit + + ticket4.reload + assert_equal('test 1', ticket4.title, 'ticket4.title verify') + assert_equal('Users', ticket4.group.name, 'ticket4.group verify') + assert_equal('new', ticket4.state.name, 'ticket4.state verify') + assert_equal(2, ticket4.articles.count, 'ticket4.articles verify') + assert_equal(%w[aa kk], ticket4.tag_list) + article4 = ticket4.articles.last + assert_match('Zammad ', article4.from) + assert_match('nicole.braun@zammad.org', article4.to) + assert_match('Thanks for your inquiry (test 1)!', article4.subject) + assert_match('some message', article4.body) + assert_match('> some message <b>note</b> 2', article4.body) + assert_equal('text/html', article4.content_type) + + end + end