resizing 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/resizing.rb +8 -1
- data/lib/resizing/version.rb +1 -1
- data/test/data/images/empty_file.jpg +0 -0
- data/test/resizing/client_test.rb +30 -0
- data/test/vcr/client/error.yml +52 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 447b0dda55d606eec4ec8133edd826cd206719ebe44c839c6a2628092ff8eaca
|
4
|
+
data.tar.gz: 8bb995ba29217cd573fc1eeaec86aad1a0f999513aa89cb598eec8ea168a5ef0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d899143122b31fc588b6c721f1fd889edf203a43de5b09a2e0164dd3a075d92b3fb3936f7d0e0c154b6c994dddc748e190c2e7ab8327690aed1b31a96bc886c
|
7
|
+
data.tar.gz: a621e2b3c388c3d9b6cea438589f2fe4474465ca6fe78aa4e97977c10857da4ef48c89883690c3db4b782b8b58871fa1fa37e8ff69bc8ce67f05b84cb95d80ec
|
data/lib/resizing.rb
CHANGED
@@ -14,7 +14,14 @@ module Resizing
|
|
14
14
|
class Error < StandardError; end
|
15
15
|
class ConfigurationError < Error; end
|
16
16
|
class APIError < Error;
|
17
|
-
|
17
|
+
def decoded_body
|
18
|
+
@decoded_body ||= {}
|
19
|
+
end
|
20
|
+
|
21
|
+
def decoded_body=(value)
|
22
|
+
raise ArgumentError, 'The decoded_body is expected to be passed a Hash.' unless value.is_a? Hash
|
23
|
+
@decoded_body = value
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def self.configure
|
data/lib/resizing/version.rb
CHANGED
File without changes
|
@@ -75,6 +75,36 @@ module Resizing
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
+
def test_raise_error
|
79
|
+
Resizing.configure = @configuration_template
|
80
|
+
|
81
|
+
client = Resizing::Client.new
|
82
|
+
VCR.use_cassette 'client/error', record: :once do
|
83
|
+
f = File.open('test/data/images/empty_file.jpg', 'r')
|
84
|
+
assert_raises Resizing::APIError do
|
85
|
+
client.post(f, content_type: 'image/jpeg')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_handleable_response_body_from_resizing
|
91
|
+
Resizing.configure = @configuration_template
|
92
|
+
|
93
|
+
client = Resizing::Client.new
|
94
|
+
VCR.use_cassette 'client/error', record: :once do
|
95
|
+
f = File.open('test/data/images/empty_file.jpg', 'r')
|
96
|
+
|
97
|
+
response = nil
|
98
|
+
|
99
|
+
begin
|
100
|
+
client.post(f, content_type: 'image/jpeg')
|
101
|
+
rescue Resizing::APIError => e
|
102
|
+
response = e.decoded_body
|
103
|
+
end
|
104
|
+
assert_equal response, {"error"=>"Magick::ImageMagickError", "message"=>"invalid image format found"}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
78
108
|
def test_get_the_metadata
|
79
109
|
# TODO
|
80
110
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://192.168.56.101:5000/projects/e06e710d-f026-4dcf-b2c0-eab0de8bb83f/upload/images/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "-------------RubyMultipartPost-877f1391fb4284d764ae71084ad0d7f4\r\nContent-Disposition:
|
9
|
+
form-data; name=\"image\"; filename=\"empty_file.jpg\"\r\nContent-Length:
|
10
|
+
0\r\nContent-Type: image/jpeg\r\nContent-Transfer-Encoding: binary\r\n\r\n\r\n-------------RubyMultipartPost-877f1391fb4284d764ae71084ad0d7f4--\r\n"
|
11
|
+
headers:
|
12
|
+
User-Agent:
|
13
|
+
- Faraday v1.0.1
|
14
|
+
X-ResizingToken:
|
15
|
+
- v1,1607654898,be14774d9217431dc1dc6dd761b396c3b7458a8fcf7354fbd97198ee33907d56
|
16
|
+
Content-Type:
|
17
|
+
- multipart/form-data; boundary=-----------RubyMultipartPost-877f1391fb4284d764ae71084ad0d7f4
|
18
|
+
Content-Length:
|
19
|
+
- '289'
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 415
|
23
|
+
message: Unsupported Media Type
|
24
|
+
headers:
|
25
|
+
x-frame-options:
|
26
|
+
- SAMEORIGIN
|
27
|
+
x-xss-protection:
|
28
|
+
- 1; mode=block
|
29
|
+
x-content-type-options:
|
30
|
+
- nosniff
|
31
|
+
x-download-options:
|
32
|
+
- noopen
|
33
|
+
x-permitted-cross-domain-policies:
|
34
|
+
- none
|
35
|
+
referrer-policy:
|
36
|
+
- strict-origin-when-cross-origin
|
37
|
+
content-type:
|
38
|
+
- application/json; charset=utf-8
|
39
|
+
cache-control:
|
40
|
+
- no-cache
|
41
|
+
x-request-id:
|
42
|
+
- c3cd6487-4df0-4a41-ad8e-db67b7a9d2dd
|
43
|
+
x-runtime:
|
44
|
+
- '0.206168'
|
45
|
+
transfer-encoding:
|
46
|
+
- chunked
|
47
|
+
body:
|
48
|
+
encoding: UTF-8
|
49
|
+
string: '{"error":"Magick::ImageMagickError","message":"invalid image format
|
50
|
+
found"}'
|
51
|
+
recorded_at: Fri, 11 Dec 2020 02:48:18 GMT
|
52
|
+
recorded_with: VCR 6.0.0
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resizing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Junichiro Kasuya
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/resizing/public_id.rb
|
209
209
|
- lib/resizing/version.rb
|
210
210
|
- resizing.gemspec
|
211
|
+
- test/data/images/empty_file.jpg
|
211
212
|
- test/data/images/sample1.jpg
|
212
213
|
- test/resizing/carrier_wave/storage/file_test.rb
|
213
214
|
- test/resizing/carrier_wave/storage/remote_test.rb
|
@@ -220,6 +221,7 @@ files:
|
|
220
221
|
- test/vcr/carrier_wave_test/remove_resizing_picture.yml
|
221
222
|
- test/vcr/carrier_wave_test/save.yml
|
222
223
|
- test/vcr/client/delete.yml
|
224
|
+
- test/vcr/client/error.yml
|
223
225
|
- test/vcr/client/metadata.yml
|
224
226
|
- test/vcr/client/post.yml
|
225
227
|
- test/vcr/client/put.yml
|