resizing 0.4.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04cca28d70c6c4c7a361ae5714aadb8e0983a77827b7099ca3dcb18d60e41052
4
- data.tar.gz: 653e75727cbeb23d3b9f799b9547df92010410b7f409d671bfaea529325060db
3
+ metadata.gz: 447b0dda55d606eec4ec8133edd826cd206719ebe44c839c6a2628092ff8eaca
4
+ data.tar.gz: 8bb995ba29217cd573fc1eeaec86aad1a0f999513aa89cb598eec8ea168a5ef0
5
5
  SHA512:
6
- metadata.gz: 9f6395295e817926af6f50fdf66817c97beac4b9e4efbd9ffede1cfb597567ca43a56615a777ae333a96e841aac62f20b4804918f542dc8cf42a57c59c8e8433
7
- data.tar.gz: b7368beeae3086929f303100059122f9310e18b9bbe6c2503d5d8cb11994272d5e95e480870a4a6a513162db5a87a247ccc785d1dec21dac731bd462ce7881c2
6
+ metadata.gz: 9d899143122b31fc588b6c721f1fd889edf203a43de5b09a2e0164dd3a075d92b3fb3936f7d0e0c154b6c994dddc748e190c2e7ab8327690aed1b31a96bc886c
7
+ data.tar.gz: a621e2b3c388c3d9b6cea438589f2fe4474465ca6fe78aa4e97977c10857da4ef48c89883690c3db4b782b8b58871fa1fa37e8ff69bc8ce67f05b84cb95d80ec
@@ -0,0 +1,149 @@
1
+ # Changelog
2
+
3
+ ## [v0.5.3](https://github.com/jksy/resizing-gem/tree/v0.5.3) (2020-10-15)
4
+
5
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.5.2...v0.5.3)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Feature/fix raise error [\#40](https://github.com/jksy/resizing-gem/pull/40) ([jksy](https://github.com/jksy))
10
+
11
+ ## [v0.5.2](https://github.com/jksy/resizing-gem/tree/v0.5.2) (2020-10-11)
12
+
13
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.5.1...v0.5.2)
14
+
15
+ ## [v0.5.1](https://github.com/jksy/resizing-gem/tree/v0.5.1) (2020-10-11)
16
+
17
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.5.0...v0.5.1)
18
+
19
+ ## [v0.5.0](https://github.com/jksy/resizing-gem/tree/v0.5.0) (2020-10-11)
20
+
21
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.4.2...v0.5.0)
22
+
23
+ ## [v0.4.2](https://github.com/jksy/resizing-gem/tree/v0.4.2) (2020-10-01)
24
+
25
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.4.1...v0.4.2)
26
+
27
+ **Merged pull requests:**
28
+
29
+ - fix raise error if tempfile is assinged [\#38](https://github.com/jksy/resizing-gem/pull/38) ([jksy](https://github.com/jksy))
30
+
31
+ ## [v0.4.1](https://github.com/jksy/resizing-gem/tree/v0.4.1) (2020-10-01)
32
+
33
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.2.1...v0.4.1)
34
+
35
+ **Closed issues:**
36
+
37
+ - pass original filename into Resizing [\#36](https://github.com/jksy/resizing-gem/issues/36)
38
+ - columnがnilの時はdefault\_urlを返す [\#33](https://github.com/jksy/resizing-gem/issues/33)
39
+
40
+ **Merged pull requests:**
41
+
42
+ - save original filename [\#37](https://github.com/jksy/resizing-gem/pull/37) ([jksy](https://github.com/jksy))
43
+ - columnがnilの時はdefault\_urlを返す \#33 [\#34](https://github.com/jksy/resizing-gem/pull/34) ([jksy](https://github.com/jksy))
44
+
45
+ ## [v0.2.1](https://github.com/jksy/resizing-gem/tree/v0.2.1) (2020-09-29)
46
+
47
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.4.0...v0.2.1)
48
+
49
+ ## [v0.4.0](https://github.com/jksy/resizing-gem/tree/v0.4.0) (2020-09-28)
50
+
51
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.3.2...v0.4.0)
52
+
53
+ **Merged pull requests:**
54
+
55
+ - change version string when put request with mockclient [\#32](https://github.com/jksy/resizing-gem/pull/32) ([jksy](https://github.com/jksy))
56
+ - add delete method [\#31](https://github.com/jksy/resizing-gem/pull/31) ([jksy](https://github.com/jksy))
57
+ - Feature/add identifier to public [\#30](https://github.com/jksy/resizing-gem/pull/30) ([jksy](https://github.com/jksy))
58
+ - add identifier [\#29](https://github.com/jksy/resizing-gem/pull/29) ([jksy](https://github.com/jksy))
59
+ - Feature/refactor public [\#28](https://github.com/jksy/resizing-gem/pull/28) ([jksy](https://github.com/jksy))
60
+ - divide to PublicId class [\#27](https://github.com/jksy/resizing-gem/pull/27) ([jksy](https://github.com/jksy))
61
+ - fix some bug & errors [\#26](https://github.com/jksy/resizing-gem/pull/26) ([jksy](https://github.com/jksy))
62
+ - fix mockclient [\#25](https://github.com/jksy/resizing-gem/pull/25) ([jksy](https://github.com/jksy))
63
+ - fix raise no method presented, no cotent type is presented [\#24](https://github.com/jksy/resizing-gem/pull/24) ([jksy](https://github.com/jksy))
64
+
65
+ ## [v0.3.2](https://github.com/jksy/resizing-gem/tree/v0.3.2) (2020-09-11)
66
+
67
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.3.1...v0.3.2)
68
+
69
+ **Merged pull requests:**
70
+
71
+ - fix raise error when call remove! with nil column [\#23](https://github.com/jksy/resizing-gem/pull/23) ([jksy](https://github.com/jksy))
72
+
73
+ ## [v0.3.1](https://github.com/jksy/resizing-gem/tree/v0.3.1) (2020-09-11)
74
+
75
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.3.0...v0.3.1)
76
+
77
+ ## [v0.3.0](https://github.com/jksy/resizing-gem/tree/v0.3.0) (2020-08-21)
78
+
79
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.2.0...v0.3.0)
80
+
81
+ **Merged pull requests:**
82
+
83
+ - Feature/fix mock client [\#22](https://github.com/jksy/resizing-gem/pull/22) ([jksy](https://github.com/jksy))
84
+
85
+ ## [v0.2.0](https://github.com/jksy/resizing-gem/tree/v0.2.0) (2020-08-12)
86
+
87
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.1.4...v0.2.0)
88
+
89
+ **Merged pull requests:**
90
+
91
+ - version 0.2.0 [\#21](https://github.com/jksy/resizing-gem/pull/21) ([jksy](https://github.com/jksy))
92
+ - support f\_auto, q\_auto parameter [\#20](https://github.com/jksy/resizing-gem/pull/20) ([jksy](https://github.com/jksy))
93
+
94
+ ## [v0.1.4](https://github.com/jksy/resizing-gem/tree/v0.1.4) (2020-08-08)
95
+
96
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.1.3...v0.1.4)
97
+
98
+ **Merged pull requests:**
99
+
100
+ - Feature/update gems and change default hostname [\#19](https://github.com/jksy/resizing-gem/pull/19) ([jksy](https://github.com/jksy))
101
+
102
+ ## [v0.1.3](https://github.com/jksy/resizing-gem/tree/v0.1.3) (2020-06-12)
103
+
104
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.1.2...v0.1.3)
105
+
106
+ **Merged pull requests:**
107
+
108
+ - fix error when record is not found [\#18](https://github.com/jksy/resizing-gem/pull/18) ([jksy](https://github.com/jksy))
109
+
110
+ ## [v0.1.2](https://github.com/jksy/resizing-gem/tree/v0.1.2) (2020-06-12)
111
+
112
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.1.1...v0.1.2)
113
+
114
+ **Merged pull requests:**
115
+
116
+ - ignore response if delete method is received 404 status code [\#17](https://github.com/jksy/resizing-gem/pull/17) ([jksy](https://github.com/jksy))
117
+
118
+ ## [v0.1.1](https://github.com/jksy/resizing-gem/tree/v0.1.1) (2020-06-12)
119
+
120
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/v0.1.0...v0.1.1)
121
+
122
+ **Merged pull requests:**
123
+
124
+ - Feature/fix raise error [\#16](https://github.com/jksy/resizing-gem/pull/16) ([jksy](https://github.com/jksy))
125
+ - change mysql port on docker-compose [\#9](https://github.com/jksy/resizing-gem/pull/9) ([jksy](https://github.com/jksy))
126
+
127
+ ## [v0.1.0](https://github.com/jksy/resizing-gem/tree/v0.1.0) (2020-06-07)
128
+
129
+ [Full Changelog](https://github.com/jksy/resizing-gem/compare/e817d9b883425ddae3e42439ccd1a9d2e270c363...v0.1.0)
130
+
131
+ **Merged pull requests:**
132
+
133
+ - add mock client for test environments [\#14](https://github.com/jksy/resizing-gem/pull/14) ([jksy](https://github.com/jksy))
134
+ - Feature/add test test for remove xxx [\#13](https://github.com/jksy/resizing-gem/pull/13) ([jksy](https://github.com/jksy))
135
+ - add rubocop & fix some tests [\#12](https://github.com/jksy/resizing-gem/pull/12) ([jksy](https://github.com/jksy))
136
+ - fix the column cant be update by null value [\#11](https://github.com/jksy/resizing-gem/pull/11) ([jksy](https://github.com/jksy))
137
+ - fix empty url when model is reload [\#10](https://github.com/jksy/resizing-gem/pull/10) ([jksy](https://github.com/jksy))
138
+ - fix return invalid url when model is reloaded [\#8](https://github.com/jksy/resizing-gem/pull/8) ([jksy](https://github.com/jksy))
139
+ - add circleci [\#7](https://github.com/jksy/resizing-gem/pull/7) ([jksy](https://github.com/jksy))
140
+ - divide some classes and add tests [\#6](https://github.com/jksy/resizing-gem/pull/6) ([jksy](https://github.com/jksy))
141
+ - fix connect host [\#5](https://github.com/jksy/resizing-gem/pull/5) ([jksy](https://github.com/jksy))
142
+ - Feature/carrier wave [\#4](https://github.com/jksy/resizing-gem/pull/4) ([jksy](https://github.com/jksy))
143
+ - faraday version is down. and some fix bugs [\#3](https://github.com/jksy/resizing-gem/pull/3) ([jksy](https://github.com/jksy))
144
+ - Feature/add default host [\#2](https://github.com/jksy/resizing-gem/pull/2) ([jksy](https://github.com/jksy))
145
+ - first implementation [\#1](https://github.com/jksy/resizing-gem/pull/1) ([jksy](https://github.com/jksy))
146
+
147
+
148
+
149
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/bash
2
+
3
+ github_changelog_generator -u jksy -p resizing-gem
@@ -13,7 +13,16 @@ module Resizing
13
13
 
14
14
  class Error < StandardError; end
15
15
  class ConfigurationError < Error; end
16
- class APIError < Error; end
16
+ class APIError < Error;
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
25
+ end
17
26
 
18
27
  def self.configure
19
28
  raise ConfigurationError, 'Resizing.configure is not initialized' unless defined? @configure
@@ -8,6 +8,7 @@ module Resizing
8
8
 
9
9
  def initialize(uploader, identifier = nil)
10
10
  @uploader = uploader
11
+ @file = nil
11
12
  @content_type = nil
12
13
  @public_id = Resizing::PublicId.new identifier
13
14
  end
@@ -76,6 +77,11 @@ module Resizing
76
77
  !!file
77
78
  end
78
79
 
80
+ def current_path
81
+ @current_path = model.send :read_attribute, serialization_column
82
+ end
83
+ alias path current_path
84
+
79
85
  def store(new_file)
80
86
  if new_file.is_a?(self.class)
81
87
  # new_file.copy_to(path)
@@ -88,15 +94,23 @@ module Resizing
88
94
  # guess content-type from extension
89
95
  @content_type ||= MIME::Types.type_for(new_file.path).first.content_type
90
96
  end
91
- @public_id = PublicId.new(model.send :read_attribute, serialization_column)
92
97
 
93
- image_id = if @public_id.empty?
94
- Resizing.configure.generate_image_id
95
- else
96
- @public_id.image_id
97
- end
98
+ original_filename = new_file.try(:original_filename) || new_file.try(:filename) || new_file.try(:path)
99
+ if original_filename.present?
100
+ original_filename = ::File.basename(original_filename)
101
+ end
98
102
 
99
- @response = Resizing.put(image_id, new_file.read, { content_type: @content_type, filename: new_file.original_filename })
103
+ content = if new_file.respond_to?(:to_io)
104
+ new_file.to_io.tap(&:rewind)
105
+ elsif new_file.respond_to?(:read) && new_file.respond_to?(:rewind)
106
+ new_file.read.tap do
107
+ new_file.rewind
108
+ end
109
+ else
110
+ new_file
111
+ end
112
+
113
+ @response = Resizing.post(content, { content_type: @content_type, filename: original_filename })
100
114
  @public_id = Resizing::PublicId.new(@response['public_id'])
101
115
 
102
116
  # force update column
@@ -176,12 +190,6 @@ module Resizing
176
190
  parameters.count == 2 && parameters[1].include?(:options)
177
191
  end
178
192
 
179
- # def store! sanitized_file
180
- # puts sanitized_file.inspect
181
- # client = Resizing::Client.new
182
- # @store_response = client.post(sanitized_file.to_file, {content_type: sanitized_file.content_type})
183
- # end
184
-
185
193
  def retrieve!(identifier)
186
194
  raise NotImplementedError, "retrieve! #{identifier}"
187
195
  end
@@ -63,6 +63,8 @@ module Resizing
63
63
 
64
64
  result = handle_create_response(response)
65
65
  result
66
+ rescue Faraday::TimeoutError => e
67
+ handle_timeout_error e
66
68
  end
67
69
 
68
70
  def put(image_id, file_or_binary, options)
@@ -83,6 +85,8 @@ module Resizing
83
85
 
84
86
  result = handle_create_response(response)
85
87
  result
88
+ rescue Faraday::TimeoutError => e
89
+ handle_timeout_error e
86
90
  end
87
91
 
88
92
  def delete(image_id)
@@ -94,6 +98,8 @@ module Resizing
94
98
 
95
99
  result = handle_delete_response(response)
96
100
  result
101
+ rescue Faraday::TimeoutError => e
102
+ handle_timeout_error e
97
103
  end
98
104
 
99
105
  def metadata(image_id, options = {})
@@ -105,6 +111,8 @@ module Resizing
105
111
 
106
112
  result = handle_metadata_response(response)
107
113
  result
114
+ rescue Faraday::TimeoutError => e
115
+ handle_timeout_error e
108
116
  end
109
117
 
110
118
  private
@@ -145,13 +153,13 @@ module Resizing
145
153
  end
146
154
 
147
155
  def to_io(data)
156
+ return data.to_io if data.respond_to? :to_io
157
+
148
158
  case data
149
- when IO
150
- data
151
159
  when String
152
160
  StringIO.new(data)
153
161
  else
154
- raise ArgumentError, 'file_or_binary is required IO class or String'
162
+ raise ArgumentError, "file_or_binary is required IO class or String:#{data.class}"
155
163
  end
156
164
  end
157
165
 
@@ -166,7 +174,10 @@ module Resizing
166
174
  when HTTP_STATUS_OK, HTTP_STATUS_CREATED
167
175
  JSON.parse(response.body)
168
176
  else
169
- raise APIError, "invalid http status code #{response.status}"
177
+ result = JSON.parse(response.body) rescue {}
178
+ err = APIError.new("invalid http status code #{response.status}")
179
+ err.decoded_body = result
180
+ raise err
170
181
  end
171
182
  end
172
183
 
@@ -177,7 +188,10 @@ module Resizing
177
188
  when HTTP_STATUS_OK, HTTP_STATUS_NOT_FOUND
178
189
  JSON.parse(response.body)
179
190
  else
180
- raise APIError, "invalid http status code #{response.status}"
191
+ result = JSON.parse(response.body) rescue {}
192
+ err = APIError.new("invalid http status code #{response.status}")
193
+ err.decoded_body = result
194
+ raise err
181
195
  end
182
196
  end
183
197
 
@@ -188,8 +202,16 @@ module Resizing
188
202
  when HTTP_STATUS_OK, HTTP_STATUS_NOT_FOUND
189
203
  JSON.parse(response.body)
190
204
  else
191
- raise APIError, "invalid http status code #{response.status}"
205
+ result = JSON.parse(response.body) rescue {}
206
+ err = APIError.new("invalid http status code #{response.status}")
207
+ err.decoded_body = result
208
+ raise err
192
209
  end
193
210
  end
211
+
212
+ def handle_timeout_error error
213
+ # error: Faraday::TimeoutError
214
+ raise APIError.new("TimeoutError: #{error.inspect}")
215
+ end
194
216
  end
195
217
  end
@@ -42,7 +42,7 @@ module Resizing
42
42
  end
43
43
 
44
44
  def library_root
45
- File.join(File.dirname(__FILE__), '..', '..')
45
+ @library_root ||= File.expand_path('../../../', __FILE__)
46
46
  end
47
47
  end
48
48
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Resizing
4
- VERSION = '0.4.1'
4
+ VERSION = '0.7.0'
5
5
  end
File without changes
@@ -10,8 +10,8 @@ module Resizing
10
10
 
11
11
  @configuration_template = {
12
12
  host: 'http://192.168.56.101:5000',
13
- project_id: '098a2a0d-c387-4135-a071-1254d6d7e70a',
14
- secret_token: '4g1cshg2lq8j93ufhvqrpjswxmtjz12yhfvq6w79jpwi7cr7nnknoqgwzkwerbs6',
13
+ project_id: 'e06e710d-f026-4dcf-b2c0-eab0de8bb83f',
14
+ secret_token: 'ewbym2r1pk49x1d2lxdbiiavnqp25j2kh00hsg3koy0ppm620x5mhlmgl3rq5ci8',
15
15
  open_timeout: 10,
16
16
  response_timeout: 20
17
17
  }
@@ -70,7 +70,7 @@ module Resizing
70
70
  assert_equal('jpg', model.resizing_picture.format)
71
71
  end
72
72
 
73
- def test_url_is_return_default_url
73
+ def test_url_is_return_default_url_as_nil
74
74
  model = TestModel.new
75
75
  model.save!
76
76
  assert_nil model.resizing_picture_url
@@ -82,13 +82,19 @@ module Resizing
82
82
  assert_equal('http://example.com/test.jpg', model.resizing_picture_url)
83
83
  end
84
84
 
85
+ def test_is_successful
86
+ model = prepare_model_with_tempfile TestModel
87
+ model.save!
88
+ # assert_equal('http://192.168.56.101:5000/projects/098a2a0d-c387-4135-a071-1254d6d7e70a/upload/images/28c49144-c00d-4cb5-8619-98ce95977b9c/v1Id850__tqNsnoGWWUibtIBZ5NgjV45M/', model.resizing_picture_url)
89
+ end
90
+
85
91
  def expect_url
86
- 'http://192.168.56.101:5000/projects/098a2a0d-c387-4135-a071-1254d6d7e70a/'+
87
- 'upload/images/28c49144-c00d-4cb5-8619-98ce95977b9c/v1Id850__tqNsnoGWWUibtIBZ5NgjV45M'
92
+ 'http://192.168.56.101:5000/projects/e06e710d-f026-4dcf-b2c0-eab0de8bb83f/'+
93
+ 'upload/images/14ea7aac-a194-4330-931f-6b562aec413d/v_8c5lEhDB5RT3PZp1Fn5PYGm9YVx_x0e'
88
94
  end
89
95
 
90
96
  def prepare_model model
91
- VCR.use_cassette 'carrier_wave_test/save' do
97
+ VCR.use_cassette 'carrier_wave_test/save', record: :once do
92
98
  SecureRandom.stub :uuid, '28c49144-c00d-4cb5-8619-98ce95977b9c' do
93
99
  model = model.new
94
100
  file = File.open('test/data/images/sample1.jpg', 'r')
@@ -103,5 +109,16 @@ module Resizing
103
109
  end
104
110
  end
105
111
  end
112
+
113
+ def prepare_model_with_tempfile model
114
+ VCR.use_cassette 'carrier_wave_test/save', record: :once do
115
+ SecureRandom.stub :uuid, '28c49144-c00d-4cb5-8619-98ce95977b9c' do
116
+ model = model.new
117
+ file = File.open('test/data/images/sample1.jpg', 'r')
118
+ model.resizing_picture = file
119
+ return model
120
+ end
121
+ end
122
+ end
106
123
  end
107
124
  end
@@ -8,8 +8,8 @@ module Resizing
8
8
  # NOP
9
9
  @configuration_template = {
10
10
  host: 'http://192.168.56.101:5000',
11
- project_id: '098a2a0d-c387-4135-a071-1254d6d7e70a',
12
- secret_token: '4g1cshg2lq8j93ufhvqrpjswxmtjz12yhfvq6w79jpwi7cr7nnknoqgwzkwerbs6',
11
+ project_id: 'e06e710d-f026-4dcf-b2c0-eab0de8bb83f',
12
+ secret_token: 'ewbym2r1pk49x1d2lxdbiiavnqp25j2kh00hsg3koy0ppm620x5mhlmgl3rq5ci8',
13
13
  open_timeout: 10,
14
14
  response_timeout: 20
15
15
  }
@@ -41,14 +41,14 @@ module Resizing
41
41
  VCR.use_cassette 'client/post', record: :once do
42
42
  f = File.open('test/data/images/sample1.jpg', 'r')
43
43
  r = client.post(f, content_type: 'image/jpeg')
44
- assert_equal(r['id'], 'bfdaf2b3-7ec5-41f4-9caa-d53247dd9666')
44
+ assert_equal(r['id'], '87263920-2081-498e-a107-9625f4fde01b')
45
45
  assert_equal(r['project_id'], Resizing.configure.project_id)
46
46
  assert_equal(r['content_type'], 'image/jpeg')
47
47
  assert(!r['latest_version_id'].nil?)
48
48
  assert(!r['latest_etag'].nil?)
49
49
  assert(!r['created_at'].nil?)
50
50
  assert(!r['updated_at'].nil?)
51
- assert_equal(r['public_id'], '/projects/098a2a0d-c387-4135-a071-1254d6d7e70a/upload/images/bfdaf2b3-7ec5-41f4-9caa-d53247dd9666/vAyWaxx96gLaAzB9Bq.VbX1_pxfXJ0Jcq')
51
+ assert_equal(r['public_id'], '/projects/e06e710d-f026-4dcf-b2c0-eab0de8bb83f/upload/images/87263920-2081-498e-a107-9625f4fde01b/vHg9VFvdI6HRzLFbV495VdwVmHIspLRCo')
52
52
  assert_equal(r['filename'], 'sample1.jpg')
53
53
  end
54
54
  end
@@ -70,11 +70,41 @@ module Resizing
70
70
  assert(!r['updated_at'].nil?)
71
71
  assert_equal(
72
72
  r['public_id'],
73
- "/projects/098a2a0d-c387-4135-a071-1254d6d7e70a/upload/images/#{name}/v6Ew3HmDAYfb3NMRdLxR45i_gXMbLlGyi"
73
+ "/projects/e06e710d-f026-4dcf-b2c0-eab0de8bb83f/upload/images/#{name}/vfztekhN_WoeXo8ZkCZ4i5jcQvmPpZewR"
74
74
  )
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
 
@@ -82,7 +112,7 @@ module Resizing
82
112
 
83
113
  client = Resizing::Client.new
84
114
  VCR.use_cassette 'client/metadata', record: :once do
85
- name = 'bfdaf2b3-7ec5-41f4-9caa-d53247dd9666'
115
+ name = '87263920-2081-498e-a107-9625f4fde01b'
86
116
  r = client.metadata(name)
87
117
  assert_equal(r['id'], name)
88
118
  assert_equal(r['project_id'], Resizing.configure.project_id)
@@ -95,7 +125,7 @@ module Resizing
95
125
  assert(!r['width'].nil?)
96
126
  assert_equal(
97
127
  r['public_id'],
98
- "/projects/098a2a0d-c387-4135-a071-1254d6d7e70a/upload/images/#{name}/v6Ew3HmDAYfb3NMRdLxR45i_gXMbLlGyi"
128
+ "/projects/e06e710d-f026-4dcf-b2c0-eab0de8bb83f/upload/images/87263920-2081-498e-a107-9625f4fde01b/vHg9VFvdI6HRzLFbV495VdwVmHIspLRCo"
99
129
  )
100
130
  end
101
131
  end