fix: Check for file url before validating remote file
This commit is contained in:
parent
a8f86abbd8
commit
2e577aa64e
2 changed files with 11 additions and 1 deletions
|
|
@ -262,7 +262,7 @@ class File(Document):
|
|||
def validate_remote_file(self):
|
||||
"""Validates if file uploaded using URL already exist"""
|
||||
site_url = get_url()
|
||||
if "/files/" in self.file_url and self.file_url.startswith(site_url):
|
||||
if self.file_url and "/files/" in self.file_url and self.file_url.startswith(site_url):
|
||||
self.file_url = self.file_url.split(site_url, 1)[1]
|
||||
|
||||
def set_folder_name(self):
|
||||
|
|
|
|||
|
|
@ -510,6 +510,16 @@ class TestFile(FrappeTestCase):
|
|||
).insert(ignore_permissions=True)
|
||||
self.assertRaisesRegex(ValidationError, "not a zip file", test_file.unzip)
|
||||
|
||||
def test_create_file_without_file_url(self):
|
||||
test_file = frappe.get_doc(
|
||||
{
|
||||
"doctype": "File",
|
||||
"file_name": "logo",
|
||||
"content": "frappe",
|
||||
}
|
||||
).insert()
|
||||
assert test_file is not None
|
||||
|
||||
|
||||
class TestAttachment(unittest.TestCase):
|
||||
test_doctype = "Test For Attachment"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue