cloudinary 1.0.82 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +58 -7
  3. data/CHANGELOG +13 -0
  4. data/Gemfile +1 -1
  5. data/cloudinary.gemspec +13 -3
  6. data/lib/cloudinary/active_support/core_ext/hash/keys.rb +166 -0
  7. data/lib/cloudinary/active_support/core_ext/hash/readme.md +1 -0
  8. data/lib/cloudinary/api.rb +2 -1
  9. data/lib/cloudinary/carrier_wave/preloaded.rb +1 -1
  10. data/lib/cloudinary/helper.rb +38 -21
  11. data/lib/cloudinary/missing.rb +11 -10
  12. data/lib/cloudinary/uploader.rb +18 -20
  13. data/lib/cloudinary/utils.rb +187 -75
  14. data/lib/cloudinary/version.rb +1 -1
  15. data/lib/cloudinary/video_helper.rb +126 -0
  16. data/spec/api_spec.rb +23 -22
  17. data/spec/cloudinary_helper_spec.rb +34 -20
  18. data/spec/spec_helper.rb +75 -5
  19. data/spec/uploader_spec.rb +32 -3
  20. data/spec/utils_methods_spec.rb +18 -0
  21. data/spec/utils_spec.rb +73 -78
  22. data/spec/video_tag_spec.rb +186 -0
  23. data/spec/video_url_spec.rb +169 -0
  24. data/vendor/assets/html/cloudinary_cors.html +47 -0
  25. data/vendor/assets/javascripts/cloudinary/canvas-to-blob.min.js +1 -0
  26. data/vendor/assets/javascripts/cloudinary/index.js +4 -0
  27. data/vendor/assets/javascripts/cloudinary/jquery.cloudinary.js +898 -0
  28. data/vendor/assets/javascripts/cloudinary/jquery.fileupload-image.js +315 -0
  29. data/vendor/assets/javascripts/cloudinary/jquery.fileupload-process.js +172 -0
  30. data/vendor/assets/javascripts/cloudinary/jquery.fileupload-validate.js +119 -0
  31. data/vendor/assets/javascripts/cloudinary/jquery.fileupload.js +1460 -0
  32. data/vendor/assets/javascripts/cloudinary/jquery.iframe-transport.js +214 -0
  33. data/vendor/assets/javascripts/cloudinary/jquery.ui.widget.js +558 -0
  34. data/vendor/assets/javascripts/cloudinary/load-image.min.js +1 -0
  35. data/vendor/assets/javascripts/cloudinary/processing.js +5 -0
  36. metadata +44 -7
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.82"
3
+ VERSION = "1.0.83"
4
4
  end
@@ -0,0 +1,126 @@
1
+ if !Hash.respond_to?(:deep_symbolize_keys)
2
+ require 'cloudinary/active_support/core_ext/hash/keys'
3
+ end
4
+ module CloudinaryHelper
5
+ include ActionView::Context
6
+ DEFAULT_POSTER_OPTIONS = { :format => 'jpg', :resource_type => 'video' }
7
+ DEFAULT_SOURCE_TYPES = %w(webm mp4 ogv)
8
+ DEFAULT_VIDEO_OPTIONS = { :resource_type => 'video' }
9
+
10
+ # Creates an HTML video tag for the provided +source+
11
+ #
12
+ # ==== Options
13
+ # * <tt>:source_types</tt> - Specify which source type the tag should include. defaults to webm, mp4 and ogv.
14
+ # * <tt>:source_transformation</tt> - specific transformations to use for a specific source type.
15
+ # * <tt>:poster</tt> - override default thumbnail:
16
+ # * url: provide an ad hoc url
17
+ # * options: with specific poster transformations and/or Cloudinary +:public_id+
18
+ #
19
+ # ==== Examples
20
+ # cl_video_tag("mymovie.mp4")
21
+ # cl_video_tag("mymovie.mp4", :source_types => :webm)
22
+ # cl_video_tag("mymovie.ogv", :poster => "myspecialplaceholder.jpg")
23
+ # cl_video_tag("mymovie.webm", :source_types => [:webm, :mp4], :poster => {:effect => 'sepia'}) do
24
+ # content_tag( :span, "Cannot present video!")
25
+ # end
26
+ def cl_video_tag(source, options = {}, &block)
27
+ source = strip_known_ext(source)
28
+ video_attributes = [:autoplay,:controls,:loop,:muted,:poster, :preload]
29
+ options = Hash[options].deep_symbolize_keys
30
+
31
+ options[:source_types] ||= DEFAULT_SOURCE_TYPES
32
+ video_attributes.keep_if{ |key, _| options.has_key?(key)} # required prior to Rails 4.x
33
+ video_options = options.extract!(*video_attributes)
34
+ if video_options.has_key? :poster
35
+ poster = video_options.delete(:poster)
36
+ case poster
37
+ when String
38
+ video_options[:poster] = poster
39
+ when Hash
40
+ if poster.has_key? :public_id
41
+ poster[:resource_type] = "image"
42
+ poster_name = poster[:public_id]
43
+ video_options[:poster] = cl_image_path(poster_name, poster)
44
+ else
45
+ video_options[:poster] = cl_video_thumbnail_path(source, poster)
46
+ end
47
+ else
48
+ # no poster
49
+ end
50
+ else
51
+ video_options[:poster] = cl_video_thumbnail_path(source, options)
52
+ end
53
+
54
+ source_transformation = options.delete(:source_transformation) || {}
55
+ source_types = Array(options.delete(:source_types))
56
+ fallback = (capture(&block) if block_given?) || options.delete(:fallback_content)
57
+
58
+ if source_types.size > 1
59
+ cloudinary_tag(source, options) do |_, tag_options|
60
+ content_tag('video', tag_options.merge(video_options)) do
61
+ source_tags = source_types.map do |type|
62
+ transformation = source_transformation[type.to_sym] || {}
63
+ cloudinary_tag("#{source}.#{type}", tag_options.merge(transformation)) do |url, _|
64
+ mime_type = "video/#{(type == 'ogv' ? 'ogg' : type)}"
65
+ tag("source", :src => url, :type => mime_type)
66
+ end
67
+ end
68
+ source_tags.push(fallback.html_safe) unless fallback.blank?
69
+ safe_join(source_tags)
70
+ end
71
+ end
72
+ else
73
+ transformation = source_transformation[source_types.first.to_sym] || {}
74
+ video_options[:src] = cl_video_path("#{source}.#{source_types.first.to_sym}", transformation.merge(options))
75
+ cloudinary_tag(source, options) do |url, tag_options|
76
+ content_tag('video', fallback, tag_options.merge(video_options))
77
+ end
78
+ end
79
+ end
80
+
81
+ # Returns a url for the given source with +options+
82
+ def cl_video_path(source, options={})
83
+ cl_image_path(source, DEFAULT_VIDEO_OPTIONS.merge(options))
84
+ end
85
+
86
+ # Returns an HTML <tt>img</tt> tag with the thumbnail for the given video +source+ and +options+
87
+ def cl_video_thumbnail_tag(source, options={})
88
+ cl_image_tag(source, DEFAULT_POSTER_OPTIONS.merge(options))
89
+ end
90
+
91
+ # Returns a url for the thumbnail for the given video +source+ and +options+
92
+ def cl_video_thumbnail_path(source, options={})
93
+ cl_image_path(source, DEFAULT_POSTER_OPTIONS.merge(options))
94
+ end
95
+
96
+ protected
97
+
98
+ def strip_known_ext(name)
99
+ name.sub(/\.(#{DEFAULT_SOURCE_TYPES.join("|")})$/, '')
100
+ end
101
+
102
+ def safe_join(array, sep=$,)
103
+ sep = ERB::Util.unwrapped_html_escape(sep)
104
+ array.flatten.map! { |i| ERB::Util.unwrapped_html_escape(i) }.join(sep).html_safe
105
+ end unless method_defined?( :safe_join)
106
+
107
+ # HTML escapes strings but doesn't wrap them with an ActiveSupport::SafeBuffer.
108
+ # This method is not for public consumption! Seriously!
109
+ def unwrapped_html_escape(s) # :nodoc:
110
+ s = s.to_s
111
+ if s.html_safe?
112
+ s
113
+ else
114
+ s.gsub(HTML_ESCAPE_REGEXP, HTML_ESCAPE)
115
+ end
116
+ end unless method_defined?( :unwrapped_html_escape)
117
+
118
+ HTML_ESCAPE = { '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', '"' => '&quot;', "'" => '&#39;' } unless defined?( HTML_ESCAPE)
119
+ HTML_ESCAPE_REGEXP = /[&"'><]/ unless defined?(HTML_ESCAPE_REGEXP)
120
+
121
+ end
122
+
123
+
124
+
125
+
126
+
data/spec/api_spec.rb CHANGED
@@ -173,32 +173,33 @@ describe Cloudinary::Api do
173
173
  expect(transformation).not_to be_blank
174
174
  expect(transformation["allowed_for_strict"]).to eq(false)
175
175
  end
176
+ describe "named transformations" do
177
+ it "should allow creating named transformation" do
178
+ @api.create_transformation("api_test_transformation", "crop"=>"scale", "width"=>102)
179
+ transformation = @api.transformation("api_test_transformation")
180
+ expect(transformation).not_to be_blank
181
+ expect(transformation["allowed_for_strict"]).to eq(true)
182
+ expect(transformation["info"]).to eq(["crop"=>"scale", "width"=>102])
183
+ expect(transformation["used"]).to eq(false)
184
+ end
176
185
 
177
- it "should allow creating named transformation" do
178
- @api.create_transformation("api_test_transformation", "crop"=>"scale", "width"=>102)
179
- transformation = @api.transformation("api_test_transformation")
180
- expect(transformation).not_to be_blank
181
- expect(transformation["allowed_for_strict"]).to eq(true)
182
- expect(transformation["info"]).to eq(["crop"=>"scale", "width"=>102])
183
- expect(transformation["used"]).to eq(false)
184
- end
186
+ it "should allow deleting named transformation" do
187
+ @api.create_transformation("api_test_transformation2", "crop"=>"scale", "width"=>103)
188
+ @api.transformation("api_test_transformation2")
189
+ @api.delete_transformation("api_test_transformation2")
190
+ expect{@api.transformation("api_test_transformation2")}.to raise_error(Cloudinary::Api::NotFound)
191
+ end
185
192
 
186
- it "should allow deleting named transformation" do
187
- @api.create_transformation("api_test_transformation2", "crop"=>"scale", "width"=>103)
188
- @api.transformation("api_test_transformation2")
189
- @api.delete_transformation("api_test_transformation2")
190
- expect{@api.transformation("api_test_transformation2")}.to raise_error(Cloudinary::Api::NotFound)
191
- end
193
+ it "should allow unsafe update of named transformation" do
194
+ @api.create_transformation("api_test_transformation3", "crop"=>"scale", "width"=>102)
195
+ @api.update_transformation("api_test_transformation3", :unsafe_update=>{"crop"=>"scale", "width"=>103})
196
+ transformation = @api.transformation("api_test_transformation3")
197
+ expect(transformation).not_to be_blank
198
+ expect(transformation["info"]).to eq(["crop"=>"scale", "width"=>103])
199
+ expect(transformation["used"]).to eq(false)
200
+ end
192
201
 
193
- it "should allow unsafe update of named transformation" do
194
- @api.create_transformation("api_test_transformation3", "crop"=>"scale", "width"=>102)
195
- @api.update_transformation("api_test_transformation3", :unsafe_update=>{"crop"=>"scale", "width"=>103})
196
- transformation = @api.transformation("api_test_transformation3")
197
- expect(transformation).not_to be_blank
198
- expect(transformation["info"]).to eq(["crop"=>"scale", "width"=>103])
199
- expect(transformation["used"]).to eq(false)
200
202
  end
201
-
202
203
  it "should allow deleting implicit transformation" do
203
204
  @api.transformation("c_scale,w_100")
204
205
  @api.delete_transformation("c_scale,w_100")
@@ -10,12 +10,28 @@ end
10
10
 
11
11
  RSpec.describe CloudinaryHelper do
12
12
  let(:helper) { helper_class.new }
13
-
14
-
13
+ let(:options) { {} }
15
14
  context "#cl_image_upload_tag" do
16
- let(:options) { {} }
17
- subject(:input) { helper.cl_image_upload_tag(:image_id, options) }
15
+ let(:options) {{:multiple => true}}
16
+ before do
17
+ if defined? allow
18
+ allow(Cloudinary::Utils).to receive_messages :cloudinary_api_url => '', :sign_request => Hash.new
19
+ allow(helper).to receive(:build_callback_url).and_return('')
20
+ else
21
+ Cloudinary::Utils.should_receive(:cloudinary_api_url).and_return('')
22
+ Cloudinary::Utils.should_receive(:sign_request).and_return(Hash.new)
23
+ helper.should_receive(:build_callback_url).and_return('')
24
+ end
25
+ end
26
+ let(:test_tag) { TestTag.new( helper.cl_image_upload_tag('image_id', options)) }
18
27
 
28
+ it "allow multiple upload" do
29
+ expect(test_tag['data-cloudinary-field']).to eq('image_id[]')
30
+ expect(test_tag['multiple']).to eq('multiple')
31
+ end
32
+ end
33
+ context "#cl_upload_tag" do
34
+ let(:options) {{:multiple => true}}
19
35
  before do
20
36
  if defined? allow
21
37
  allow(Cloudinary::Utils).to receive_messages :cloudinary_api_url => '', :sign_request => Hash.new
@@ -26,34 +42,32 @@ RSpec.describe CloudinaryHelper do
26
42
  helper.should_receive(:build_callback_url).and_return('')
27
43
  end
28
44
  end
45
+ let(:test_tag) { TestTag.new( helper.cl_upload_tag('image_id', options)) }
29
46
 
30
47
  it "allow multiple upload" do
31
- options[:multiple] = true
32
- expect(input).to include('data-cloudinary-field="image_id[]"')
33
- expect(input).to include('multiple="multiple"')
48
+ expect(test_tag['data-cloudinary-field']).to eq('image_id[]')
49
+ expect(test_tag['multiple']).to eq('multiple')
34
50
  end
35
51
  end
36
52
 
37
53
  context "#cl_image_tag" do
38
- subject(:input) { helper.cl_image_tag('sample.jpg', options) }
54
+ let(:test_tag) { TestTag.new( helper.cl_image_tag('sample.jpg', options)) }
39
55
 
40
- context "responsive_width" do
41
- let(:options) { {responsive_width: true, cloud_name: "test"} }
56
+ context ":responsive_width" do
57
+ let(:options) { {:responsive_width => true, :cloud_name => "test"} }
42
58
  it "should use data-src for responsive_width" do
43
- img_tag = html_tag_matcher 'img'
44
- expect(input).to match img_tag
45
- expect(input).to include('class="cld-responsive"')
46
- expect(input).to include( 'data-src="http://res.cloudinary.com/test/image/upload/c_limit,w_auto/sample.jpg"')
59
+ expect(test_tag.name).to match( 'img')
60
+ expect(test_tag['class']).to eq("cld-responsive")
61
+ expect(test_tag['data-src']).to eq( "http://res.cloudinary.com/test/image/upload/c_limit,w_auto/sample.jpg")
47
62
  end
48
63
  end
49
64
 
50
- context "dpr_auto" do
51
- let(:options) { {dpr: :auto, cloud_name: "test"} }
65
+ context ":dpr_auto" do
66
+ let(:options) { {:dpr => :auto, :cloud_name => "test"} }
52
67
  it "should use data-src for dpr auto" do
53
- img_tag = html_tag_matcher 'img'
54
- expect(input).to match(img_tag)
55
- expect(input).to include('data-src="http://res.cloudinary.com/test/image/upload/dpr_auto/sample.jpg"')
56
- expect(input).to include('class="cld-hidpi"')
68
+ expect(test_tag.name).to match( 'img')
69
+ expect(test_tag['class']).to eq( 'cld-hidpi')
70
+ expect(test_tag['data-src']).to eq( "http://res.cloudinary.com/test/image/upload/dpr_auto/sample.jpg")
57
71
  end
58
72
  end
59
73
  end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,83 @@
1
+ require 'rspec'
2
+ require 'rexml/parsers/ultralightparser'
3
+ require 'rspec/version'
4
+
1
5
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
2
6
  RSpec.configure do |config|
3
- config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ unless RSpec::Version::STRING.match( /^3/)
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ end
4
10
  config.run_all_when_everything_filtered = true
5
11
  config.filter_run_excluding :delete_all => true
6
12
  end
7
13
 
8
- # Create a regexp with the given tag name.
9
- # @param [String or Symbol] tag tag name (e.g. `img`)
10
- # @return [Regexp] the regular expression to match the tag
14
+ # Create a regexp with the given +tag+ name.
11
15
  def html_tag_matcher( tag)
12
- /<#{tag}([\s]+[-[:word:]]+[\s]*\=\s*\"[^\"]*\")*\s*>.*<\s*\/#{tag}\s*>/
16
+ /<#{tag}([\s]+([-[:word:]]+)[\s]*\=\s*\"([^\"]*)\")*\s*>.*<\s*\/#{tag}\s*>/
13
17
  end
18
+
19
+ # Represents an HTML tag
20
+ class TestTag
21
+ attr_accessor :name, :attributes, :children, :text, :html_string
22
+ # Creates a new +TestTag+ from a given +element+ string
23
+ def initialize(element)
24
+ @html_string = element
25
+ element = valid_tag(element) unless element.is_a? Array
26
+ case element[0]
27
+ when :start_element
28
+ @name = element[2]
29
+ @attributes = element[3]
30
+ @children = (Array(element[4..-1]) || []).map {|c | TestTag.new c}
31
+ when :text
32
+ @text = element[1]
33
+ @name = "text"
34
+ @attributes = []
35
+ @children = []
36
+ end
37
+
38
+ end
39
+
40
+ # Parses a given +tag+ in string format
41
+ def valid_tag(tag)
42
+ parser = REXML::Parsers::UltraLightParser.new( tag)
43
+ parser.parse[0]
44
+ end
45
+
46
+ # Returns attribute named +symbol_or_string+
47
+ def [](symbol_or_string)
48
+ attributes[symbol_or_string.to_s]
49
+ end
50
+
51
+ def method_missing(symbol, *args)
52
+ if (m = /children_by_(\w+)/.match(symbol.to_s)) and !args.empty?
53
+ @children.select{ |c| c[m[1]] == args[0]}
54
+ else
55
+ super
56
+ end
57
+ end
58
+
59
+ def ==(other)
60
+ case other
61
+ when String
62
+ @text == other
63
+ else
64
+ other.respond_to?( :text) &&
65
+ other.respond_to?( :name) &&
66
+ other.respond_to?( :attributes) &&
67
+ other.respond_to?( :children) &&
68
+ @text == other.text &&
69
+ @name == other.name &&
70
+ @attributes == other.attributes &&
71
+ @children == other.children
72
+ end
73
+ end
74
+ end
75
+
76
+ def test_cloudinary_url(public_id, options, expected_url, expected_options)
77
+ url = Cloudinary::Utils.cloudinary_url(public_id, options)
78
+ expect(url).to eq(expected_url)
79
+ expect(options).to eq(expected_options)
80
+ url
81
+ end
82
+
83
+ TEST_IMAGE_URL = "http://cloudinary.com/images/old_logo.png"
@@ -1,6 +1,10 @@
1
1
  require 'spec_helper'
2
2
  require 'cloudinary'
3
3
 
4
+ RSpec.configure do |c|
5
+ c.filter_run_excluding :large => true
6
+ end
7
+
4
8
  describe Cloudinary::Uploader do
5
9
  break puts("Please setup environment for api test to run") if Cloudinary.config.api_secret.blank?
6
10
 
@@ -130,9 +134,20 @@ describe Cloudinary::Uploader do
130
134
  expect{Cloudinary::Uploader.upload("spec/logo.png", {:auto_tagging => 0.5})}.to raise_error(CloudinaryException, /Must use/)
131
135
  end
132
136
 
133
- it "should support upload_large" do
134
- result = Cloudinary::Uploader.upload_large("spec/logo.png")
135
- expect(result["public_id"]).to match(/^[a-z0-9]+.png$/)
137
+ it "should support upload_large", :large => true do
138
+ io = StringIO.new
139
+ header = "BMJ\xB9Y\x00\x00\x00\x00\x00\x8A\x00\x00\x00|\x00\x00\x00x\x05\x00\x00x\x05\x00\x00\x01\x00\x18\x00\x00\x00\x00\x00\xC0\xB8Y\x00a\x0F\x00\x00a\x0F\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00\x00\xFF\x00\x00\xFF\x00\x00\x00\x00\x00\x00\xFFBGRs\x00\x00\x00\x00\x00\x00\x00\x00T\xB8\x1E\xFC\x00\x00\x00\x00\x00\x00\x00\x00fff\xFC\x00\x00\x00\x00\x00\x00\x00\x00\xC4\xF5(\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
140
+ io.puts(header)
141
+ 5880000.times{ io.write("\xFF") }
142
+ io.rewind
143
+ result = Cloudinary::Uploader.upload_large(io, :chunk_size => 5243000)
144
+ expect(result["resource_type"]).to eq('raw')
145
+ io.rewind
146
+ result = Cloudinary::Uploader.upload_large(io, :resource_type => 'image', :chunk_size => 5243000)
147
+ expect(result["resource_type"]).to eq('image')
148
+ expect(result["width"]).to eq(1400)
149
+ expect(result["height"]).to eq(1400)
150
+ expect(result["format"]).to eq("bmp")
136
151
  end
137
152
 
138
153
  context "unsigned" do
@@ -154,4 +169,18 @@ describe Cloudinary::Uploader do
154
169
  Cloudinary::Api.delete_upload_preset(preset["name"])
155
170
  end
156
171
  end
172
+
173
+ describe ":timeout" do
174
+ before do
175
+ @timeout = Cloudinary.config.timeout
176
+ Cloudinary.config.timeout = 0.01
177
+ end
178
+ after do
179
+ Cloudinary.config.timeout = @timeout
180
+ end
181
+
182
+ it "should fail if timeout is reached" do
183
+ expect{Cloudinary::Uploader.upload(Pathname.new("spec/logo.png"))}.to raise_error
184
+ end
185
+ end
157
186
  end
@@ -0,0 +1,18 @@
1
+ require 'rspec'
2
+ require 'spec_helper'
3
+ require 'cloudinary'
4
+
5
+ include Cloudinary
6
+
7
+ describe Utils do
8
+
9
+ it 'should parse integer range values' do
10
+ expect(Utils.norm_range_value("200")).to eq( "200")
11
+ end
12
+ it "should parse float range values" do
13
+ expect(Utils.norm_range_value("200.0")).to eq("200.0"), "parse a float"
14
+ end
15
+ it "should parse a percent range value" do
16
+ expect(Utils.norm_range_value("20p")).to eq("20p")
17
+ end
18
+ end
data/spec/utils_spec.rb CHANGED
@@ -3,8 +3,7 @@ require 'cloudinary'
3
3
 
4
4
  describe Cloudinary::Utils do
5
5
  before(:each) do
6
- Cloudinary.config do
7
- |config|
6
+ Cloudinary.config do |config|
8
7
  config.cloud_name = "test123"
9
8
  config.secure_distribution = nil
10
9
  config.private_cdn = false
@@ -15,16 +14,11 @@ describe Cloudinary::Utils do
15
14
  config.api_secret = "b"
16
15
  end
17
16
  end
18
-
19
- def test_cloudinary_url(public_id, options, expected_url, expected_options)
20
- url = Cloudinary::Utils.cloudinary_url(public_id, options)
21
- expect(url).to eq(expected_url)
22
- expect(options).to eq(expected_options)
23
- url
24
- end
17
+ let(:root_path) { "http://res.cloudinary.com/test123" }
18
+ let(:upload_path) { "#{root_path}/image/upload" }
25
19
 
26
- it "should use cloud_name from config" do
27
- test_cloudinary_url("test", {}, "http://res.cloudinary.com/test123/image/upload/test", {})
20
+ it "should use cloud_name from config" do
21
+ test_cloudinary_url("test", {}, "#{upload_path}/test", {})
28
22
  end
29
23
 
30
24
  it "should allow overriding cloud_name in options" do
@@ -58,7 +52,7 @@ describe Cloudinary::Utils do
58
52
 
59
53
  it "should allow overriding private_cdn if private_cdn=false" do
60
54
  Cloudinary.config.private_cdn = true
61
- test_cloudinary_url("test", {:private_cdn => false}, "http://res.cloudinary.com/test123/image/upload/test", {})
55
+ test_cloudinary_url("test", { :private_cdn => false }, "#{upload_path}/test", {})
62
56
  end
63
57
 
64
58
  it "should allow overriding cname if cname=example.com" do
@@ -67,11 +61,11 @@ describe Cloudinary::Utils do
67
61
 
68
62
  it "should allow overriding cname if cname=false" do
69
63
  Cloudinary.config.cname = "example.com"
70
- test_cloudinary_url("test", {:cname => nil}, "http://res.cloudinary.com/test123/image/upload/test", {})
64
+ test_cloudinary_url("test", { :cname => false }, "#{upload_path}/test", {})
71
65
  end
72
66
 
73
- it "should use format from options" do
74
- test_cloudinary_url("test", {:format=>:jpg}, "http://res.cloudinary.com/test123/image/upload/test.jpg", {})
67
+ it "should use format from options" do
68
+ test_cloudinary_url("test", { :format => :jpg }, "#{upload_path}/test.jpg", {})
75
69
  end
76
70
 
77
71
  it "should disallow url_suffix in shared distribution" do
@@ -112,8 +106,8 @@ describe Cloudinary::Utils do
112
106
 
113
107
  it "should allow use_root_path in shared distribution" do
114
108
  # expect{Cloudinary::Utils.cloudinary_url("test", {:use_root_path=>true})}.to raise_error(CloudinaryException)
115
- test_cloudinary_url("test", {:use_root_path=>true, :private_cdn=>false}, "http://res.cloudinary.com/test123/test", {})
116
- test_cloudinary_url("test", {:use_root_path=>true, :private_cdn=>false, :angle=>0}, "http://res.cloudinary.com/test123/a_0/test", {})
109
+ test_cloudinary_url("test", { :use_root_path => true, :private_cdn => false }, "#{root_path}/test", {})
110
+ test_cloudinary_url("test", { :use_root_path => true, :private_cdn => false, :angle => 0 }, "#{root_path}/a_0/test", {})
117
111
  end
118
112
 
119
113
  it "should support use_root_path for private_cdn" do
@@ -133,38 +127,38 @@ describe Cloudinary::Utils do
133
127
  end
134
128
 
135
129
  it "should use width and height from options only if crop is given" do
136
- test_cloudinary_url("test", {:width=>100, :height=>100}, "http://res.cloudinary.com/test123/image/upload/test", {:width=>100, :height=>100})
137
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:crop}, "http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/test", {:width=>100, :height=>100})
130
+ test_cloudinary_url("test", { :width => 100, :height => 100 }, "#{upload_path}/test", { :width => 100, :height => 100 })
131
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :crop }, "#{upload_path}/c_crop,h_100,w_100/test", { :width => 100, :height => 100 })
138
132
  end
