Redmine 4.1.7

This commit is contained in:
Manuel Cillero 2023-07-07 08:08:27 +02:00
parent 55458d3479
commit 3ca3c37487
103 changed files with 2426 additions and 431 deletions

View file

@ -152,6 +152,19 @@ class AttachmentTest < ActiveSupport::TestCase
end
end
def test_extension_update_should_be_validated_against_denied_extensions
with_settings :attachment_extensions_denied => "txt, png" do
a = Attachment.new(:container => Issue.find(1),
:file => mock_file_with_options(:original_filename => "test.jpeg"),
:author => User.find(1))
assert_save a
b = Attachment.find(a.id)
b.filename = "test.png"
assert !b.save
end
end
def test_valid_extension_should_be_case_insensitive
with_settings :attachment_extensions_allowed => "txt, Png" do
assert Attachment.valid_extension?(".pnG")
@ -235,6 +248,23 @@ class AttachmentTest < ActiveSupport::TestCase
assert_not_equal a1.diskfile, a2.diskfile
end
def test_identical_attachments_created_in_same_transaction_should_not_end_up_unreadable
attachments = []
Project.transaction do
3.times do
a = Attachment.create!(
:container => Issue.find(1), :author => User.find(1),
:file => mock_file(:filename => 'foo', :content => 'abcde')
)
attachments << a
end
end
attachments.each do |a|
assert a.readable?
end
assert_equal 1, attachments.map(&:diskfile).uniq.size
end
def test_filename_should_be_basenamed
a = Attachment.new(:file => mock_file(:original_filename => "path/to/the/file"))
assert_equal 'file', a.filename