From 575d6855ea13fa2fdc2543cdb200242326bb08bd Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 12 Nov 2018 14:11:32 +0800 Subject: [PATCH] DEV: Improve specs for `Validators::UploadValidator`. --- .../validators/upload_validator_spec.rb | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/components/validators/upload_validator_spec.rb b/spec/components/validators/upload_validator_spec.rb index f256e2f176e..28d899c66b9 100644 --- a/spec/components/validators/upload_validator_spec.rb +++ b/spec/components/validators/upload_validator_spec.rb @@ -29,5 +29,29 @@ describe Validators::UploadValidator do expect(UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)).to be_valid end + + describe 'when allow_staff_to_upload_any_file_in_pm is true' do + it 'should allow uploads for pm' do + upload = Fabricate.build(:upload, + user: Fabricate(:admin), + original_filename: 'test.ico', + for_private_message: true + ) + + expect(subject.validate(upload)).to eq(true) + end + + describe 'for a normal user' do + it 'should not allow uploads for pm' do + upload = Fabricate.build(:upload, + user: Fabricate(:user), + original_filename: 'test.ico', + for_private_message: true + ) + + expect(subject.validate(upload)).to eq(nil) + end + end + end end end