139
133
 
140
134
  it "should not pass width and height to html in case of fit, lfill or limit crop" do
141
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:limit}, "http://res.cloudinary.com/test123/image/upload/c_limit,h_100,w_100/test", {})
142
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:lfill}, "http://res.cloudinary.com/test123/image/upload/c_lfill,h_100,w_100/test", {})
143
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:fit}, "http://res.cloudinary.com/test123/image/upload/c_fit,h_100,w_100/test", {})
135
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :limit }, "#{upload_path}/c_limit,h_100,w_100/test", {})
136
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :lfill }, "#{upload_path}/c_lfill,h_100,w_100/test", {})
137
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :fit }, "#{upload_path}/c_fit,h_100,w_100/test", {})
144
138
  end
145
139
 
146
140
  it "should not pass width and height to html in case angle was used" do
147
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:scale, :angle=>:auto}, "http://res.cloudinary.com/test123/image/upload/a_auto,c_scale,h_100,w_100/test", {})
141
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :scale, :angle => :auto }, "#{upload_path}/a_auto,c_scale,h_100,w_100/test", {})
148
142
  end
149
143
 
150
- it "should use x, y, radius, prefix, gravity and quality from options" do
151
- test_cloudinary_url("test", {:x=>1, :y=>2, :radius=>3, :gravity=>:center, :quality=>0.4, :prefix=>"a"}, "http://res.cloudinary.com/test123/image/upload/g_center,p_a,q_0.4,r_3,x_1,y_2/test", {})
144
+ it "should use x, y, radius, prefix, gravity and quality from options" do
145
+ test_cloudinary_url("test", { :x => 1, :y => 2, :radius => 3, :gravity => :center, :quality => 0.4, :prefix => "a" }, "#{upload_path}/g_center,p_a,q_0.4,r_3,x_1,y_2/test", {})
152
146
  end
