From 6f0d975c155ad0fe4ec83c06cd918492b8cd93da Mon Sep 17 00:00:00 2001 From: Martin Gruner Date: Thu, 6 May 2021 13:32:21 +0000 Subject: [PATCH] Optimize the way some large strings are created to speed up ticket_spec.rb. --- spec/models/ticket_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/models/ticket_spec.rb b/spec/models/ticket_spec.rb index 85293379a..b6657722b 100644 --- a/spec/models/ticket_spec.rb +++ b/spec/models/ticket_spec.rb @@ -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