Reuploading an attachment with a different file name allowed in newer versions.
Author: rishijainCreated Mar 21, 2025Updated Mar 25, 2025
I am using carrierwave v2.2.6.
I have a test case like this:
test "should_not_change_filename" do
login_as :admin
image = images :one
post :update, params: {
id: image.to_param,
image: {
attachment: fixture_file_upload("abc.jpg", "image/jpeg")
}
}
assert_equal ["Attachment file name cannot change from 'one.jpg'"], assigns(:image).errors.full_messages
endThis breaks in gem version >= v3.0.0. In version 2.2.6, when I re upload a file with a different name than the file name that is already attached, it gives an error. But same flow uploads the new file with a different name in versions >= 3.0.0.
I could not find reference to this change in the releases or in any reported issues. Can you point me to it? Also, if I want to persist with old behaviour, is there a way to do it?
Source: carrierwaveuploader/carrierwave