153
147
 
154
- it "should support named tranformation" do
155
- test_cloudinary_url("test", {:transformation=>"blip"}, "http://res.cloudinary.com/test123/image/upload/t_blip/test", {})
148
+ it "should support named tranformation" do
149
+ test_cloudinary_url("test", { :transformation => "blip" }, "#{upload_path}/t_blip/test", {})
156
150
  end
157
151
 
158
- it "should support array of named tranformations" do
159
- test_cloudinary_url("test", {:transformation=>["blip", "blop"]}, "http://res.cloudinary.com/test123/image/upload/t_blip.blop/test", {})
152
+ it "should support array of named tranformations" do
153
+ test_cloudinary_url("test", { :transformation => ["blip", "blop"] }, "#{upload_path}/t_blip.blop/test", {})
160
154
  end
161
155
 
162
- it "should support base tranformation" do
163
- test_cloudinary_url("test", {:transformation=>{:x=>100, :y=>100, :crop=>:fill}, :crop=>:crop, :width=>100}, "http://res.cloudinary.com/test123/image/upload/c_fill,x_100,y_100/c_crop,w_100/test", {:width=>100})
156
+ it "should support base tranformation" do
157
+ test_cloudinary_url("test", { :transformation => { :x => 100, :y => 100, :crop => :fill }, :crop => :crop, :width => 100 }, "#{upload_path}/c_fill,x_100,y_100/c_crop,w_100/test", { :width => 100 })
164
158
  end
165
159
 
166
- it "should support array of base tranformations" do
167
- test_cloudinary_url("test", {:transformation=>[{:x=>100, :y=>100, :width=>200, :crop=>:fill}, {:radius=>10}], :crop=>:crop, :width=>100}, "http://res.cloudinary.com/test123/image/upload/c_fill,w_200,x_100,y_100/r_10/c_crop,w_100/test", {:width=>100})
160
+ it "should support array of base tranformations" do
161
+ test_cloudinary_url("test", { :transformation => [{ :x => 100, :y => 100, :width => 200, :crop => :fill }, { :radius => 10 }], :crop => :crop, :width => 100 }, "#{upload_path}/c_fill,w_200,x_100,y_100/r_10/c_crop,w_100/test", { :width => 100 })
168
162
  end
169
163
 
170
164
  it "should support array of tranformations" do
@@ -172,30 +166,30 @@ describe Cloudinary::Utils do
172
166
  expect(result).to eq("c_fill,w_200,x_100,y_100/r_10")
173
167
  end
174
168
 
175
- it "should not include empty tranformations" do
176
- test_cloudinary_url("test", {:transformation=>[{}, {:x=>100, :y=>100, :crop=>:fill}, {}]}, "http://res.cloudinary.com/test123/image/upload/c_fill,x_100,y_100/test", {})
169
+ it "should not include empty tranformations" do
170
+ test_cloudinary_url("test", { :transformation => [{}, { :x => 100, :y => 100, :crop => :fill }, {}] }, "#{upload_path}/c_fill,x_100,y_100/test", {})
177
171
  end
