Refactoring: Migrate ticket_null_byte_test.rb to RSpec.
This commit is contained in:
parent
27b9bbd401
commit
50c1cfcb0a
4 changed files with 15 additions and 33 deletions
|
@ -5,6 +5,7 @@ FactoryBot.define do
|
|||
sender_name 'Customer'
|
||||
end
|
||||
|
||||
ticket
|
||||
from 'factory-customer-1@example.com'
|
||||
to 'factory-customer-1@example.com'
|
||||
subject 'factory article'
|
||||
|
|
|
@ -1,6 +1,13 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Ticket::Article do
|
||||
describe '.create' do
|
||||
it 'handles NULL byte in subject or body' do
|
||||
expect(create(:ticket_article, subject: "com test 1\u0000", body: "some\u0000message 123"))
|
||||
.to be_persisted
|
||||
end
|
||||
end
|
||||
|
||||
describe 'hooks on creation' do
|
||||
context 'of outgoing article' do
|
||||
context 'over Twitter' do
|
||||
|
|
|
@ -65,6 +65,13 @@ RSpec.describe Ticket do
|
|||
|
||||
end
|
||||
|
||||
describe '.create' do
|
||||
it 'handles NULL byte in title' do
|
||||
expect(create(:ticket, title: "some title \u0000 123"))
|
||||
.to be_persisted
|
||||
end
|
||||
end
|
||||
|
||||
describe '#destroy' do
|
||||
|
||||
it 'deletes all related objects before destroy' do
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
require 'test_helper'
|
||||
|
||||
class TicketNullByteTest < ActiveSupport::TestCase
|
||||
test 'null byte test' do
|
||||
ticket1 = Ticket.create!(
|
||||
title: "some title \u0000 123",
|
||||
group: Group.lookup(name: 'Users'),
|
||||
customer_id: 2,
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
assert(ticket1, 'ticket created')
|
||||
|
||||
article1 = Ticket::Article.create!(
|
||||
ticket_id: ticket1.id,
|
||||
from: 'some_customer_com-1@example.com',
|
||||
to: 'some_zammad_com-1@example.com',
|
||||
subject: "com test 1\u0000",
|
||||
message_id: 'some@id_com_1',
|
||||
body: "some\u0000message 123",
|
||||
internal: false,
|
||||
sender: Ticket::Article::Sender.find_by(name: 'Customer'),
|
||||
type: Ticket::Article::Type.find_by(name: 'email'),
|
||||
updated_by_id: 1,
|
||||
created_by_id: 1,
|
||||
)
|
||||
assert(article1, 'ticket created')
|
||||
|
||||
ticket1.destroy!
|
||||
article1.destroy!
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue