# encoding: utf-8 require 'spec_helper' describe "Uploading" do with_tmp_spec_dir with_mongoid with_files before :all do class TheImageUploader < Models::FileUploader end class ThePost include Mongoid::Document field :name, type: String, default: "" validates_uniqueness_of :name mount_uploader :image, TheImageUploader end end after(:all){remove_constants :ThePost, :TheImageUploader} it "should preserve spaces and unicode characters in filename" do File.open "#{spec_dir}/файл с пробелами.txt" do |f| ship = ThePost.new image: f ship.image.url.should =~ /\/файл с пробелами\.txt/ ship.image.filename =~ /файл с пробелами\.txt/ ship.image.path =~ /\/файл с пробелами\.txt/ # ship.smart_url.should =~ /files\/file with spaces\/file with spaces\.txt\?\d/ # f.smart_url.should =~ /files\/data\/ship\?\d+/ # f.smart_url(:icon).should =~ /images\/mime\/dat_icon\.png/ # f.smart_url(:thumb).should =~ /images\/mime\/dat_thumb\.png/ end end end