178
172
 
179
- it "should support size" do
180
- test_cloudinary_url("test", {:size=>"10x10", :crop=>:crop}, "http://res.cloudinary.com/test123/image/upload/c_crop,h_10,w_10/test", {:width=>"10", :height=>"10"})
173
+ it "should support size" do
174
+ test_cloudinary_url("test", { :size => "10x10", :crop => :crop }, "#{upload_path}/c_crop,h_10,w_10/test", { :width => "10", :height => "10" })
181
175
  end
182
176
 
183
177
  it "should use type from options" do
184
- test_cloudinary_url("test", {:type=>:facebook}, "http://res.cloudinary.com/test123/image/facebook/test", {})
178
+ test_cloudinary_url("test", { :type => :facebook }, "#{root_path}/image/facebook/test", {})
185
179
  end
186
180
 
187
181
  it "should use resource_type from options" do
188
- test_cloudinary_url("test", {:resource_type=>:raw}, "http://res.cloudinary.com/test123/raw/upload/test", {})
182
+ test_cloudinary_url("test", { :resource_type => :raw }, "#{root_path}/raw/upload/test", {})
189
183
  end
190
184
 
191
185
  it "should ignore http links only if type is not given or is asset" do
192
186
  test_cloudinary_url("http://test", {:type=>nil}, "http://test", {})
193
187
  test_cloudinary_url("http://test", {:type=>:asset}, "http://test", {})
194
- test_cloudinary_url("http://test", {:type=>:fetch}, "http://res.cloudinary.com/test123/image/fetch/http://test" , {})
188
+ test_cloudinary_url("http://test", { :type => :fetch }, "#{root_path}/image/fetch/http://test", {})
195
189
  end
196
190
 
197
191
  it "should use allow absolute links to /images" do
198
- test_cloudinary_url("/images/test", {}, "http://res.cloudinary.com/test123/image/upload/test", {})
192
+ test_cloudinary_url("/images/test", {}, "#{upload_path}/test", {})
199
193
  end
200
194
 
201
195
  it "should use ignore absolute links not to /images" do
@@ -203,60 +197,61 @@ describe Cloudinary::Utils do
203
197
  end
204
198
 
205
199
  it "should escape fetch urls" do
206
- test_cloudinary_url("http://blah.com/hello?a=b", {:type=>:fetch}, "http://res.cloudinary.com/test123/image/fetch/http://blah.com/hello%3Fa%3Db", {})
200
+ test_cloudinary_url("http://blah.com/hello?a=b", { :type => :fetch }, "#{root_path}/image/fetch/http://blah.com/hello%3Fa%3Db", {})
207
201
  end
208
202
 
209
203
  it "should should escape http urls" do
210
- test_cloudinary_url("http://www.youtube.com/watch?v=d9NF2edxy-M", {:type=>:youtube}, "http://res.cloudinary.com/test123/image/youtube/http://www.youtube.com/watch%3Fv%3Dd9NF2edxy-M", {})
204
+ test_cloudinary_url("http://www.youtube.com/watch?v=d9NF2edxy-M", { :type => :youtube }, "#{root_path}/image/youtube/http://www.youtube.com/watch%3Fv%3Dd9NF2edxy-M", {})
211
205
  end
212
206
 
213
207
  it "should support background" do
214
- test_cloudinary_url("test", {:background=>"red"}, "http://res.cloudinary.com/test123/image/upload/b_red/test", {})
215
- test_cloudinary_url("test", {:background=>"#112233"}, "http://res.cloudinary.com/test123/image/upload/b_rgb:112233/test", {})
208
+ test_cloudinary_url("test", { :background => "red" }, "#{upload_path}/b_red/test", {})
209
+ test_cloudinary_url("test", { :background => "#112233" }, "#{upload_path}/b_rgb:112233/test", {})
216
210
  end
217
211
 
218
212
  it "should support default_image" do
219
- test_cloudinary_url("test", {:default_image=>"default"}, "http://res.cloudinary.com/test123/image/upload/d_default/test", {})
213
+ test_cloudinary_url("test", { :default_image => "default" }, "#{upload_path}/d_default/test", {})
220
214
  end
221
215
 
222
216
  it "should support angle" do
223
- test_cloudinary_url("test", {:angle=>"55"}, "http://res.cloudinary.com/test123/image/upload/a_55/test", {})
224
- test_cloudinary_url("test", {:angle=>["auto", "55"]}, "http://res.cloudinary.com/test123/image/upload/a_auto.55/test", {})
217
+ test_cloudinary_url("test", { :angle => "55" }, "#{upload_path}/a_55/test", {})
218
+ test_cloudinary_url("test", { :angle => ["auto", "55"] }, "#{upload_path}/a_auto.55/test", {})
225
219
  end
226
220
 
227
221
  it "should support format for fetch urls" do
228
- test_cloudinary_url("http://cloudinary.com/images/logo.png", {:format=>"jpg", :type=>:fetch}, "http://res.cloudinary.com/test123/image/fetch/f_jpg/http://cloudinary.com/images/logo.png", {})
222
+ test_cloudinary_url("http://cloudinary.com/images/logo.png", { :format => "jpg", :type => :fetch }, "#{root_path}/image/fetch/f_jpg/http://cloudinary.com/images/logo.png", {})
229
223
  end
230
224
 
231
225
  it "should support effect" do
232
- test_cloudinary_url("test", {:effect=>"sepia"}, "http://res.cloudinary.com/test123/image/upload/e_sepia/test", {})
226
+ test_cloudinary_url("test", { :effect => "sepia" }, "#{upload_path}/e_sepia/test", {})
233
227
  end
234
228
 
235
229
  it "should support effect with hash param" do
236
- test_cloudinary_url("test", {:effect=>{"sepia"=>10}}, "http://res.cloudinary.com/test123/image/upload/e_sepia:10/test", {})
230
+ test_cloudinary_url("test", { :effect => { "sepia" => 10 } }, "#{upload_path}/e_sepia:10/test", {})
237
231
  end
238
232
 
239
233
  it "should support effect with array param" do
240
- test_cloudinary_url("test", {:effect=>["sepia", 10]}, "http://res.cloudinary.com/test123/image/upload/e_sepia:10/test", {})
234
+ test_cloudinary_url("test", { :effect => ["sepia", 10] }, "#{upload_path}/e_sepia:10/test", {})
241
235
  end
242
236
 
243
237
  {:overlay=>:l, :underlay=>:u}.each do |param, letter|
244
238
  it "should support #{param}" do
245
- test_cloudinary_url("test", {param=>"text:hello"}, "http://res.cloudinary.com/test123/image/upload/#{letter}_text:hello/test", {})
239
+ test_cloudinary_url("test", { param => "text:hello" }, "#{upload_path}/#{letter}_text:hello/test", {})
246
240
  end
247
241
 
248
242
  it "should not pass width/height to html for #{param}" do
249
- test_cloudinary_url("test", {param=>"text:hello", :height=>100, :width=>100}, "http://res.cloudinary.com/test123/image/upload/h_100,#{letter}_text:hello,w_100/test", {})
243
+ test_cloudinary_url("test", { param => "text:hello", :height => 100, :width => 100 }, "#{upload_path}/h_100,#{letter}_text:hello,w_100/test", {})
250
244
  end
251
245
  end
252
246
 
247
+
253
248
  it "should use ssl_detected if secure is not given as parameter and not set to true in configuration" do
254
249
  test_cloudinary_url("test", {:ssl_detected=>true}, "https://res.cloudinary.com/test123/image/upload/test", {})
255
250
  end
256
251
 
257
252
  it "should use secure if given over ssl_detected and configuration" do
258
253
  Cloudinary.config.secure = true
259
- test_cloudinary_url("test", {:ssl_detected=>true, :secure=>false}, "http://res.cloudinary.com/test123/image/upload/test", {})
254
+ test_cloudinary_url("test", { :ssl_detected => true, :secure => false }, "#{upload_path}/test", {})
260
255
  end
261
256
 
262
257
  it "should use secure: true from configuration over ssl_detected" do
@@ -285,19 +280,19 @@ describe Cloudinary::Utils do
285
280
  end
286
281
 
287
282
  it "should support string param" do
288
- test_cloudinary_url("test", {"effect"=>{"sepia"=>10}}, "http://res.cloudinary.com/test123/image/upload/e_sepia:10/test", {})
283
+ test_cloudinary_url("test", { "effect" => { "sepia" => 10 } }, "#{upload_path}/e_sepia:10/test", {})
289
284
  end
290
285
 
291
286
  it "should support border" do
292
- test_cloudinary_url("test", {"border"=>{:width=>5}}, "http://res.cloudinary.com/test123/image/upload/bo_5px_solid_black/test", {})
293
- test_cloudinary_url("test", {"border"=>{:width=>5, :color=>"#ffaabbdd"}}, "http://res.cloudinary.com/test123/image/upload/bo_5px_solid_rgb:ffaabbdd/test", {})
294
- test_cloudinary_url("test", {"border"=>"1px_solid_blue"}, "http://res.cloudinary.com/test123/image/upload/bo_1px_solid_blue/test", {})
295
- test_cloudinary_url("test", {"border"=>"2"}, "http://res.cloudinary.com/test123/image/upload/test", {:border=>"2"})
287
+ test_cloudinary_url("test", { "border" => { :width => 5 } }, "#{upload_path}/bo_5px_solid_black/test", {})
288
+ test_cloudinary_url("test", { "border" => { :width => 5, :color => "#ffaabbdd" } }, "#{upload_path}/bo_5px_solid_rgb:ffaabbdd/test", {})
289
+ test_cloudinary_url("test", { "border" => "1px_solid_blue" }, "#{upload_path}/bo_1px_solid_blue/test", {})
290
+ test_cloudinary_url("test", { "border" => "2" }, "#{upload_path}/test", { :border => "2" })
296
291
  end
297
292
 
298
293
  it "should support flags" do
299
- test_cloudinary_url("test", {"flags"=>"abc"}, "http://res.cloudinary.com/test123/image/upload/fl_abc/test", {})
300
- test_cloudinary_url("test", {"flags"=>["abc", "def"]}, "http://res.cloudinary.com/test123/image/upload/fl_abc.def/test", {})
294
+ test_cloudinary_url("test", { "flags" => "abc" }, "#{upload_path}/fl_abc/test", {})
295
+ test_cloudinary_url("test", { "flags" => ["abc", "def"] }, "#{upload_path}/fl_abc.def/test", {})
301
296
  end
302
297
 
303
298
  it "build_upload_params should not destroy options" do
@@ -319,16 +314,16 @@ describe Cloudinary::Utils do
319
314
  end
320
315
 
321
316
  it "should add version if public_id contains /" do
322
- test_cloudinary_url("folder/test", {}, "http://res.cloudinary.com/test123/image/upload/v1/folder/test", {})
323
- test_cloudinary_url("folder/test", {:version=>123}, "http://res.cloudinary.com/test123/image/upload/v123/folder/test", {})
317
+ test_cloudinary_url("folder/test", {}, "#{upload_path}/v1/folder/test", {})
318
+ test_cloudinary_url("folder/test", { :version => 123 }, "#{upload_path}/v123/folder/test", {})
324
319
  end
325
320
 
326
321
  it "should not add version if public_id contains version already" do
327
- test_cloudinary_url("v1234/test", {}, "http://res.cloudinary.com/test123/image/upload/v1234/test", {})
322
+ test_cloudinary_url("v1234/test", {}, "#{upload_path}/v1234/test", {})
328
323
  end
