-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Validation of SVG content type not working since update active_storage_validations to 1.3.1 #280
Labels
bug
Something isn't working
Comments
I'm having a similar problem, but with the docx content type. Here is a stand-alone test case that demonstrates the problem: # frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", "~> 7.0.0"
gem "sqlite3", "~> 1.4"
gem "rspec-rails", "~> 7.1"
gem "marcel", "~> 1.0.4"
gem "active_storage_validations", "1.3.1"
end
require "active_record/railtie"
require "active_storage/engine"
require "tmpdir"
require "rails/all"
require "rspec/rails"
require "active_storage_validations/matchers"
require "rspec/autorun"
class TestApp < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
config.root = __dir__
config.hosts << "example.org"
config.eager_load = false
config.session_store :cookie_store, key: "cookie_store_key"
config.secret_key_base = "secret_key_base"
config.logger = Logger.new($stdout)
Rails.logger = config.logger
config.active_storage.service = :local
config.active_storage.service_configurations = {
local: {
root: Dir.tmpdir,
service: "Disk"
}
}
end
ENV["DATABASE_URL"] = "sqlite3::memory:"
Rails.application.initialize!
require ActiveStorage::Engine.root.join("db/migrate/20170806125915_create_active_storage_tables.rb").to_s
ActiveRecord::Schema.define do
CreateActiveStorageTables.new.change
create_table :documents, force: true
end
class Document < ActiveRecord::Base
has_one_attached :file
validates :file, attached: true, content_type: [:docx, :pdf]
end
RSpec.configure do |config|
config.include ActiveStorageValidations::Matchers, type: :model
end
RSpec.describe Document, type: :model do
it "validates the correct mime types" do
document = Document.new
expect(document).to validate_content_type_of(:file)
.allowing("application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/pdf")
end
end Output:
|
Mth0158
added a commit
that referenced
this issue
Nov 11, 2024
Mth0158
added a commit
that referenced
this issue
Nov 11, 2024
…tent-type-not-working-since-update-active_storage_validations-to-131 [Matcher] Fix content_type extension generation issue (#280)
Hi everyone, |
Released with 1.3.2 :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello everyone,
I installed the latest version (1.3.1) of active_storage_validations to my Rails 7.0 project today. Since then I get the following errors in the specs:
In my model I configured it like:
Do any of you have a quick guess as to why this might be? I have already tried to change the content type to
:svg
, both in the specs and in the model. But apparently it has a problem with SVGs.The text was updated successfully, but these errors were encountered: