spec/utils_spec.rb in cloudinary-1.0.26 vs spec/utils_spec.rb in cloudinary-1.0.27
- old
+ new
@@ -6,10 +6,11 @@
Cloudinary.config do
|config|
config.cloud_name = "test123"
config.secure_distribution = nil
config.private_cdn = false
+ config.secure = false
end
end
it "should use cloud_name from config" do
result = Cloudinary::Utils.cloudinary_url("test")
@@ -190,17 +191,10 @@
result = Cloudinary::Utils.cloudinary_url("test", options)
options.should == {}
result.should == "http://res.cloudinary.com/test123/image/upload/a_55/test"
end
- it "should support overlay" do
- options = {:overlay=>"text:hello"}
- result = Cloudinary::Utils.cloudinary_url("test", options)
- options.should == {}
- result.should == "http://res.cloudinary.com/test123/image/upload/l_text:hello/test"
- end
-
it "should support format for fetch urls" do
options = {:format=>"jpg", :type=>:fetch}
result = Cloudinary::Utils.cloudinary_url("http://cloudinary.com/images/logo.png", options)
options.should == {}
result.should == "http://res.cloudinary.com/test123/image/fetch/f_jpg/http://cloudinary.com/images/logo.png"
@@ -225,13 +219,44 @@
result = Cloudinary::Utils.cloudinary_url("test", options)
options.should == {}
result.should == "http://res.cloudinary.com/test123/image/upload/e_sepia:10/test"
end
- it "should not pass width/height to html for overlay" do
- options = {:overlay=>"text:hello", :height=>100, :width=>100}
+ {:overlay=>:l, :underlay=>:u}.each do |param, letter|
+ it "should support #{param}" do
+ options = {param=>"text:hello"}
+ result = Cloudinary::Utils.cloudinary_url("test", options)
+ options.should == {}
+ result.should == "http://res.cloudinary.com/test123/image/upload/#{letter}_text:hello/test"
+ end
+
+ it "should not pass width/height to html for #{param}" do
+ options = {param=>"text:hello", :height=>100, :width=>100}
+ result = Cloudinary::Utils.cloudinary_url("test", options)
+ options.should == {}
+ result.should == "http://res.cloudinary.com/test123/image/upload/h_100,#{letter}_text:hello,w_100/test"
+ end
+ end
+
+ it "should use ssl_detected if secure is not given as parameter and not set to true in configuration" do
+ options = {:ssl_detected=>true}
result = Cloudinary::Utils.cloudinary_url("test", options)
options.should == {}
- result.should == "http://res.cloudinary.com/test123/image/upload/h_100,l_text:hello,w_100/test"
- end
-
+ result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
+ end
+
+ it "should use secure if given over ssl_detected and configuration" do
+ options = {:ssl_detected=>true, :secure=>false}
+ Cloudinary.config.secure = true
+ result = Cloudinary::Utils.cloudinary_url("test", options)
+ options.should == {}
+ result.should == "http://res.cloudinary.com/test123/image/upload/test"
+ end
+
+ it "should use secure: true from configuration over ssl_detected" do
+ options = {:ssl_detected=>false}
+ Cloudinary.config.secure = true
+ result = Cloudinary::Utils.cloudinary_url("test", options)
+ options.should == {}
+ result.should == "https://d3jpl91pxevbkh.cloudfront.net/test123/image/upload/test"
+ end
end