mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: create upload record for exported csv files
This commit is contained in:
28
spec/components/validators/upload_validator_spec.rb
Normal file
28
spec/components/validators/upload_validator_spec.rb
Normal file
@ -0,0 +1,28 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Validators::UploadValidator do
|
||||
subject(:validator) { described_class.new }
|
||||
|
||||
describe 'validate' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:filename) { "discourse.csv" }
|
||||
let(:csv_file) { file_from_fixtures(filename, "csv") }
|
||||
|
||||
it "should create an invalid upload when the filename is blank" do
|
||||
SiteSetting.authorized_extensions = "*"
|
||||
created_upload = UploadCreator.new(csv_file, nil).create_for(user.id)
|
||||
validator.validate(created_upload)
|
||||
expect(created_upload).to_not be_valid
|
||||
expect(created_upload.errors.full_messages.first)
|
||||
.to include(I18n.t("activerecord.errors.messages.blank"))
|
||||
end
|
||||
|
||||
it "allows 'gz' as extension when uploading export file" do
|
||||
SiteSetting.authorized_extensions = ""
|
||||
|
||||
created_upload = UploadCreator.new(csv_file, "#{filename}.gz", for_export: true).create_for(user.id)
|
||||
expect(created_upload).to be_valid
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user