Change profile image max size to 8 MB (#20183)

* Change profile image max size to 8 MB

* Stub the const for the sake of the test
This commit is contained in:
Ben Halpern 2023-09-28 17:05:35 -04:00 committed by GitHub
parent 777afeeacb
commit c71b2b182f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View file

@ -1,5 +1,5 @@
class LogoUploader < BaseUploader
MAX_FILE_SIZE = 3.megabytes
MAX_FILE_SIZE = 8.megabytes
STORE_DIRECTORY = "uploads/logos/".freeze
EXTENSION_ALLOWLIST = %w[png jpg jpeg jpe].freeze
IMAGE_TYPE_ALLOWLIST = %i[png jpg jpeg jpe].freeze

View file

@ -1,10 +1,12 @@
class ProfileImageUploader < BaseUploader
MAX_FILE_SIZE = 8.megabytes
def filename
"#{secure_token}.#{file.extension}" if original_filename.present?
end
def size_range
1..(2.megabytes)
1..MAX_FILE_SIZE
end
protected

View file

@ -51,6 +51,7 @@ RSpec.describe Users::Update, type: :service do
end
it "returns an error if Profile image is too large" do
stub_const("ProfileImageUploader::MAX_FILE_SIZE", 2.megabytes)
profile_image = fixture_file_upload("large_profile_img.jpg", "image/jpeg")
service = described_class.call(user, profile: {}, user: { profile_image: profile_image })