From 31a463c58714f0cd75de6f8ad5a1618bbc2b4f02 Mon Sep 17 00:00:00 2001 From: Alex Sherman Date: Thu, 18 Mar 2021 15:22:02 +0500 Subject: [PATCH] Move size constant to LegalDocument class --- app/controllers/epp/base_controller.rb | 4 +--- app/models/legal_document.rb | 1 + test/integration/epp/domain/create/base_test.rb | 6 ++---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/controllers/epp/base_controller.rb b/app/controllers/epp/base_controller.rb index ff711c490..205b7f844 100644 --- a/app/controllers/epp/base_controller.rb +++ b/app/controllers/epp/base_controller.rb @@ -23,8 +23,6 @@ module Epp rescue_from ActiveRecord::RecordNotFound, with: :respond_with_object_does_not_exist_error before_action :set_paper_trail_whodunnit - EIGHT_MEGABYTES = 8_388_608 - protected def respond_with_command_failed_error(exception) @@ -72,7 +70,7 @@ module Epp end def error_code(error) - error.str1.present? && error.str1.size > EIGHT_MEGABYTES ? 2306 : 2001 + error.str1.present? && error.str1.size > LegalDocument::MAX_BODY_SIZE ? 2306 : 2001 end def schema diff --git a/app/models/legal_document.rb b/app/models/legal_document.rb index 377a9fdde..24b965996 100644 --- a/app/models/legal_document.rb +++ b/app/models/legal_document.rb @@ -1,6 +1,7 @@ class LegalDocument < ApplicationRecord include EppErrors MIN_BODY_SIZE = (1.37 * 3.kilobytes).ceil + MAX_BODY_SIZE = 8.megabytes if ENV['legal_document_types'].present? TYPES = ENV['legal_document_types'].split(',').map(&:strip) diff --git a/test/integration/epp/domain/create/base_test.rb b/test/integration/epp/domain/create/base_test.rb index 777f01abc..5308de519 100644 --- a/test/integration/epp/domain/create/base_test.rb +++ b/test/integration/epp/domain/create/base_test.rb @@ -82,8 +82,7 @@ class EppDomainCreateBaseTest < EppTestCase contact = contacts(:john) registrant = contact.becomes(Registrant) - # 8388608 bytes == 8 mb - bignum_legaldoc = 't' * (8388608 + 1) + bignum_legaldoc = 't' * (LegalDocument::MAX_BODY_SIZE + 1) request_xml = <<-XML @@ -117,8 +116,7 @@ class EppDomainCreateBaseTest < EppTestCase contact = contacts(:john) registrant = contact.becomes(Registrant) - # 8388608 bytes == 8 mb - bignum_legaldoc = 't' * 8388608 + bignum_legaldoc = 't' * LegalDocument::MAX_BODY_SIZE request_xml = <<-XML