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:
parent
777afeeacb
commit
c71b2b182f
3 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue