cloudinary 1.9.1 → 1.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- data/.github/pull_request_template.md +24 -0
- data/.gitignore +7 -1
- data/.travis.yml +15 -8
- data/CHANGELOG.md +261 -0
- data/README.md +3 -0
- data/Rakefile +3 -45
- data/cloudinary.gemspec +27 -20
- data/lib/active_storage/blob_key.rb +20 -0
- data/lib/active_storage/service/cloudinary_service.rb +249 -0
- data/lib/cloudinary.rb +53 -63
- data/lib/cloudinary/account_api.rb +231 -0
- data/lib/cloudinary/account_config.rb +30 -0
- data/lib/cloudinary/api.rb +228 -71
- data/lib/cloudinary/auth_token.rb +10 -4
- data/lib/cloudinary/base_api.rb +79 -0
- data/lib/cloudinary/base_config.rb +70 -0
- data/lib/cloudinary/cache.rb +38 -0
- data/lib/cloudinary/cache/breakpoints_cache.rb +31 -0
- data/lib/cloudinary/cache/key_value_cache_adapter.rb +25 -0
- data/lib/cloudinary/cache/rails_cache_adapter.rb +34 -0
- data/lib/cloudinary/cache/storage/rails_cache_storage.rb +5 -0
- data/lib/cloudinary/carrier_wave.rb +4 -2
- data/lib/cloudinary/carrier_wave/remote.rb +3 -2
- data/lib/cloudinary/carrier_wave/storage.rb +2 -1
- data/lib/cloudinary/{controller.rb → cloudinary_controller.rb} +3 -5
- data/lib/cloudinary/config.rb +43 -0
- data/lib/cloudinary/helper.rb +77 -7
- data/lib/cloudinary/migrator.rb +3 -1
- data/lib/cloudinary/railtie.rb +7 -3
- data/lib/cloudinary/responsive.rb +111 -0
- data/lib/cloudinary/uploader.rb +67 -15
- data/lib/cloudinary/utils.rb +324 -54
- data/lib/cloudinary/version.rb +1 -1
- data/lib/cloudinary/video_helper.rb +96 -22
- data/lib/tasks/cloudinary/fetch_assets.rake +48 -0
- data/lib/tasks/{cloudinary.rake → cloudinary/sync_static.rake} +0 -0
- data/tools/allocate_test_cloud.sh +9 -0
- data/tools/get_test_cloud.sh +9 -0
- data/tools/update_version +220 -0
- data/vendor/assets/javascripts/cloudinary/jquery.cloudinary.js +51 -13
- data/vendor/assets/javascripts/cloudinary/jquery.fileupload.js +24 -4
- data/vendor/assets/javascripts/cloudinary/jquery.ui.widget.js +741 -561
- data/vendor/assets/javascripts/cloudinary/load-image.all.min.js +1 -1
- metadata +92 -67
- data/spec/access_control_spec.rb +0 -99
- data/spec/api_spec.rb +0 -545
- data/spec/archive_spec.rb +0 -129
- data/spec/auth_token_spec.rb +0 -79
- data/spec/cloudinary_helper_spec.rb +0 -190
- data/spec/cloudinary_spec.rb +0 -32
- data/spec/data/sync_static/app/assets/javascripts/1.coffee +0 -1
- data/spec/data/sync_static/app/assets/javascripts/1.js +0 -1
- data/spec/data/sync_static/app/assets/stylesheets/1.css +0 -3
- data/spec/docx.docx +0 -0
- data/spec/favicon.ico +0 -0
- data/spec/logo.png +0 -0
- data/spec/rake_spec.rb +0 -160
- data/spec/sample_asset_file.tsv +0 -4
- data/spec/search_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -245
- data/spec/storage_spec.rb +0 -44
- data/spec/streaminig_profiles_api_spec.rb +0 -74
- data/spec/support/helpers/temp_file_helpers.rb +0 -22
- data/spec/support/shared_contexts/rake.rb +0 -19
- data/spec/uploader_spec.rb +0 -363
- data/spec/utils_methods_spec.rb +0 -54
- data/spec/utils_spec.rb +0 -906
- data/spec/video_tag_spec.rb +0 -251
- data/spec/video_url_spec.rb +0 -164
data/spec/archive_spec.rb
DELETED
@@ -1,129 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cloudinary'
|
3
|
-
require 'rest_client'
|
4
|
-
require 'zip'
|
5
|
-
|
6
|
-
RSpec.shared_context 'archive' do
|
7
|
-
|
8
|
-
before :all do
|
9
|
-
Cloudinary::Uploader.upload(
|
10
|
-
"http://res.cloudinary.com/demo/image/upload/sample.jpg",
|
11
|
-
:public_id => 'tag_samplebw',
|
12
|
-
:tags => [TEST_TAG, TIMESTAMP_TAG],
|
13
|
-
:transformation => {
|
14
|
-
:effect => :blackwhite
|
15
|
-
}
|
16
|
-
)
|
17
|
-
Cloudinary::Uploader.upload(
|
18
|
-
"http://res.cloudinary.com/demo/image/upload/sample.jpg",
|
19
|
-
:public_id => 'tag_sample',
|
20
|
-
:tags => [TEST_TAG, TIMESTAMP_TAG],
|
21
|
-
:transformation => {
|
22
|
-
:effect => :blackwhite
|
23
|
-
}
|
24
|
-
)
|
25
|
-
Cloudinary::Uploader.upload(
|
26
|
-
"http://res.cloudinary.com/demo/image/upload/sample.jpg",
|
27
|
-
:public_id => 'tag_sample_raw.jpg',
|
28
|
-
:resource_type => 'raw',
|
29
|
-
:tags => [TEST_TAG, TIMESTAMP_TAG],
|
30
|
-
)
|
31
|
-
end
|
32
|
-
include_context "cleanup", TIMESTAMP_TAG
|
33
|
-
end
|
34
|
-
|
35
|
-
describe Cloudinary::Utils do
|
36
|
-
include_context 'archive'
|
37
|
-
|
38
|
-
describe '.generate_zip_download_url' do
|
39
|
-
let(:options) { {} }
|
40
|
-
let!(:archive_result) {
|
41
|
-
Cloudinary::Utils.download_zip_url(
|
42
|
-
{
|
43
|
-
:target_public_id => 'gem_archive_test',
|
44
|
-
:public_ids => %w(tag_sample tag_samplebw),
|
45
|
-
:target_tags => [TEST_TAG, TIMESTAMP_TAG]
|
46
|
-
}.merge(options))
|
47
|
-
}
|
48
|
-
|
49
|
-
describe 'public_ids' do
|
50
|
-
it 'should generate a valid url' do
|
51
|
-
expect(archive_result).not_to be_empty
|
52
|
-
end
|
53
|
-
it 'should include two files' do
|
54
|
-
Zip::File.open_buffer(RestClient.get(archive_result)) do |zip_file|
|
55
|
-
list = zip_file.glob('*').map(&:name)
|
56
|
-
expect(list.length).to be(2)
|
57
|
-
expect(list).to include('tag_sample.jpg', 'tag_samplebw.jpg')
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe Cloudinary::Uploader do
|
65
|
-
include_context 'archive'
|
66
|
-
|
67
|
-
let(:options) { {} }
|
68
|
-
|
69
|
-
describe '.create_archive' do
|
70
|
-
let!(:target_public_id) {
|
71
|
-
"gem_test#{ SUFFIX}"
|
72
|
-
}
|
73
|
-
expected_keys = %w(
|
74
|
-
resource_type
|
75
|
-
type
|
76
|
-
public_id
|
77
|
-
version
|
78
|
-
url
|
79
|
-
secure_url
|
80
|
-
created_at
|
81
|
-
tags
|
82
|
-
signature
|
83
|
-
bytes
|
84
|
-
etag
|
85
|
-
resource_count
|
86
|
-
file_count
|
87
|
-
)
|
88
|
-
let!(:archive_result) {
|
89
|
-
Cloudinary::Uploader.create_archive(
|
90
|
-
{
|
91
|
-
:target_public_id => target_public_id,
|
92
|
-
:public_ids => %w(tag_sample tag_samplebw),
|
93
|
-
:tags => [TEST_TAG, TIMESTAMP_TAG],
|
94
|
-
:transformations => [{width: 100, height: 100, crop: "fill"},{effect: "grayscale"}],
|
95
|
-
:skip_transformation_name => true
|
96
|
-
}.merge(options))
|
97
|
-
}
|
98
|
-
let(:options) { { :mode => :create } }
|
99
|
-
it 'should return a Hash with suitable set of keys' do
|
100
|
-
expect(archive_result).to be_a(Hash)
|
101
|
-
expect(archive_result.keys).to include(*expected_keys)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
describe 'create archive based on raw resources and missing public IDs' do
|
105
|
-
let!(:target_public_id) {
|
106
|
-
"gem_test#{ SUFFIX}"
|
107
|
-
}
|
108
|
-
let!(:archive_result) {
|
109
|
-
Cloudinary::Uploader.create_archive(
|
110
|
-
{
|
111
|
-
:target_public_id => target_public_id,
|
112
|
-
:public_ids => %w(tag_sample_raw.jpg non-wxisting-resource),
|
113
|
-
:resource_type => 'raw',
|
114
|
-
:allow_missing => true
|
115
|
-
}.merge(options))
|
116
|
-
}
|
117
|
-
let(:options) { { :mode => :create } }
|
118
|
-
it 'should skip missing public IDs and successfully generate the archive containing raw resources' do
|
119
|
-
expect(archive_result).to be_a(Hash)
|
120
|
-
expect(archive_result["resource_count"]).to equal(1)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
describe '.create_zip' do
|
124
|
-
it 'should call create_archive with "zip" format' do
|
125
|
-
expect(Cloudinary::Uploader).to receive(:create_archive).with({ :tags => TEST_TAG }, "zip")
|
126
|
-
Cloudinary::Uploader.create_zip({ :tags => TEST_TAG })
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
data/spec/auth_token_spec.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'cloudinary'
|
4
|
-
|
5
|
-
describe 'auth_token' do
|
6
|
-
before :all do
|
7
|
-
@url_backup = ENV["CLOUDINARY_URL"]
|
8
|
-
end
|
9
|
-
before do
|
10
|
-
Cloudinary.config_from_url "cloudinary://a:b@test123"
|
11
|
-
Cloudinary.config.auth_token = { :key => KEY, :duration => 300, :start_time => 11111111 }
|
12
|
-
end
|
13
|
-
after do
|
14
|
-
ENV["CLOUDINARY_URL"] = @url_backup
|
15
|
-
Cloudinary::config_from_url @url_backup
|
16
|
-
end
|
17
|
-
it "should generate with start and duration" do
|
18
|
-
token = Cloudinary::Utils.generate_auth_token :start_time => 1111111111, :acl => "/image/*", :duration => 300
|
19
|
-
expect(token).to eq '__cld_token__=st=1111111111~exp=1111111411~acl=%2fimage%2f*~hmac=1751370bcc6cfe9e03f30dd1a9722ba0f2cdca283fa3e6df3342a00a7528cc51'
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "authenticated url" do
|
23
|
-
before do
|
24
|
-
Cloudinary.config :private_cdn => true
|
25
|
-
|
26
|
-
end
|
27
|
-
it "should add token if authToken is globally set and signed = true" do
|
28
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :resource_type => "image", :type => "authenticated", :version => "1486020273"
|
29
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3")
|
30
|
-
|
31
|
-
end
|
32
|
-
it "should add token for 'public' resource" do
|
33
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :resource_type => "image", :type => "public", :version => "1486020273"
|
34
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/public/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=c2b77d9f81be6d89b5d0ebc67b671557e88a40bcf03dd4a6997ff4b994ceb80e")
|
35
|
-
|
36
|
-
end
|
37
|
-
it "should not add token if signed is false" do
|
38
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :type => "authenticated", :version => "1486020273"
|
39
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg")
|
40
|
-
|
41
|
-
end
|
42
|
-
it "should not add token if authToken is globally set but null auth token is explicitly set and signed = true" do
|
43
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :auth_token => false, :sign_url => true, :type => "authenticated", :version => "1486020273"
|
44
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/s--v2fTPYTu--/v1486020273/sample.jpg")
|
45
|
-
|
46
|
-
end
|
47
|
-
it "explicit authToken should override global setting" do
|
48
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :auth_token => { :key => ALT_KEY, :start_time => 222222222, :duration => 100 }, :type => "authenticated", :transformation => { :crop => "scale", :width => 300 }
|
49
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/c_scale,w_300/sample.jpg?__cld_token__=st=222222222~exp=222222322~hmac=55cfe516530461213fe3b3606014533b1eca8ff60aeab79d1bb84c9322eebc1f")
|
50
|
-
|
51
|
-
end
|
52
|
-
it "should compute expiration as start time + duration" do
|
53
|
-
token = { :key => KEY, :start_time => 11111111, :duration => 300 }
|
54
|
-
url = Cloudinary::Utils.cloudinary_url "sample.jpg", :sign_url => true, :auth_token => token, :resource_type => "image", :type => "authenticated", :version => "1486020273"
|
55
|
-
expect(url).to eq("http://test123-res.cloudinary.com/image/authenticated/v1486020273/sample.jpg?__cld_token__=st=11111111~exp=11111411~hmac=8db0d753ee7bbb9e2eaf8698ca3797436ba4c20e31f44527e43b6a6e995cfdb3")
|
56
|
-
|
57
|
-
end
|
58
|
-
it "should raise if key is not provided" do
|
59
|
-
Cloudinary.config.auth_token[:key] = nil
|
60
|
-
token = { :expiration => 111111, :duration => 0 }
|
61
|
-
expect{Cloudinary::Utils.generate_auth_token(token)}.to raise_error(/Missing auth token key configuration/)
|
62
|
-
end
|
63
|
-
it "should raise if expiration and duration are not provided" do
|
64
|
-
token = { :key => KEY, :expiration => 0, :duration => 0 }
|
65
|
-
expect{Cloudinary::Utils.generate_auth_token(token)}.to raise_error(/Must provide either expiration or duration/)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
describe "authentication token" do
|
69
|
-
it "should generate token string" do
|
70
|
-
user = "foobar" # we can't rely on the default "now" value in tests
|
71
|
-
tokenOptions = { :key => KEY, :duration => 300, :acl => "/*/t_#{user}" }
|
72
|
-
tokenOptions[:start_time] = 222222222 # we can't rely on the default "now" value in tests
|
73
|
-
cookieToken = Cloudinary::Utils.generate_auth_token tokenOptions
|
74
|
-
expect(cookieToken).to eq("__cld_token__=st=222222222~exp=222222522~acl=%2f*%2ft_foobar~hmac=8e39600cc18cec339b21fe2b05fcb64b98de373355f8ce732c35710d8b10259f")
|
75
|
-
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'cloudinary'
|
4
|
-
require 'action_view'
|
5
|
-
require 'cloudinary/helper'
|
6
|
-
|
7
|
-
helper_class = Class.new do
|
8
|
-
include CloudinaryHelper
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.describe CloudinaryHelper do
|
12
|
-
let(:helper) { helper_class.new }
|
13
|
-
let(:options) { {} }
|
14
|
-
before :each do
|
15
|
-
Cloudinary.config({})
|
16
|
-
end
|
17
|
-
context "#cl_image_upload_tag" do
|
18
|
-
let(:options) {{:multiple => true}}
|
19
|
-
before do
|
20
|
-
if defined? allow
|
21
|
-
allow(Cloudinary::Utils).to receive_messages :cloudinary_api_url => '', :sign_request => Hash.new
|
22
|
-
allow(helper).to receive(:build_callback_url).and_return('')
|
23
|
-
else
|
24
|
-
Cloudinary::Utils.should_receive(:cloudinary_api_url).and_return('')
|
25
|
-
Cloudinary::Utils.should_receive(:sign_request).and_return(Hash.new)
|
26
|
-
helper.should_receive(:build_callback_url).and_return('')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
let(:test_tag) { TestTag.new( helper.cl_image_upload_tag('image_id', options)) }
|
30
|
-
|
31
|
-
it "allow multiple upload" do
|
32
|
-
expect(test_tag['data-cloudinary-field']).to eq('image_id[]')
|
33
|
-
expect(test_tag['multiple']).to eq('multiple')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
context "#cl_upload_tag" do
|
37
|
-
let(:options) {{:multiple => true}}
|
38
|
-
before do
|
39
|
-
if defined? allow
|
40
|
-
allow(Cloudinary::Utils).to receive_messages :cloudinary_api_url => '', :sign_request => Hash.new
|
41
|
-
allow(helper).to receive(:build_callback_url).and_return('')
|
42
|
-
else
|
43
|
-
Cloudinary::Utils.should_receive(:cloudinary_api_url).and_return('')
|
44
|
-
Cloudinary::Utils.should_receive(:sign_request).and_return(Hash.new)
|
45
|
-
helper.should_receive(:build_callback_url).and_return('')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
let(:test_tag) { TestTag.new( helper.cl_upload_tag('image_id', options)) }
|
49
|
-
|
50
|
-
it "allow multiple upload" do
|
51
|
-
expect(test_tag['data-cloudinary-field']).to eq('image_id[]')
|
52
|
-
expect(test_tag['multiple']).to eq('multiple')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context "#cl_image_tag" do
|
57
|
-
let(:test_tag) { TestTag.new( helper.cl_image_tag('sample.jpg', options)) }
|
58
|
-
|
59
|
-
context ":responsive_width" do
|
60
|
-
let(:options) { {:responsive_width => true, :cloud_name => "test"} }
|
61
|
-
it "should use data-src for responsive_width" do
|
62
|
-
expect(test_tag.name).to match( 'img')
|
63
|
-
expect(test_tag['class']).to eq("cld-responsive")
|
64
|
-
expect(test_tag['data-src']).to eq( "http://res.cloudinary.com/test/image/upload/c_limit,w_auto/sample.jpg")
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context ":dpr_auto" do
|
69
|
-
let(:options) { {:dpr => :auto, :cloud_name => "test"} }
|
70
|
-
it "should use data-src for dpr auto" do
|
71
|
-
expect(test_tag.name).to match( 'img')
|
72
|
-
expect(test_tag['class']).to eq( 'cld-hidpi')
|
73
|
-
expect(test_tag['data-src']).to eq( "http://res.cloudinary.com/test/image/upload/dpr_auto/sample.jpg")
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context ":client_hints" do
|
78
|
-
shared_examples "client_hints" do
|
79
|
-
it "should not use data-src or set responsive class" do
|
80
|
-
expect(test_tag.name).to match( 'img')
|
81
|
-
expect(test_tag['class']).to be_nil
|
82
|
-
expect(test_tag['data-src']).to be_nil
|
83
|
-
expect(test_tag['src']).to eq( "http://res.cloudinary.com/test/image/upload/dpr_auto,w_auto/sample.jpg")
|
84
|
-
end
|
85
|
-
it "should override :responsive" do
|
86
|
-
Cloudinary.config.responsive = true
|
87
|
-
expect(test_tag.name).to match( 'img')
|
88
|
-
expect(test_tag['class']).to be_nil
|
89
|
-
expect(test_tag['data-src']).to be_nil
|
90
|
-
expect(test_tag['src']).to eq( "http://res.cloudinary.com/test/image/upload/dpr_auto,w_auto/sample.jpg")
|
91
|
-
end
|
92
|
-
end
|
93
|
-
context "as option" do
|
94
|
-
let(:options) { {:dpr => :auto, :cloud_name => "test", :width => "auto", :client_hints => true} }
|
95
|
-
include_examples "client_hints"
|
96
|
-
end
|
97
|
-
context "as global configuration" do
|
98
|
-
before do
|
99
|
-
Cloudinary.config.client_hints = true
|
100
|
-
end
|
101
|
-
let(:options) { {:dpr => :auto, :cloud_name => "test", :width => "auto"} }
|
102
|
-
include_examples "client_hints"
|
103
|
-
end
|
104
|
-
|
105
|
-
context "false" do
|
106
|
-
let(:options) { {:width => :auto, :cloud_name => "test", :client_hints => false} }
|
107
|
-
it "should use normal responsive behaviour" do
|
108
|
-
expect(test_tag.name).to match( 'img')
|
109
|
-
expect(test_tag['class']).to eq( 'cld-responsive')
|
110
|
-
expect(test_tag['data-src']).to eq( "http://res.cloudinary.com/test/image/upload/w_auto/sample.jpg")
|
111
|
-
end
|
112
|
-
end
|
113
|
-
context "width" do
|
114
|
-
let(:options) { {:dpr => :auto, :cloud_name => "test", :width => "auto:breakpoints", :client_hints => true}}
|
115
|
-
it "supports auto width" do
|
116
|
-
expect(test_tag['src']).to eq( "http://res.cloudinary.com/test/image/upload/dpr_auto,w_auto:breakpoints/sample.jpg")
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context "#cl_client_hints_meta_tag" do
|
123
|
-
it "should create a meta tag" do
|
124
|
-
tag = TestTag.new( helper.cl_client_hints_meta_tag)
|
125
|
-
expect(tag.name).to match('meta')
|
126
|
-
expect(tag['content']).to eq('DPR, Viewport-Width, Width')
|
127
|
-
expect(tag['http-equiv']).to eq('Accept-CH')
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context "auth_token" do
|
132
|
-
it "should add token to an image tag url" do
|
133
|
-
tag = helper.cl_image_tag "sample.jpg",
|
134
|
-
:cloud_name => 'test123',
|
135
|
-
:sign_url => true,
|
136
|
-
:type => "authenticated",
|
137
|
-
:version => "1486020273",
|
138
|
-
:auth_token => {key: KEY, start_time: 11111111, duration: 300}
|
139
|
-
expect(tag).to match /<img.*src="http:\/\/res.cloudinary.com\/test123\/image\/authenticated\/v1486020273\/sample.jpg\?__cld_token__=st=11111111~exp=11111411~hmac=9bd6f41e2a5893da8343dc8eb648de8bf73771993a6d1457d49851250caf3b80.*>/
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
describe "image_path" do
|
145
|
-
|
146
|
-
before :all do
|
147
|
-
class Cloudinary::Static
|
148
|
-
class << self
|
149
|
-
def reset_metadata
|
150
|
-
@metadata = nil
|
151
|
-
@static_file_config = nil
|
152
|
-
@public_prefixes = nil
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
before :each do
|
159
|
-
@static_support = Cloudinary.config.static_image_support
|
160
|
-
@static_file = Cloudinary::Static::METADATA_FILE
|
161
|
-
Cloudinary::Static.reset_metadata
|
162
|
-
end
|
163
|
-
|
164
|
-
after :each do
|
165
|
-
Cloudinary.config.static_image_support = @static_support
|
166
|
-
Kernel::silence_warnings { Cloudinary::Static::METADATA_FILE = @static_file }
|
167
|
-
Cloudinary::Static.reset_metadata
|
168
|
-
end
|
169
|
-
|
170
|
-
context 'type=="asset"' do
|
171
|
-
it "should not transform images staring with /" do
|
172
|
-
expect(helper.image_path('/bar')).to eq('/bar')
|
173
|
-
end
|
174
|
-
it "should not transform images staring with /images unless asset is found and static_support is true" do
|
175
|
-
Cloudinary.config.static_image_support = false
|
176
|
-
expect(helper.image_path('/images/foo.jpg')).to eq('/images/foo.jpg')
|
177
|
-
expect(helper.image_path('some-folder/foo.gif')).to eq("/images/some-folder/foo.gif")
|
178
|
-
Kernel::silence_warnings { Cloudinary::Static::METADATA_FILE = "spec/sample_asset_file.tsv"}
|
179
|
-
Cloudinary::Static.reset_metadata
|
180
|
-
expect(helper.image_path('/images/foo.jpg'))
|
181
|
-
.to eq("/images/foo.jpg")
|
182
|
-
expect(helper.image_path('some-folder/foo.gif')).to eq("/images/some-folder/foo.gif")
|
183
|
-
Cloudinary.config.static_image_support = true
|
184
|
-
expect(helper.image_path('/images/foo.jpg')).to eq("http://res.cloudinary.com/sdk-test/image/asset/images-foo.jpg")
|
185
|
-
expect(helper.image_path('foo.jpg')).to eq("http://res.cloudinary.com/sdk-test/image/asset/images-foo.jpg")
|
186
|
-
expect(helper.image_path('some-folder/foo.gif')).to eq('/images/some-folder/foo.gif')
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
data/spec/cloudinary_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'cloudinary'
|
3
|
-
|
4
|
-
describe Cloudinary do
|
5
|
-
before :all do
|
6
|
-
@user_platform = Cloudinary.user_platform
|
7
|
-
end
|
8
|
-
after :all do
|
9
|
-
Cloudinary.user_platform = @user_platform
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should add a user platform to USER_AGENT' do
|
13
|
-
Cloudinary.user_platform = "Spec/1.0 (Test)"
|
14
|
-
expect(Cloudinary.USER_AGENT).to match( %r"Spec\/1.0 \(Test\) CloudinaryRuby/[\d.]+")
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'config' do
|
19
|
-
before do
|
20
|
-
@url_backup = ENV["CLOUDINARY_URL"]
|
21
|
-
end
|
22
|
-
after do
|
23
|
-
ENV["CLOUDINARY_URL"] = @url_backup
|
24
|
-
Cloudinary::config_from_url @url_backup
|
25
|
-
end
|
26
|
-
it "should allow nested values in CLOUDINARY_URL" do
|
27
|
-
ENV["CLOUDINARY_URL"] = "cloudinary://key:secret@test123?foo[bar]=value"
|
28
|
-
Cloudinary::config_from_url ENV["CLOUDINARY_URL"]
|
29
|
-
expect(Cloudinary::config.foo.bar).to eq 'value'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
coffeescript = true
|
@@ -1 +0,0 @@
|
|
1
|
-
{ alert("I am javascript!");}
|
data/spec/docx.docx
DELETED
Binary file
|