Browse Source

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

Martin Gruner 3 years ago
parent
commit
6f0d975c15
1 changed files with 4 additions and 4 deletions
  1. 4 4
      spec/models/ticket_spec.rb

+ 4 - 4
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