dragonfly 0.9.12 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- data/Gemfile +7 -6
- data/History.md +6 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/dragonfly.gemspec +26 -68
- data/extra_docs/Rails3.md +1 -1
- data/features/no_processing.feature +1 -1
- data/fixtures/rails/files/app/models/album.rb +1 -0
- data/fixtures/rails/files/features/step_definitions/web_steps.rb +189 -0
- data/lib/dragonfly/active_model_extensions/class_methods.rb +15 -15
- data/lib/dragonfly/image_magick/generator.rb +2 -0
- data/lib/dragonfly/image_magick/processor.rb +26 -20
- data/lib/dragonfly/job.rb +24 -18
- data/lib/dragonfly/routed_endpoint.rb +1 -8
- data/lib/dragonfly/serializer.rb +20 -9
- data/lib/dragonfly/server.rb +5 -6
- data/lib/dragonfly/url_mapper.rb +11 -17
- data/lib/dragonfly/utils.rb +24 -0
- data/spec/dragonfly/active_model_extensions/model_spec.rb +60 -60
- data/spec/dragonfly/data_storage/s3_data_store_spec.rb +25 -25
- data/spec/dragonfly/image_magick/analyser_spec.rb +3 -8
- data/spec/dragonfly/image_magick/encoder_spec.rb +12 -7
- data/spec/dragonfly/image_magick/generator_spec.rb +18 -7
- data/spec/dragonfly/image_magick/processor_spec.rb +28 -28
- data/spec/dragonfly/job_endpoint_spec.rb +9 -9
- data/spec/dragonfly/job_spec.rb +54 -53
- data/spec/dragonfly/serializer_spec.rb +36 -20
- data/spec/dragonfly/server_spec.rb +23 -41
- data/spec/dragonfly/url_mapper_spec.rb +12 -3
- metadata +166 -98
@@ -32,7 +32,7 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
32
32
|
d.region = 'eu-west-1'
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
else
|
37
37
|
|
38
38
|
BUCKET_NAME = 'test-bucket'
|
@@ -47,7 +47,7 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
47
47
|
d.region = 'eu-west-1'
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
end
|
52
52
|
|
53
53
|
it_should_behave_like 'data_store'
|
@@ -82,14 +82,14 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
82
82
|
data, meta = @data_store.retrieve(uid)
|
83
83
|
data.should == 'eggheads'
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
it "should work fine when not using the filesystem" do
|
87
87
|
@data_store.use_filesystem = false
|
88
88
|
temp_object = Dragonfly::TempObject.new('gollum')
|
89
89
|
uid = @data_store.store(temp_object)
|
90
90
|
@data_store.retrieve(uid).first.should == "gollum"
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
if enabled # Fog.mock! doesn't act consistently here
|
94
94
|
it "should reset the connection and try again if Fog throws a socket EOFError" do
|
95
95
|
temp_object = Dragonfly::TempObject.new('gollum')
|
@@ -128,12 +128,12 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
128
128
|
@data_store.region = nil
|
129
129
|
@data_store.domain.should == 's3.amazonaws.com'
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
it "should return the correct domain" do
|
133
133
|
@data_store.region = 'eu-west-1'
|
134
134
|
@data_store.domain.should == 's3-eu-west-1.amazonaws.com'
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
it "does raise an error if an unknown region is given" do
|
138
138
|
@data_store.region = 'latvia-central'
|
139
139
|
lambda{
|
@@ -146,32 +146,32 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
146
146
|
before(:each) do
|
147
147
|
@temp_object = Dragonfly::TempObject.new("Hi guys")
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it "should require a bucket name on store" do
|
151
151
|
@data_store.bucket_name = nil
|
152
152
|
proc{ @data_store.store(@temp_object) }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
153
153
|
end
|
154
|
-
|
154
|
+
|
155
155
|
it "should require an access_key_id on store" do
|
156
156
|
@data_store.access_key_id = nil
|
157
157
|
proc{ @data_store.store(@temp_object) }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
it "should require a secret access key on store" do
|
161
161
|
@data_store.secret_access_key = nil
|
162
162
|
proc{ @data_store.store(@temp_object) }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
it "should require a bucket name on retrieve" do
|
166
166
|
@data_store.bucket_name = nil
|
167
167
|
proc{ @data_store.retrieve('asdf') }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
168
168
|
end
|
169
|
-
|
169
|
+
|
170
170
|
it "should require an access_key_id on retrieve" do
|
171
171
|
@data_store.access_key_id = nil
|
172
172
|
proc{ @data_store.retrieve('asdf') }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
it "should require a secret access key on retrieve" do
|
176
176
|
@data_store.secret_access_key = nil
|
177
177
|
proc{ @data_store.retrieve('asdf') }.should raise_error(Dragonfly::Configurable::NotConfigured)
|
@@ -183,48 +183,48 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
183
183
|
@data_store.bucket_name = "dragonfly-test-blah-blah-#{rand(100000000)}"
|
184
184
|
@data_store.store(Dragonfly::TempObject.new("asdfj"))
|
185
185
|
end
|
186
|
-
|
186
|
+
|
187
187
|
it "should not try to create the bucket on retrieve if it doesn't exist" do
|
188
188
|
@data_store.bucket_name = "dragonfly-test-blah-blah-#{rand(100000000)}"
|
189
189
|
@data_store.send(:storage).should_not_receive(:put_bucket)
|
190
190
|
proc{ @data_store.retrieve("gungle") }.should raise_error(Dragonfly::DataStorage::DataNotFound)
|
191
191
|
end
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
describe "headers" do
|
195
195
|
before(:each) do
|
196
196
|
@temp_object = Dragonfly::TempObject.new('fjkdlsa')
|
197
197
|
@data_store.storage_headers = {'x-amz-foo' => 'biscuithead'}
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
it "should allow configuring globally" do
|
201
201
|
@data_store.storage.should_receive(:put_object).with(BUCKET_NAME, anything, anything,
|
202
202
|
hash_including('x-amz-foo' => 'biscuithead')
|
203
203
|
)
|
204
204
|
@data_store.store(@temp_object)
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
it "should allow adding per-store" do
|
208
208
|
@data_store.storage.should_receive(:put_object).with(BUCKET_NAME, anything, anything,
|
209
209
|
hash_including('x-amz-foo' => 'biscuithead', 'hello' => 'there')
|
210
210
|
)
|
211
211
|
@data_store.store(@temp_object, :headers => {'hello' => 'there'})
|
212
212
|
end
|
213
|
-
|
213
|
+
|
214
214
|
it "should let the per-store one take precedence" do
|
215
215
|
@data_store.storage.should_receive(:put_object).with(BUCKET_NAME, anything, anything,
|
216
216
|
hash_including('x-amz-foo' => 'override!')
|
217
217
|
)
|
218
218
|
@data_store.store(@temp_object, :headers => {'x-amz-foo' => 'override!'})
|
219
219
|
end
|
220
|
-
|
220
|
+
|
221
221
|
it "should not mess with the meta" do
|
222
222
|
@data_store.storage.should_receive(:put_object) do |_, __, ___, headers|
|
223
223
|
headers['x-amz-meta-extra'].should =~ /^\w+$/
|
224
224
|
end
|
225
225
|
@data_store.store(@temp_object, :headers => {'hello' => 'there'})
|
226
226
|
end
|
227
|
-
|
227
|
+
|
228
228
|
it "should store with the content-type if passed in" do
|
229
229
|
@data_store.storage.should_receive(:put_object) do |_, __, ___, headers|
|
230
230
|
headers['Content-Type'].should == 'text/plain'
|
@@ -234,23 +234,23 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
234
234
|
end
|
235
235
|
|
236
236
|
describe "urls for serving directly" do
|
237
|
-
|
237
|
+
|
238
238
|
before(:each) do
|
239
239
|
@uid = 'some/path/on/s3'
|
240
240
|
end
|
241
|
-
|
241
|
+
|
242
242
|
it "should use the bucket subdomain" do
|
243
243
|
@data_store.url_for(@uid).should == "http://#{BUCKET_NAME}.s3.amazonaws.com/some/path/on/s3"
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
it "should use the bucket subdomain for other regions too" do
|
247
247
|
@data_store.region = 'eu-west-1'
|
248
248
|
@data_store.url_for(@uid).should == "http://#{BUCKET_NAME}.s3.amazonaws.com/some/path/on/s3"
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
251
|
it "should give an expiring url" do
|
252
252
|
@data_store.url_for(@uid, :expires => 1301476942).should =~
|
253
|
-
%r{^https://#{@data_store.domain}
|
253
|
+
%r{^https://#{BUCKET_NAME}\.#{@data_store.domain}/some/path/on/s3\?AWSAccessKeyId=#{@data_store.access_key_id}&Signature=[\w%]+&Expires=1301476942$}
|
254
254
|
end
|
255
255
|
|
256
256
|
it "should allow for using https" do
|
@@ -271,7 +271,7 @@ describe Dragonfly::DataStorage::S3DataStore do
|
|
271
271
|
@data_store.url_host = url_host
|
272
272
|
@data_store.url_for(@uid).should == "http://#{url_host}/some/path/on/s3"
|
273
273
|
end
|
274
|
-
|
274
|
+
|
275
275
|
end
|
276
276
|
|
277
277
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Dragonfly::ImageMagick::Analyser do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@image = Dragonfly::TempObject.new(SAMPLES_DIR.join('beach.png'))
|
7
7
|
@analyser = Dragonfly::ImageMagick::Analyser.new
|
@@ -53,7 +53,7 @@ describe Dragonfly::ImageMagick::Analyser do
|
|
53
53
|
it "should say if it's an image" do
|
54
54
|
@analyser.image?(@image).should == true
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
it "should say if it's not an image" do
|
58
58
|
suppressing_stderr do
|
59
59
|
@analyser.image?(Dragonfly::TempObject.new('blah')).should == false
|
@@ -64,15 +64,10 @@ describe Dragonfly::ImageMagick::Analyser do
|
|
64
64
|
image = Dragonfly::TempObject.new(SAMPLES_DIR.join('white pixel.png'))
|
65
65
|
@analyser.width(image).should == 1
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should work (width) for images with capital letter extensions" do
|
69
69
|
image = Dragonfly::TempObject.new(SAMPLES_DIR.join('DSC02119.JPG'))
|
70
70
|
@analyser.width(image).should == 1
|
71
71
|
end
|
72
72
|
|
73
|
-
it "should work (width) for images with numbers in the format" do
|
74
|
-
image = Dragonfly::TempObject.new(SAMPLES_DIR.join('a.jp2'))
|
75
|
-
@analyser.width(image).should == 1
|
76
|
-
end
|
77
|
-
|
78
73
|
end
|
@@ -1,26 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Dragonfly::ImageMagick::Encoder do
|
4
|
-
|
4
|
+
|
5
5
|
before(:all) do
|
6
6
|
sample_file = File.dirname(__FILE__) + '/../../../samples/beach.png' # 280x355, 135KB
|
7
7
|
@image = Dragonfly::TempObject.new(File.new(sample_file))
|
8
8
|
@encoder = Dragonfly::ImageMagick::Encoder.new
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
describe "#encode" do
|
12
|
-
|
12
|
+
|
13
13
|
it "should encode the image to the correct format" do
|
14
14
|
image = @encoder.encode(@image, :gif)
|
15
15
|
image.should have_format('gif')
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
it "should work with a string argument" do
|
19
|
+
image = @encoder.encode(@image, 'gif')
|
20
|
+
image.should have_format('gif')
|
21
|
+
end
|
22
|
+
|
18
23
|
it "should throw :unable_to_handle if the format is not handleable" do
|
19
24
|
lambda{
|
20
25
|
@encoder.encode(@image, :goofy)
|
21
26
|
}.should throw_symbol(:unable_to_handle)
|
22
27
|
end
|
23
|
-
|
28
|
+
|
24
29
|
it "should do nothing if the image is already in the correct format" do
|
25
30
|
image = @encoder.encode(@image, :png)
|
26
31
|
image.should == @image
|
@@ -31,11 +36,11 @@ describe Dragonfly::ImageMagick::Encoder do
|
|
31
36
|
image.should have_format('jpeg')
|
32
37
|
image.should have_size('1.45KB')
|
33
38
|
end
|
34
|
-
|
39
|
+
|
35
40
|
it "should still work even if the image is already in the correct format and args are given" do
|
36
41
|
image = @encoder.encode(@image, :png, '-quality 1')
|
37
42
|
image.should_not == @image
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
45
|
+
|
41
46
|
end
|
@@ -16,7 +16,7 @@ describe Dragonfly::ImageMagick::Generator do
|
|
16
16
|
it {@image.should have_format('png')}
|
17
17
|
it {@meta.should == {:format => :png, :name => 'plain.png'}}
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
it "should cope with colour name format" do
|
21
21
|
image, meta = @generator.plain(1, 1, 'red')
|
22
22
|
image.should have_width(1)
|
@@ -62,12 +62,6 @@ describe Dragonfly::ImageMagick::Generator do
|
|
62
62
|
image.should have_width(1)
|
63
63
|
end
|
64
64
|
|
65
|
-
it "should blow up with an invalid colour" do
|
66
|
-
lambda{
|
67
|
-
@generator.plain(1,1,'rgb(doogie)')
|
68
|
-
}.should_not raise_error()
|
69
|
-
end
|
70
|
-
|
71
65
|
describe "specifying the format" do
|
72
66
|
before(:each) do
|
73
67
|
@image, @meta = @generator.plain(23, 12, 'white', :format => :gif)
|
@@ -75,6 +69,11 @@ describe Dragonfly::ImageMagick::Generator do
|
|
75
69
|
it {@image.should have_format('gif')}
|
76
70
|
it {@meta.should == {:format => :gif, :name => 'plain.gif'}}
|
77
71
|
end
|
72
|
+
|
73
|
+
it "works with string args" do
|
74
|
+
image, meta = @generator.plain(1, 1, 'white', 'format' => 'gif')
|
75
|
+
image.should have_format('gif')
|
76
|
+
end
|
78
77
|
end
|
79
78
|
|
80
79
|
describe "plasma" do
|
@@ -95,6 +94,11 @@ describe Dragonfly::ImageMagick::Generator do
|
|
95
94
|
it {@image.should have_format('gif')}
|
96
95
|
it {@meta.should == {:format => :gif, :name => 'plasma.gif'}}
|
97
96
|
end
|
97
|
+
|
98
|
+
it "works with string args" do
|
99
|
+
image, meta = @generator.plasma(1, 1, 'gif')
|
100
|
+
image.should have_format('gif')
|
101
|
+
end
|
98
102
|
end
|
99
103
|
|
100
104
|
describe "text" do
|
@@ -161,7 +165,14 @@ describe Dragonfly::ImageMagick::Generator do
|
|
161
165
|
@generator.text(@text, :padding => '1 2 3 4 5')
|
162
166
|
}.should raise_error(ArgumentError)
|
163
167
|
end
|
168
|
+
|
169
|
+
it "works with string args" do
|
170
|
+
image, meta = @generator.text(@text, 'format' => 'gif', 'padding' => '10')
|
171
|
+
image.should have_format('gif')
|
172
|
+
image.should have_width(@width + 20)
|
173
|
+
end
|
164
174
|
end
|
175
|
+
|
165
176
|
end
|
166
177
|
|
167
178
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Dragonfly::ImageMagick::Processor do
|
4
|
-
|
4
|
+
|
5
5
|
before(:each) do
|
6
6
|
@image = Dragonfly::TempObject.new(SAMPLES_DIR.join('beach.png')) # 280x355
|
7
7
|
@processor = Dragonfly::ImageMagick::Processor.new
|
@@ -82,40 +82,40 @@ describe Dragonfly::ImageMagick::Processor do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
it "should crop using the offset given" do
|
85
|
-
image = @processor.crop(@image,
|
85
|
+
image = @processor.crop(@image, 'x' => '7', 'y' => '12')
|
86
86
|
image.should have_width(273)
|
87
87
|
image.should have_height(343)
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should crop using the dimensions given" do
|
91
|
-
image = @processor.crop(@image,
|
91
|
+
image = @processor.crop(@image, 'width' => '10', 'height' => '20')
|
92
92
|
image.should have_width(10)
|
93
93
|
image.should have_height(20)
|
94
94
|
end
|
95
95
|
|
96
96
|
it "should crop in one dimension if given" do
|
97
|
-
image = @processor.crop(@image,
|
97
|
+
image = @processor.crop(@image, 'width' => '10')
|
98
98
|
image.should have_width(10)
|
99
99
|
image.should have_height(355)
|
100
100
|
end
|
101
101
|
|
102
102
|
it "should take into account the gravity given" do
|
103
|
-
image1 = @processor.crop(@image,
|
104
|
-
image2 = @processor.crop(@image,
|
103
|
+
image1 = @processor.crop(@image, 'width' => '10', 'height' => '10', 'gravity' => 'nw')
|
104
|
+
image2 = @processor.crop(@image, 'width' => '10', 'height' => '10', 'gravity' => 'se')
|
105
105
|
image1.should_not equal_image(image2)
|
106
106
|
end
|
107
107
|
|
108
108
|
it "should clip bits of the image outside of the requested crop area when not nw gravity" do
|
109
109
|
# Rmagick was previously throwing an error when the cropping area was outside the image size, when
|
110
110
|
# using a gravity other than nw
|
111
|
-
image = @processor.crop(@image,
|
111
|
+
image = @processor.crop(@image, 'width' => '500', 'height' => '1000', 'x' => '100', 'y' => '200', 'gravity' => 'se')
|
112
112
|
image.should have_width(180)
|
113
113
|
image.should have_height(155)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it "should crop twice in a row correctly" do
|
117
|
-
image1 = @processor.crop(@image,
|
118
|
-
image2 = @processor.crop(Dragonfly::TempObject.new(image1),
|
117
|
+
image1 = @processor.crop(@image, 'x' => '10', 'y' => '10', 'width' => '100', 'height' => '100')
|
118
|
+
image2 = @processor.crop(Dragonfly::TempObject.new(image1), 'x' => '0' , 'y' => '0' , 'width' => '50' , 'height' => '50' )
|
119
119
|
image2.should have_width(50)
|
120
120
|
image2.should have_height(50)
|
121
121
|
end
|
@@ -123,8 +123,8 @@ describe Dragonfly::ImageMagick::Processor do
|
|
123
123
|
it "should crop twice in a row while consciously keeping page geometry" do
|
124
124
|
# see http://www.imagemagick.org/Usage/crop/#crop_page
|
125
125
|
# it explains how cropping multiple times without resetting geometry behaves
|
126
|
-
image1 = @processor.crop(@image,
|
127
|
-
image2 = @processor.crop(Dragonfly::TempObject.new(image1),
|
126
|
+
image1 = @processor.crop(@image, 'x' => '10', 'y' => '10', 'width' => '100', 'height' => '100', 'repage' => false)
|
127
|
+
image2 = @processor.crop(Dragonfly::TempObject.new(image1), 'x' => '0' , 'y' => '0' , 'width' => '50' , 'height' => '50')
|
128
128
|
image2.should have_width(40)
|
129
129
|
image2.should have_height(40)
|
130
130
|
end
|
@@ -154,26 +154,26 @@ describe Dragonfly::ImageMagick::Processor do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
it "should crop to the correct dimensions" do
|
157
|
-
image = @processor.resize_and_crop(@image,
|
157
|
+
image = @processor.resize_and_crop(@image, 'width' => '100', 'height' => '100')
|
158
158
|
image.should have_width(100)
|
159
159
|
image.should have_height(100)
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should actually resize before cropping" do
|
163
|
-
image1 = @processor.resize_and_crop(@image,
|
164
|
-
image2 = @processor.crop(@image,
|
163
|
+
image1 = @processor.resize_and_crop(@image, 'width' => '100', 'height' => '100')
|
164
|
+
image2 = @processor.crop(@image, 'width' => '100', 'height' => '100', 'gravity' => 'c')
|
165
165
|
image1.should_not equal_image(image2)
|
166
166
|
end
|
167
167
|
|
168
168
|
it "should allow cropping in one dimension" do
|
169
|
-
image = @processor.resize_and_crop(@image,
|
169
|
+
image = @processor.resize_and_crop(@image, 'width' => '100')
|
170
170
|
image.should have_width(100)
|
171
171
|
image.should have_height(355)
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should take into account the gravity given" do
|
175
|
-
image1 = @processor.resize_and_crop(@image,
|
176
|
-
image2 = @processor.resize_and_crop(@image,
|
175
|
+
image1 = @processor.resize_and_crop(@image, 'width' => '10', 'height' => '10', 'gravity' => 'nw')
|
176
|
+
image2 = @processor.resize_and_crop(@image, 'width' => '10', 'height' => '10', 'gravity' => 'se')
|
177
177
|
image1.should_not equal_image(image2)
|
178
178
|
end
|
179
179
|
|
@@ -188,13 +188,13 @@ describe Dragonfly::ImageMagick::Processor do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should not rotate given a larger height and the '>' qualifier" do
|
191
|
-
image = @processor.rotate(@image, 90,
|
191
|
+
image = @processor.rotate(@image, 90, 'qualifier' => '>')
|
192
192
|
image.should have_width(280)
|
193
193
|
image.should have_height(355)
|
194
194
|
end
|
195
195
|
|
196
196
|
it "should rotate given a larger height and the '<' qualifier" do
|
197
|
-
image = @processor.rotate(@image, 90,
|
197
|
+
image = @processor.rotate(@image, 90, 'qualifier' => '<')
|
198
198
|
image.should have_width(355)
|
199
199
|
image.should have_height(280)
|
200
200
|
end
|
@@ -217,19 +217,19 @@ describe Dragonfly::ImageMagick::Processor do
|
|
217
217
|
@processor.thumb(@image, '30x40').should == image
|
218
218
|
end
|
219
219
|
it "should call resize_and_crop if the correct string given" do
|
220
|
-
@processor.should_receive(:resize_and_crop).with(@image,
|
220
|
+
@processor.should_receive(:resize_and_crop).with(@image, 'width' => '30', 'height' => '40', 'gravity' => 'se').and_return(image = mock)
|
221
221
|
@processor.thumb(@image, '30x40#se').should == image
|
222
222
|
end
|
223
223
|
it "should call crop if x and y given" do
|
224
|
-
@processor.should_receive(:crop).with(@image,
|
224
|
+
@processor.should_receive(:crop).with(@image, 'width' => '30', 'height' => '40', 'x' => '+10', 'y' => '+20', 'gravity' => nil).and_return(image = mock)
|
225
225
|
@processor.thumb(@image, '30x40+10+20').should == image
|
226
226
|
end
|
227
227
|
it "should call crop if just gravity given" do
|
228
|
-
@processor.should_receive(:crop).with(@image,
|
228
|
+
@processor.should_receive(:crop).with(@image, 'width' => '30', 'height' => '40', 'x' => nil, 'y' => nil, 'gravity' => 'sw').and_return(image = mock)
|
229
229
|
@processor.thumb(@image, '30x40sw').should == image
|
230
230
|
end
|
231
231
|
it "should call crop if x, y and gravity given" do
|
232
|
-
@processor.should_receive(:crop).with(@image,
|
232
|
+
@processor.should_receive(:crop).with(@image, 'width' => '30', 'height' => '40', 'x' => '-10', 'y' => '-20', 'gravity' => 'se').and_return(image = mock)
|
233
233
|
@processor.thumb(@image, '30x40-10-20se').should == image
|
234
234
|
end
|
235
235
|
it "should raise an argument error if an unrecognized string is given" do
|
@@ -263,16 +263,16 @@ describe Dragonfly::ImageMagick::Processor do
|
|
263
263
|
image.should have_height(355)
|
264
264
|
end
|
265
265
|
end
|
266
|
-
|
266
|
+
|
267
267
|
describe "convert" do
|
268
268
|
it "should allow for general convert commands" do
|
269
269
|
image = @processor.convert(@image, '-scale 56x71')
|
270
270
|
image.should have_width(56)
|
271
271
|
image.should have_height(71)
|
272
272
|
end
|
273
|
-
|
273
|
+
|
274
274
|
it "should allow for general convert commands with added format" do
|
275
|
-
image, extra = @processor.convert(@image, '-scale 56x71',
|
275
|
+
image, extra = @processor.convert(@image, '-scale 56x71', 'gif')
|
276
276
|
image.should have_width(56)
|
277
277
|
image.should have_height(71)
|
278
278
|
image.should have_format('gif')
|
@@ -289,5 +289,5 @@ describe Dragonfly::ImageMagick::Processor do
|
|
289
289
|
@processor.convert(image, "-resize 2x2!").should have_width(2)
|
290
290
|
end
|
291
291
|
end
|
292
|
-
|
292
|
+
|
293
293
|
end
|