Optimize the way some large strings are created to speed up ticket_spec.rb.

This commit is contained in:
Martin Gruner 2021-05-06 13:32:21 +00:00
parent 7de5ec9037
commit 6f0d975c15

View file

@ -1856,7 +1856,7 @@ RSpec.describe Ticket, type: :model do
Store.add(
object: 'SomeObject',
o_id: 1,
data: (1024**800_000).to_s, # with 2.4 mb
data: 'a' * (1024**2 * 2.4), # with 2.4 mb
filename: 'test.TXT',
created_by_id: 1,
)
@ -1931,7 +1931,7 @@ RSpec.describe Ticket, type: :model do
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: (1024**800_000).to_s, # with 2.4 mb
data: 'a' * (1024**2 * 2.4), # with 2.4 mb
filename: 'some_file.pdf',
preferences: {
'Content-Type' => 'image/pdf',
@ -1941,14 +1941,14 @@ RSpec.describe Ticket, type: :model do
Store.add(
object: 'Ticket::Article',
o_id: article1.id,
data: (1024**2_000_000).to_s, # with 5,8 mb
data: 'a' * (1024**2 * 5.8), # with 5,8 mb
filename: 'some_file.txt',
preferences: {
'Content-Type' => 'text/plain',
},
created_by_id: 1,
)
create(:ticket_article, ticket: ticket, body: (1024**400_000).to_s.split(/(.{100})/).join(' ')) # body with 1,2 mb
create(:ticket_article, ticket: ticket, body: 'a' * (1024**2 * 1.2)) # body with 1,2 mb
create(:ticket_article, ticket: ticket)
ticket.search_index_attribute_lookup
end