Skip to content

Reuploading an attachment with a different file name allowed in newer versions. #2782

Description

@rishijain

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
  end

This 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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions