class EtFakeCcd::Command::UploadDocumentCommand
Constants
- VALID_FILE_CONTENT_TYPES
- VALID_FILE_EXTENSIONS
Public Class Methods
from_json(json)
click to toggle source
# File lib/et_fake_ccd/command/upload_document_command.rb, line 12 def self.from_json(json) new data: json end
Private Instance Methods
validate_data()
click to toggle source
# File lib/et_fake_ccd/command/upload_document_command.rb, line 20 def validate_data validate_file end
validate_file()
click to toggle source
# File lib/et_fake_ccd/command/upload_document_command.rb, line 24 def validate_file return if validate_file_extension && validate_file_content_type errors.add :data, "Your upload contains a disallowed file type", field_error: { "id": "files", "message": "Your upload contains a disallowed file type" } end
validate_file_content_type()
click to toggle source
# File lib/et_fake_ccd/command/upload_document_command.rb, line 30 def validate_file_content_type VALID_FILE_CONTENT_TYPES.include?(data.dig('files', 'type')) end
validate_file_extension()
click to toggle source
# File lib/et_fake_ccd/command/upload_document_command.rb, line 34 def validate_file_extension VALID_FILE_EXTENSIONS.include?(File.extname(data.dig('files', 'filename'))) end