spec/models/uploader_spec.rb in rad_kit-0.0.8 vs spec/models/uploader_spec.rb in rad_kit-0.0.9
- old
+ new
@@ -1,38 +1,28 @@
# encoding: utf-8
require 'spec_helper'
-describe "Uploading" do
- with_tmp_spec_dir
- with_mongoid
- with_files
+describe "Uploading" do
+ with_mongo_model
+ with_file_model
before :all do
- class TheImageUploader < Models::FileUploader
+ class TheFile < Models::BaseFile
end
-
+
class ThePost
- include Mongoid::Document
+ inherit Mongo::Model, Mongo::Model::FileModel
- field :name, type: String, default: ""
- validates_uniqueness_of :name
-
- mount_uploader :image, TheImageUploader
- end
- end
- after(:all){remove_constants :ThePost, :TheImageUploader}
+ mount_file :file, TheFile
+ end
+ end
+ after(:all){remove_constants :ThePost, :TheFile}
it "should preserve spaces and unicode characters in filename" do
File.open "#{spec_dir}/файл с пробелами.txt" do |f|
- ship = ThePost.new image: f
+ post = ThePost.create! file: 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/
+ post.file.url.should =~ /\/файл с пробелами\.txt/
+ post.file.file.path =~ /файл с пробелами\.txt/
end
end
end
\ No newline at end of file