test/unit/test_roachclip.rb in roachclip-0.1.3 vs test/unit/test_roachclip.rb in roachclip-0.2.0
- old
+ new
@@ -70,15 +70,38 @@
assert d.respond_to?(:image_thumb=)
assert d.respond_to?(:image_large)
assert d.respond_to?(:image_large=)
end
+ context "with a custom path" do
+ setup do
+ Doc.roachclip :image, :path => "/gridfs/assets/%s"
+ @doc = Doc.new
+ @doc.image = File.open(test_file_path)
+
+ assert @doc.save
+ end
+
+ should "have image_path with custom path" do
+ i = @doc.image.id.to_s
+ assert_equal "/gridfs/assets/#{i}", @doc.image_path
+ end
+ end
+
context "with a saved document w/ image" do
setup do
@doc = Doc.new
@doc.image = File.open(test_file_path)
assert @doc.save
+ end
+
+ should "have image_path default to fs collection" do
+ t = Time.now
+ Time.stubs(:now).returns t
+
+ i = @doc.image.id.to_s
+ assert_equal "/gridfs/fs/#{i}-#{t.to_i}", @doc.image_path
end
should "still save documents w/ images" do
d = Doc.find @doc.id