diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-10-06 18:02:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-06 18:02:18 +0200 |
commit | 44fd66f0c6bff9cd94ba55345640c913cd733948 (patch) | |
tree | 7691a7119bd79f459828943d26f13a234618c755 /spec/models | |
parent | b31748a496ac55e3f2763d74ea7e7a7ef5c4dfad (diff) | |
parent | cef109e04661b1627acf9c98f6d00ea0629d41f4 (diff) |
Merge pull request #1616 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/media_attachment_spec.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/media_attachment_spec.rb b/spec/models/media_attachment_spec.rb index edab67d47..5dbb3d206 100644 --- a/spec/models/media_attachment_spec.rb +++ b/spec/models/media_attachment_spec.rb @@ -181,4 +181,32 @@ RSpec.describe MediaAttachment, type: :model do expect(media.description.size).to be <= 1_500 end end + + describe 'size limit validation' do + it 'rejects video files that are too large' do + stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes + stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte + expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) }.to raise_error(ActiveRecord::RecordInvalid) + end + + it 'accepts video files that are small enough' do + stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte + stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes + media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.webm')) + expect(media.valid?).to be true + end + + it 'rejects image files that are too large' do + stub_const 'MediaAttachment::IMAGE_LIMIT', 1.kilobyte + stub_const 'MediaAttachment::VIDEO_LIMIT', 100.megabytes + expect { MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) }.to raise_error(ActiveRecord::RecordInvalid) + end + + it 'accepts image files that are small enough' do + stub_const 'MediaAttachment::IMAGE_LIMIT', 100.megabytes + stub_const 'MediaAttachment::VIDEO_LIMIT', 1.kilobyte + media = MediaAttachment.create!(account: Fabricate(:account), file: attachment_fixture('attachment.jpg')) + expect(media.valid?).to be true + end + end end |