spec/utils_spec.rb in cloudinary-1.0.66 vs spec/utils_spec.rb in cloudinary-1.0.67
- old
+ new
@@ -10,11 +10,11 @@
config.private_cdn = false
config.secure = false
config.cname = nil
config.cdn_subdomain = false
config.api_key = "1234"
- config.api_secret = "1234"
+ config.api_secret = "b"
end
end
it "should use cloud_name from config" do
result = Cloudinary::Utils.cloudinary_url("test")
@@ -436,7 +436,28 @@
["a??b", "a%3F%3Fb"]
].each do
|source, target|
Cloudinary::Utils.cloudinary_url(source).should == "http://res.cloudinary.com/test123/image/upload/#{target}"
end
+ end
+
+ it "should correctly sign URLs", :signed => true do
+ options = {version: 1234, transformation: {crop: "crop", width: 10, height: 20}, sign_url: true}
+ expected = "http://res.cloudinary.com/test123/image/upload/s--MaRXzoEC--/c_crop,h_20,w_10/v1234/image.jpg"
+ actual = Cloudinary::Utils.cloudinary_url("image.jpg", options)
+ actual.should == expected
+
+ options = {version: 1234, sign_url: true}
+ expected = "http://res.cloudinary.com/test123/image/upload/s--ZlgFLQcO--/v1234/image.jpg"
+ actual = Cloudinary::Utils.cloudinary_url("image.jpg", options)
+ actual.should == expected
+
+ options = {transformation: {crop: "crop", width: 10, height: 20}, sign_url: true}
+ expected = "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg"
+ actual = Cloudinary::Utils.cloudinary_url("image.jpg", options)
+ actual.should == expected
+
+ expected = "http://res.cloudinary.com/test123/image/fetch/s--_GAUclyB--/v1234/http://google.com/path/to/image.png"
+ actual = Cloudinary::Utils.cloudinary_url("http://google.com/path/to/image.png", type: "fetch", version: 1234, sign_url: true)
+ actual.should == expected
end
end