ruby-thumbor 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-thumbor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bernardo Heynemann
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-07 00:00:00.000000000 Z
12
+ date: 2019-01-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -39,48 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: guard-rspec
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
- - !ruby/object:Gem::Dependency
57
- name: rb-fsevent
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: 0.9.1
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: 0.9.1
70
- - !ruby/object:Gem::Dependency
71
- name: listen
72
- requirement: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: 1.3.1
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: 1.3.1
84
42
  - !ruby/object:Gem::Dependency
85
43
  name: rake
86
44
  requirement: !ruby/object:Gem::Requirement
@@ -96,7 +54,7 @@ dependencies:
96
54
  - !ruby/object:Gem::Version
97
55
  version: '0'
98
56
  - !ruby/object:Gem::Dependency
99
- name: coveralls
57
+ name: rspec_junit_formatter
100
58
  requirement: !ruby/object:Gem::Requirement
101
59
  requirements:
102
60
  - - ">="
@@ -109,21 +67,7 @@ dependencies:
109
67
  - - ">="
110
68
  - !ruby/object:Gem::Version
111
69
  version: '0'
112
- - !ruby/object:Gem::Dependency
113
- name: tins
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "<"
117
- - !ruby/object:Gem::Version
118
- version: 1.7.0
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "<"
124
- - !ruby/object:Gem::Version
125
- version: 1.7.0
126
- description: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
70
+ description: ruby-thumbor is the client to the thumbor imaging service (http://github.com/thumbor/thumbor).
127
71
  email:
128
72
  - heynemann@gmail.com
129
73
  - guivideojob@gmail.com
@@ -138,9 +82,7 @@ files:
138
82
  - lib/thumbor/version.rb
139
83
  - spec/spec_helper.rb
140
84
  - spec/thumbor/cascade_spec.rb
141
- - spec/thumbor/crypto_url_spec.rb
142
- - spec/util/thumbor.rb
143
- homepage: http://github.com/heynemann/ruby-thumbor
85
+ homepage: http://github.com/thumbor/ruby-thumbor
144
86
  licenses: []
145
87
  metadata: {}
146
88
  post_install_message:
@@ -161,12 +103,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
161
103
  version: '0'
162
104
  requirements: []
163
105
  rubyforge_project:
164
- rubygems_version: 2.4.3
106
+ rubygems_version: 2.7.6
165
107
  signing_key:
166
108
  specification_version: 4
167
- summary: ruby-thumbor is the client to the thumbor imaging service (http://github.com/globocom/thumbor).
109
+ summary: ruby-thumbor is the client to the thumbor imaging service (http://github.com/thumbor/thumbor).
168
110
  test_files:
169
111
  - spec/spec_helper.rb
170
112
  - spec/thumbor/cascade_spec.rb
171
- - spec/thumbor/crypto_url_spec.rb
172
- - spec/util/thumbor.rb
@@ -1,482 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
- require 'ruby-thumbor'
4
- require 'util/thumbor'
5
-
6
- image_url = 'my.domain.com/some/image/url.jpg'
7
- image_md5 = 'f33af67e41168e80fcc5b00f8bd8061a'
8
- key = 'my-security-key'
9
-
10
- describe Thumbor::CryptoURL do
11
- subject { Thumbor::CryptoURL.new key }
12
-
13
- describe '#new' do
14
- it "should create a new instance passing key and keep it" do
15
- expect(subject.computed_key).to eq('my-security-keym')
16
- end
17
- end
18
-
19
- describe '#url_for' do
20
-
21
- it "should return just the image hash if no arguments passed" do
22
- url = subject.url_for :image => image_url
23
- expect(url).to eq(image_md5)
24
- end
25
-
26
- it "should raise if no image passed" do
27
- expect { subject.url_for Hash.new }.to raise_error(RuntimeError)
28
- end
29
-
30
- it "should return proper url for width-only" do
31
- url = subject.url_for :image => image_url, :width => 300
32
- expect(url).to eq('300x0/' << image_md5)
33
- end
34
-
35
- it "should return proper url for height-only" do
36
- url = subject.url_for :image => image_url, :height => 300
37
- expect(url).to eq('0x300/' << image_md5)
38
- end
39
-
40
- it "should return proper url for width and height" do
41
- url = subject.url_for :image => image_url, :width => 200, :height => 300
42
- expect(url).to eq('200x300/' << image_md5)
43
- end
44
-
45
- it "should return proper smart url" do
46
- url = subject.url_for :image => image_url, :width => 200, :height => 300, :smart => true
47
- expect(url).to eq('200x300/smart/' << image_md5)
48
- end
49
-
50
- it "should return proper fit-in url" do
51
- url = subject.url_for :image => image_url, :width => 200, :height => 300, :fit_in => true
52
- expect(url).to eq('fit-in/200x300/' << image_md5)
53
- end
54
-
55
- it "should return proper flip url if no width and height" do
56
- url = subject.url_for :image => image_url, :flip => true
57
- expect(url).to eq('-0x0/' << image_md5)
58
- end
59
-
60
- it "should return proper flop url if no width and height" do
61
- url = subject.url_for :image => image_url, :flop => true
62
- expect(url).to eq('0x-0/' << image_md5)
63
- end
64
-
65
- it "should return proper flip-flop url if no width and height" do
66
- url = subject.url_for :image => image_url, :flip => true, :flop => true
67
- expect(url).to eq('-0x-0/' << image_md5)
68
- end
69
-
70
- it "should return proper flip url if width" do
71
- url = subject.url_for :image => image_url, :width => 300, :flip => true
72
- expect(url).to eq('-300x0/' << image_md5)
73
- end
74
-
75
- it "should return proper flop url if height" do
76
- url = subject.url_for :image => image_url, :height => 300, :flop => true
77
- expect(url).to eq('0x-300/' << image_md5)
78
- end
79
-
80
- it "should return horizontal align" do
81
- url = subject.url_for :image => image_url, :halign => :left
82
- expect(url).to eq('left/' << image_md5)
83
- end
84
-
85
- it "should not return horizontal align if it is center" do
86
- url = subject.url_for :image => image_url, :halign => :center
87
- expect(url).to eq(image_md5)
88
- end
89
-
90
- it "should return vertical align" do
91
- url = subject.url_for :image => image_url, :valign => :top
92
- expect(url).to eq('top/' << image_md5)
93
- end
94
-
95
- it "should not return vertical align if it is middle" do
96
- url = subject.url_for :image => image_url, :valign => :middle
97
- expect(url).to eq(image_md5)
98
- end
99
-
100
- it "should return halign and valign properly" do
101
- url = subject.url_for :image => image_url, :halign => :left, :valign => :top
102
- expect(url).to eq('left/top/' << image_md5)
103
- end
104
-
105
- it "should return meta properly" do
106
- url = subject.url_for :image => image_url, :meta => true
107
- expect(url).to eq('meta/' << image_md5)
108
- end
109
-
110
- it "should return proper crop url" do
111
- url = subject.url_for :image => image_url, :crop => [10, 20, 30, 40]
112
- expect(url).to eq('10x20:30x40/' << image_md5)
113
- end
114
-
115
- it "should ignore crop if all zeros" do
116
- url = subject.url_for :image => image_url, :crop => [0, 0, 0, 0]
117
- expect(url).to eq(image_md5)
118
- end
119
-
120
- it "should have smart after halign and valign" do
121
- url = subject.url_for :image => image_url, :halign => :left, :valign => :top, :smart => true
122
- expect(url).to eq('left/top/smart/' << image_md5)
123
- end
124
-
125
- it "should ignore filters if empty" do
126
- url = subject.url_for :image => image_url, :filters => []
127
- expect(url).to eq(image_md5)
128
- end
129
-
130
- it "should have trim without params" do
131
- url = subject.url_for :image => image_url, :trim => true
132
- expect(url).to eq('trim/' << image_md5)
133
- end
134
-
135
- it "should have trim with direction param" do
136
- url = subject.url_for :image => image_url, :trim => ['bottom-right']
137
- expect(url).to eq('trim:bottom-right/' << image_md5)
138
- end
139
-
140
- it "should have trim with direction and tolerance param" do
141
- url = subject.url_for :image => image_url, :trim => ['bottom-right', 15]
142
- expect(url).to eq('trim:bottom-right:15/' << image_md5)
143
- end
144
-
145
- it "should have the trim option as the first one" do
146
- url = subject.url_for :image => image_url, :smart => true, :trim => true
147
-
148
- expect(url).to eq('trim/smart/f33af67e41168e80fcc5b00f8bd8061a')
149
- end
150
-
151
-
152
- it "should have the right crop when cropping horizontally and given a left center" do
153
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [0, 50]
154
- expect(url).to eq('0x0:80x100/40x50/' << image_md5)
155
- end
156
-
157
- it "should have the right crop when cropping horizontally and given a right center" do
158
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [100, 50]
159
- expect(url).to eq('20x0:100x100/40x50/' << image_md5)
160
- end
161
-
162
- it "should have the right crop when cropping horizontally and given the actual center" do
163
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 40, :height => 50, :center => [50, 50]
164
- expect(url).to eq('10x0:90x100/40x50/' << image_md5)
165
- end
166
-
167
- it "should have the right crop when cropping vertically and given a top center" do
168
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 0]
169
- expect(url).to eq('0x0:100x80/50x40/' << image_md5)
170
- end
171
-
172
- it "should have the right crop when cropping vertically and given a bottom center" do
173
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 100]
174
- expect(url).to eq('0x20:100x100/50x40/' << image_md5)
175
- end
176
-
177
- it "should have the right crop when cropping vertically and given the actual center" do
178
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => [50, 50]
179
- expect(url).to eq('0x10:100x90/50x40/' << image_md5)
180
- end
181
-
182
- it "should have the no crop when not necessary" do
183
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 50, :center => [50, 0]
184
- expect(url).to eq('50x50/' << image_md5)
185
- end
186
-
187
- it "should blow up with a bad center" do
188
- expect { subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => 40, :center => 50 }.to raise_error(RuntimeError)
189
- end
190
-
191
- it "should have no crop with a missing original_height" do
192
- url = subject.url_for :image => image_url, :original_width => 100, :width => 50, :height => 40, :center => [50, 50]
193
- expect(url).to eq('50x40/' << image_md5)
194
- end
195
-
196
- it "should have no crop with a missing original_width" do
197
- url = subject.url_for :image => image_url, :original_height => 100, :width => 50, :height => 40, :center => [50, 50]
198
- expect(url).to eq('50x40/' << image_md5)
199
- end
200
-
201
- it "should have no crop with out a width and height" do
202
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :center => [50, 50]
203
- expect(url).to eq(image_md5)
204
- end
205
-
206
- it "should use the original width with a missing width" do
207
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :height => 80, :center => [50, 50]
208
- expect(url).to eq('0x10:100x90/0x80/' << image_md5)
209
- end
210
-
211
- it "should use the original height with a missing height" do
212
- url = subject.url_for :image => image_url,:original_width => 100, :original_height => 100, :width => 80, :center => [50, 50]
213
- expect(url).to eq('10x0:90x100/80x0/' << image_md5)
214
- end
215
-
216
- it "should have the right crop with a negative width" do
217
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => -50, :height => 40, :center => [50, 50]
218
- expect(url).to eq('0x10:100x90/-50x40/' << image_md5)
219
- end
220
-
221
- it "should have the right crop with a negative height" do
222
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => 50, :height => -40, :center => [50, 50]
223
- expect(url).to eq('0x10:100x90/50x-40/' << image_md5)
224
- end
225
-
226
- it "should have the right crop with a negative height and width" do
227
- url = subject.url_for :image => image_url, :original_width => 100, :original_height => 100, :width => -50, :height => -40, :center => [50, 50]
228
- expect(url).to eq('0x10:100x90/-50x-40/' << image_md5)
229
- end
230
-
231
- it "should handle string values" do
232
- url = subject.url_for :image => image_url, :width => '40', :height => '50'
233
- expect(url).to eq('40x50/' << image_md5)
234
- end
235
-
236
- it "should never mutate its arguments" do
237
- opts = {:image => image_url, :width => '500'}
238
- subject.url_for opts
239
- expect(opts).to eq({:image => image_url, :width => '500'})
240
- end
241
- end
242
-
243
- describe '#generate' do
244
- it "should generate a proper url when only an image url is specified" do
245
- url = subject.generate :image => image_url
246
-
247
- expect(url).to eq("/964rCTkAEDtvjy_a572k7kRa0SU=/#{image_url}")
248
- end
249
-
250
- it "should create a new instance passing key and keep it" do
251
- url = subject.generate :width => 300, :height => 200, :image => image_url
252
-
253
- expect(url).to eq('/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg')
254
- end
255
-
256
- it "should create a new instance passing key and keep it" do
257
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url
258
-
259
- expect(url).to eq('/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg')
260
- end
261
-
262
- it "should create a new instance passing key and keep it" do
263
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true
264
-
265
- expect(url).to eq('/jP89J0qOWHgPlm_lOA28GtOh5GU=/meta/300x200/smart/my.domain.com/some/image/url.jpg')
266
- end
267
-
268
- it "should create a new instance passing key and keep it" do
269
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true
270
-
271
- expect(url).to eq('/zrrOh_TtTs4kiLLEQq1w4bcTYdc=/meta/fit-in/300x200/smart/my.domain.com/some/image/url.jpg')
272
- end
273
-
274
- it "should create a new instance passing key and keep it" do
275
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true, :flip => true
276
-
277
- expect(url).to eq('/4t1XK1KH43cOb1QJ9tU00-W2_k8=/meta/fit-in/-300x200/smart/my.domain.com/some/image/url.jpg')
278
- end
279
-
280
- it "should create a new instance passing key and keep it" do
281
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :fit_in => true, :flip => true, :flop => true
282
-
283
- expect(url).to eq('/HJnvjZU69PkPOhyZGu-Z3Uc_W_A=/meta/fit-in/-300x-200/smart/my.domain.com/some/image/url.jpg')
284
- end
285
-
286
- it "should create a new instance passing key and keep it" do
287
- url = subject.generate :filters => ["quality(20)", "brightness(10)"], :image => image_url
288
-
289
- expect(url).to eq('/q0DiFg-5-eFZIqyN3lRoCvg2K0s=/filters:quality(20):brightness(10)/my.domain.com/some/image/url.jpg')
290
- end
291
- end
292
-
293
- describe "#generate :old => true" do
294
-
295
- it "should create a new instance passing key and keep it" do
296
- url = subject.generate :width => 300, :height => 200, :image => image_url, :old => true
297
-
298
- expect(url).to eq('/qkLDiIbvtiks0Up9n5PACtmpOfX6dPXw4vP4kJU-jTfyF6y1GJBJyp7CHYh1H3R2/' << image_url)
299
- end
300
-
301
- it "should allow thumbor to decrypt it properly" do
302
- url = subject.generate :width => 300, :height => 200, :image => image_url, :old => true
303
-
304
- encrypted = url.split('/')[1]
305
-
306
- decrypted = decrypt_in_thumbor(encrypted)
307
-
308
- expect(decrypted["horizontal_flip"]).to be_falsy
309
- expect(decrypted["vertical_flip"]).to be_falsy
310
- expect(decrypted["smart"]).to be_falsy
311
- expect(decrypted["meta"]).to be_falsy
312
- expect(decrypted["fit_in"]).to be_falsy
313
- expect(decrypted["crop"]["left"]).to eq(0)
314
- expect(decrypted["crop"]["top"]).to eq(0)
315
- expect(decrypted["crop"]["right"]).to eq(0)
316
- expect(decrypted["crop"]["bottom"]).to eq(0)
317
- expect(decrypted["valign"]).to eq('middle')
318
- expect(decrypted["halign"]).to eq('center')
319
- expect(decrypted["image_hash"]).to eq(image_md5)
320
- expect(decrypted["width"]).to eq(300)
321
- expect(decrypted["height"]).to eq(200)
322
-
323
- end
324
-
325
- it "should allow thumbor to decrypt it properly with meta" do
326
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :old => true
327
-
328
- encrypted = url.split('/')[1]
329
-
330
- decrypted = decrypt_in_thumbor(encrypted)
331
-
332
- expect(decrypted["meta"]).to be_truthy
333
- expect(decrypted["image_hash"]).to eq(image_md5)
334
- expect(decrypted["width"]).to eq(300)
335
- expect(decrypted["height"]).to eq(200)
336
-
337
- end
338
-
339
- it "should allow thumbor to decrypt it properly with smart" do
340
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :old => true
341
-
342
- encrypted = url.split('/')[1]
343
-
344
- decrypted = decrypt_in_thumbor(encrypted)
345
-
346
- expect(decrypted["meta"]).to be_truthy
347
- expect(decrypted["smart"]).to be_truthy
348
- expect(decrypted["image_hash"]).to eq(image_md5)
349
- expect(decrypted["width"]).to eq(300)
350
- expect(decrypted["height"]).to eq(200)
351
-
352
- end
353
-
354
- it "should allow thumbor to decrypt it properly with fit-in" do
355
- url = subject.generate :width => 300, :height => 200, :fit_in => true, :image => image_url, :old => true
356
-
357
- encrypted = url.split('/')[1]
358
-
359
- decrypted = decrypt_in_thumbor(encrypted)
360
-
361
- expect(decrypted["fit_in"]).to be_truthy
362
- expect(decrypted["image_hash"]).to eq(image_md5)
363
- expect(decrypted["width"]).to eq(300)
364
- expect(decrypted["height"]).to eq(200)
365
-
366
- end
367
-
368
- it "should allow thumbor to decrypt it properly with flip" do
369
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :flip => true, :old => true
370
-
371
- encrypted = url.split('/')[1]
372
-
373
- decrypted = decrypt_in_thumbor(encrypted)
374
-
375
- expect(decrypted["meta"]).to be_truthy
376
- expect(decrypted["smart"]).to be_truthy
377
- expect(decrypted["image_hash"]).to eq(image_md5)
378
- expect(decrypted["width"]).to eq(300)
379
- expect(decrypted["height"]).to eq(200)
380
- decrypted["flip_horizontally"] == true
381
-
382
- end
383
-
384
- it "should allow thumbor to decrypt it properly with flop" do
385
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :flip => true, :flop => true, :old => true
386
-
387
- encrypted = url.split('/')[1]
388
-
389
- decrypted = decrypt_in_thumbor(encrypted)
390
-
391
- expect(decrypted["meta"]).to be_truthy
392
- expect(decrypted["smart"]).to be_truthy
393
- expect(decrypted["image_hash"]).to eq(image_md5)
394
- expect(decrypted["width"]).to eq(300)
395
- expect(decrypted["height"]).to eq(200)
396
- decrypted["flip_horizontally"] == true
397
- decrypted["flip_vertically"] == true
398
-
399
- end
400
-
401
- it "should allow thumbor to decrypt it properly with halign" do
402
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :flip => true, :flop => true,
403
- :halign => :left, :old => true
404
-
405
- encrypted = url.split('/')[1]
406
-
407
- decrypted = decrypt_in_thumbor(encrypted)
408
-
409
- expect(decrypted["meta"]).to be_truthy
410
- expect(decrypted["smart"]).to be_truthy
411
- expect(decrypted["image_hash"]).to eq(image_md5)
412
- expect(decrypted["width"]).to eq(300)
413
- expect(decrypted["height"]).to eq(200)
414
- decrypted["flip_horizontally"] == true
415
- decrypted["flip_vertically"] == true
416
- decrypted["halign"] == "left"
417
-
418
- end
419
-
420
- it "should allow thumbor to decrypt it properly with valign" do
421
- url = subject.generate :width => 300, :height => 200, :meta => true, :image => image_url, :smart => true, :flip => true, :flop => true,
422
- :halign => :left, :valign => :top, :old => true
423
-
424
- encrypted = url.split('/')[1]
425
-
426
- decrypted = decrypt_in_thumbor(encrypted)
427
-
428
- expect(decrypted["meta"]).to be_truthy
429
- expect(decrypted["smart"]).to be_truthy
430
- expect(decrypted["image_hash"]).to eq(image_md5)
431
- expect(decrypted["width"]).to eq(300)
432
- expect(decrypted["height"]).to eq(200)
433
- decrypted["flip_horizontally"] == true
434
- decrypted["flip_vertically"] == true
435
- decrypted["halign"] == "left"
436
- decrypted["valign"] == "top"
437
-
438
- end
439
-
440
- it "should allow thumbor to decrypt it properly with cropping" do
441
- url = subject.generate :width => 300, :height => 200, :image => image_url, :crop => [10, 20, 30, 40], :old => true
442
-
443
- encrypted = url.split('/')[1]
444
-
445
- decrypted = decrypt_in_thumbor(encrypted)
446
-
447
- expect(decrypted["horizontal_flip"]).to be_falsy
448
- expect(decrypted["vertical_flip"]).to be_falsy
449
- expect(decrypted["smart"]).to be_falsy
450
- expect(decrypted["meta"]).to be_falsy
451
- expect(decrypted["crop"]["left"]).to eq(10)
452
- expect(decrypted["crop"]["top"]).to eq(20)
453
- expect(decrypted["crop"]["right"]).to eq(30)
454
- expect(decrypted["crop"]["bottom"]).to eq(40)
455
- expect(decrypted["valign"]).to eq('middle')
456
- expect(decrypted["halign"]).to eq('center')
457
- expect(decrypted["image_hash"]).to eq(image_md5)
458
- expect(decrypted["width"]).to eq(300)
459
- expect(decrypted["height"]).to eq(200)
460
-
461
- end
462
-
463
- it "should allow thumbor to decrypt it properly with filters" do
464
- url = subject.generate :filters => ["quality(20)", "brightness(10)"], :image => image_url, :old => true
465
-
466
- encrypted = url.split('/')[1]
467
-
468
- decrypted = decrypt_in_thumbor(encrypted)
469
-
470
- expect(decrypted["filters"]).to eq("quality(20):brightness(10)")
471
- end
472
- end
473
-
474
- describe "without security key" do
475
- subject { Thumbor::CryptoURL.new nil }
476
- it "should generate a unsafe url" do
477
- url = subject.generate :image => image_url
478
-
479
- expect(url).to eq("/unsafe/#{image_url}")
480
- end
481
- end
482
- end