From fe5a9cfcc17b0f8c7a0826f331b6fa1f4bb8e792 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 10 Jul 2020 16:54:04 +0200 Subject: [PATCH] Fixes #2107 - Too large article body fails imports. --- app/models/ticket/article.rb | 2 +- spec/models/ticket/article_spec.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index 1e057a4ef..16a4365c3 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -304,7 +304,7 @@ returns current_length = body.length return true if body.length <= limit - raise Exceptions::UnprocessableEntity, "body of article is too large, #{current_length} chars - only #{limit} allowed" if !ApplicationHandleInfo.postmaster? + raise Exceptions::UnprocessableEntity, "body of article is too large, #{current_length} chars - only #{limit} allowed" if !ApplicationHandleInfo.postmaster? && !Setting.get('import_mode') logger.warn "WARNING: cut string because of database length #{self.class}.body(#{limit} but is #{current_length})" self.body = body[0, limit] diff --git a/spec/models/ticket/article_spec.rb b/spec/models/ticket/article_spec.rb index 7a91fd291..7287e7efa 100644 --- a/spec/models/ticket/article_spec.rb +++ b/spec/models/ticket/article_spec.rb @@ -256,6 +256,16 @@ RSpec.describe Ticket::Article, type: :model do end end + context 'for import' do + before do + Setting.set('import_mode', true) + end + + it 'truncates body to 1.5 million chars' do + expect(article.body.length).to eq(1_500_000) + end + end + context 'for "test.postmaster" thread', application_handle: 'test.postmaster' do it 'truncates body to 1.5 million chars' do expect(article.body.length).to eq(1_500_000)