329
324
 
330
325
  it "should allow to shorted image/upload urls" do
331
- test_cloudinary_url("test", {:shorten=>true}, "http://res.cloudinary.com/test123/iu/test", {})
326
+ test_cloudinary_url("test", { :shorten => true }, "#{root_path}/iu/test", {})
332
327
  end
333
328
 
334
329
  it "should allow to use folders in PreloadedFile" do
@@ -347,23 +342,23 @@ describe Cloudinary::Utils do
347
342
  ["parentheses(interject)", "parentheses%28interject%29"]
348
343
  ].each do
349
344
  |source, target|
350
- expect(Cloudinary::Utils.cloudinary_url(source)).to eq("http://res.cloudinary.com/test123/image/upload/#{target}")
345
+ expect(Cloudinary::Utils.cloudinary_url(source)).to eq("#{upload_path}/#{target}")
351
346
  end
352
347
  end
353
348
 
354
349
  it "should correctly sign URLs", :signed => true do
355
- test_cloudinary_url("image.jpg", {:version => 1234, :transformation => {:crop => "crop", :width => 10, :height => 20}, :sign_url => true}, "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/v1234/image.jpg", {})
356
- test_cloudinary_url("image.jpg", {:version => 1234, :sign_url => true}, "http://res.cloudinary.com/test123/image/upload/s----SjmNDA--/v1234/image.jpg", {})
357
- test_cloudinary_url("image.jpg", {:transformation => {:crop => "crop", :width => 10, :height => 20}, :sign_url => true}, "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
358
- test_cloudinary_url("image.jpg", {:transformation => {:crop => "crop", :width => 10, :height => 20}, :type => :authenticated, :sign_url => true}, "http://res.cloudinary.com/test123/image/authenticated/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
359
- test_cloudinary_url("http://google.com/path/to/image.png", {:type => "fetch", :version => 1234, :sign_url => true}, "http://res.cloudinary.com/test123/image/fetch/s--hH_YcbiS--/v1234/http://google.com/path/to/image.png", {})
350
+ test_cloudinary_url("image.jpg", { :version => 1234, :transformation => { :crop => "crop", :width => 10, :height => 20 }, :sign_url => true }, "#{upload_path}/s--Ai4Znfl3--/c_crop,h_20,w_10/v1234/image.jpg", {})
351
+ test_cloudinary_url("image.jpg", { :version => 1234, :sign_url => true }, "#{upload_path}/s----SjmNDA--/v1234/image.jpg", {})
352
+ test_cloudinary_url("image.jpg", { :transformation => { :crop => "crop", :width => 10, :height => 20 }, :sign_url => true }, "#{upload_path}/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
353
+ test_cloudinary_url("image.jpg", { :transformation => { :crop => "crop", :width => 10, :height => 20 }, :type => :authenticated, :sign_url => true }, "#{root_path}/image/authenticated/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
354
+ test_cloudinary_url("http://google.com/path/to/image.png", { :type => "fetch", :version => 1234, :sign_url => true }, "#{root_path}/image/fetch/s--hH_YcbiS--/v1234/http://google.com/path/to/image.png", {})
360
355
  end
361
356
 
362
357
  it "should correctly sign URLs in deprecated sign_version mode", :signed => true do
363
- test_cloudinary_url("image.jpg", {:version => 1234, :transformation => {:crop => "crop", :width => 10, :height => 20}, :sign_url => true, :sign_version => true}, "http://res.cloudinary.com/test123/image/upload/s--MaRXzoEC--/c_crop,h_20,w_10/v1234/image.jpg", {})
364
- test_cloudinary_url("image.jpg", {:version => 1234, :sign_url => true, :sign_version => true}, "http://res.cloudinary.com/test123/image/upload/s--ZlgFLQcO--/v1234/image.jpg", {})
365
- test_cloudinary_url("image.jpg", {:transformation => {:crop => "crop", :width => 10, :height => 20}, :sign_url => true, :sign_version => true}, "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
366
- test_cloudinary_url("http://google.com/path/to/image.png", {:type => "fetch", :version => 1234, :sign_url => true, :sign_version => true}, "http://res.cloudinary.com/test123/image/fetch/s--_GAUclyB--/v1234/http://google.com/path/to/image.png", {})
358
+ test_cloudinary_url("image.jpg", { :version => 1234, :transformation => { :crop => "crop", :width => 10, :height => 20 }, :sign_url => true, :sign_version => true }, "#{upload_path}/s--MaRXzoEC--/c_crop,h_20,w_10/v1234/image.jpg", {})
359
+ test_cloudinary_url("image.jpg", { :version => 1234, :sign_url => true, :sign_version => true }, "#{upload_path}/s--ZlgFLQcO--/v1234/image.jpg", {})
360
+ test_cloudinary_url("image.jpg", { :transformation => { :crop => "crop", :width => 10, :height => 20 }, :sign_url => true, :sign_version => true }, "#{upload_path}/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg", {})
361
+ test_cloudinary_url("http://google.com/path/to/image.png", { :type => "fetch", :version => 1234, :sign_url => true, :sign_version => true }, "#{root_path}/image/fetch/s--_GAUclyB--/v1234/http://google.com/path/to/image.png", {})
367
362
  end
368
363
 
369
364
  it "should correctly sign_request" do
@@ -372,9 +367,9 @@ describe Cloudinary::Utils do
372
367
  end
373
368
 
374
369
  it "should support responsive width" do
375
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:crop, :responsive_width=>true}, "http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_limit,w_auto/test", {responsive: true})
370
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :crop, :responsive_width => true }, "#{upload_path}/c_crop,h_100,w_100/c_limit,w_auto/test", { :responsive => true })
376
371
  Cloudinary.config.responsive_width_transformation = {:width => :auto, :crop => :pad}
377
- test_cloudinary_url("test", {:width=>100, :height=>100, :crop=>:crop, :responsive_width=>true}, "http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_pad,w_auto/test", {responsive: true})
372
+ test_cloudinary_url("test", { :width => 100, :height => 100, :crop => :crop, :responsive_width => true }, "#{upload_path}/c_crop,h_100,w_100/c_pad,w_auto/test", { :responsive => true })
378
373
  end
379
374
 
380
375
  it "should correctly encode double arrays" do