Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validate_content_type_of failing since 1.3.1 #292

Closed
modosc opened this issue Nov 12, 2024 · 4 comments
Closed

validate_content_type_of failing since 1.3.1 #292

modosc opened this issue Nov 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@modosc
Copy link

modosc commented Nov 12, 2024

this seems like a duplicate of #280 except it's still not working with 1.3.3.

in our model:

  # BEGIN validations
  validates :file,
    presence: true,
    content_type: [
      "image/jpeg",
      "image/jpg",
      "image/png",
      "image/webp",
      "application/pdf",
    ],
    size: { less_than: 10.megabytes }

in our spec:

    it {
      expect(subject).to validate_content_type_of(:file).allowing(
        "image/jpeg",
        "image/jpg",
        "image/png",
        "image/webp",
        "application/pdf",
      )
    }

the error:

  1) FileAttachment validations is expected to validate the content types allowed on :file
     Failure/Error: 
       expect(subject).to validate_content_type_of(:file).allowing(
         "image/jpeg",
         "image/jpg",
         "image/png",
         "image/webp",
         "application/pdf",
       )

       is expected to validate the content types of :file
         the following content types should be allowed: :image/jpeg, :image/jpg, :image/png, :image/webp, :application/pdf
         but :image/jpg was rejected
@kapso
Copy link

kapso commented Nov 12, 2024

yea same issue

@nuxy
Copy link

nuxy commented Nov 12, 2024

Same issue here. See comment related to REGEX use in #282

@Mth0158 Mth0158 added the bug Something isn't working label Nov 13, 2024
@Mth0158 Mth0158 self-assigned this Nov 13, 2024
@Mth0158 Mth0158 linked a pull request Nov 14, 2024 that will close this issue
Mth0158 added a commit that referenced this issue Nov 14, 2024
…ot-working-since-131

[Validator] Remove extension check on content_type validator (#282/#291/#292/#293)
@Mth0158
Copy link
Collaborator

Mth0158 commented Nov 14, 2024

Incoming bugfix release in the next hours/tomorrow to definitely fix this issue => we do not perform the extension vs content_type that causes this mess. Sorry for the unexpected breaking changes, it should have been tested more.

Let us know if you have any features idea to enhance the gem by the way :)

@Mth0158
Copy link
Collaborator

Mth0158 commented Nov 14, 2024

The fix has been released, upgrade to 1.3.4 to fix the issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants