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.

@@ -10,23 +10,23 @@ describe "Dragonfly::JobEndpoint Rack::Lint tests" do
10
10
  @job = @app.generate(:test_data)
11
11
  @endpoint = Rack::Lint.new(Dragonfly::JobEndpoint.new(@job))
12
12
  end
13
-
13
+
14
14
  it "should pass for HEAD requests" do
15
15
  Rack::MockRequest.new(@endpoint).request("HEAD", '')
16
16
  end
17
-
17
+
18
18
  it "should pass for GET requests" do
19
19
  Rack::MockRequest.new(@endpoint).request("GET", '')
20
20
  end
21
-
21
+
22
22
  it "should pass for POST requests" do
23
23
  Rack::MockRequest.new(@endpoint).request("POST", '')
24
24
  end
25
-
25
+
26
26
  it "should pass for PUT requests" do
27
27
  Rack::MockRequest.new(@endpoint).request("PUT", '')
28
28
  end
29
-
29
+
30
30
  it "should pass for DELETE requests" do
31
31
  Rack::MockRequest.new(@endpoint).request("DELETE", '')
32
32
  end
@@ -69,7 +69,7 @@ describe Dragonfly::JobEndpoint do
69
69
  end
70
70
 
71
71
  %w(POST PUT DELETE CUSTOM_METHOD).each do |method|
72
-
72
+
73
73
  it "should return a 405 error for a #{method} request" do
74
74
  response = make_request(@job, :method => method)
75
75
  response.status.should == 405
@@ -175,7 +175,7 @@ describe Dragonfly::JobEndpoint do
175
175
  end
176
176
  end
177
177
  end
178
-
178
+
179
179
  describe "custom headers" do
180
180
  before(:each) do
181
181
  @app.configure{|c| c.response_headers['This-is'] = 'brill' }
@@ -208,7 +208,7 @@ describe Dragonfly::JobEndpoint do
208
208
  def initialize(app)
209
209
  @app = app
210
210
  end
211
-
211
+
212
212
  def call(env)
213
213
  @app.call(env)
214
214
  throw :result, env['dragonfly.job']
@@ -228,7 +228,7 @@ describe Dragonfly::JobEndpoint do
228
228
 
229
229
  describe "inspect" do
230
230
  it "should be pretty yo" do
231
- @job.to_app.inspect.should == %(<Dragonfly::JobEndpoint steps=[fetch("egg")] >)
231
+ @job.to_app.inspect.should =~ %r{<Dragonfly::JobEndpoint steps=.* >}
232
232
  end
233
233
  end
234
234
 
@@ -25,12 +25,12 @@ describe Dragonfly::Job do
25
25
  end
26
26
 
27
27
  {
28
- Dragonfly::Job::Fetch => :f,
29
- Dragonfly::Job::Process => :p,
30
- Dragonfly::Job::Encode => :e,
31
- Dragonfly::Job::Generate => :g,
32
- Dragonfly::Job::FetchFile => :ff,
33
- Dragonfly::Job::FetchUrl => :fu
28
+ Dragonfly::Job::Fetch => 'f',
29
+ Dragonfly::Job::Process => 'p',
30
+ Dragonfly::Job::Encode => 'e',
31
+ Dragonfly::Job::Generate => 'g',
32
+ Dragonfly::Job::FetchFile => 'ff',
33
+ Dragonfly::Job::FetchUrl => 'fu'
34
34
  }.each do |klass, abbreviation|
35
35
  it "should return the correct abbreviation for #{klass}" do
36
36
  klass.abbreviation.should == abbreviation
@@ -74,7 +74,7 @@ describe Dragonfly::Job do
74
74
  @job.data.should == 'HELLO'
75
75
  @job.meta.should == {:name => 'test.txt'}
76
76
  end
77
-
77
+
78
78
  it "shouldn't set any url_attrs" do
79
79
  @job.url_attrs.should == {}
80
80
  end
@@ -132,7 +132,7 @@ describe Dragonfly::Job do
132
132
  @job.data.should == 'hi'
133
133
  @job.meta.should == {:name => 'plasma.png'}
134
134
  end
135
-
135
+
136
136
  it "shouldn't set any url_attrs" do
137
137
  @job.url_attrs.should == {}
138
138
  end
@@ -148,11 +148,11 @@ describe Dragonfly::Job do
148
148
  it "should fetch the specified file when applied" do
149
149
  @job.size.should == 62664
150
150
  end
151
-
151
+
152
152
  it "should set the url_attrs" do
153
153
  @job.url_attrs.should == {:name => 'egg.png'}
154
154
  end
155
-
155
+
156
156
  it "should set the name" do
157
157
  @job.meta[:name].should == 'egg.png'
158
158
  end
@@ -188,7 +188,7 @@ describe Dragonfly::Job do
188
188
  @job.fetch_url!('some.place.com/dung.beetle')
189
189
  @job.meta[:name].should == 'dung.beetle'
190
190
  end
191
-
191
+
192
192
  it "should set the name url_attr if there is one" do
193
193
  @job.fetch_url!('some.place.com/dung.beetle')
194
194
  @job.url_attrs.should == {:name =>'dung.beetle'}
@@ -255,18 +255,18 @@ describe Dragonfly::Job do
255
255
  describe "encode" do
256
256
  before(:each) do
257
257
  @job.url_attrs = {:name => 'boid'}
258
- @job.encode!(:gif, :bitrate => 'mumma')
258
+ @job.encode!(:gif, 'bitrate' => 'mumma')
259
259
  end
260
260
 
261
261
  it { @job.steps.should match_steps([Dragonfly::Job::Encode]) }
262
262
 
263
263
  it "should use the encoder when applied" do
264
- @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return('alo')
264
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, 'bitrate' => 'mumma').and_return('alo')
265
265
  @job.data.should == 'alo'
266
266
  end
267
267
 
268
268
  it "should maintain the meta and update the format" do
269
- @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return('alo')
269
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, 'bitrate' => 'mumma').and_return('alo')
270
270
  @job.meta.should == {:name => 'hello.txt', :a => :b, :format => :gif}
271
271
  end
272
272
 
@@ -276,20 +276,20 @@ describe Dragonfly::Job do
276
276
  end
277
277
 
278
278
  it "should allow returning an array with extra attributes form the encoder" do
279
- @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return(['alo', {:name => 'doobie', :eggs => 'fish'}])
279
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, 'bitrate' => 'mumma').and_return(['alo', {:name => 'doobie', :eggs => 'fish'}])
280
280
  @job.data.should == 'alo'
281
281
  @job.meta.should == {:name => 'doobie', :a => :b, :eggs => 'fish', :format => :gif}
282
282
  end
283
283
 
284
284
  it "not allow overriding the format" do
285
- @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return(['alo', {:format => :png}])
285
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, 'bitrate' => 'mumma').and_return(['alo', {:format => :png}])
286
286
  @job.apply.meta[:format].should == :gif
287
287
  end
288
288
 
289
289
  it "should maintain the url_attrs" do
290
290
  @job.url_attrs[:name].should == 'boid'
291
291
  end
292
-
292
+
293
293
  end
294
294
  end
295
295
 
@@ -452,12 +452,12 @@ describe Dragonfly::Job do
452
452
  job.fetch! 'some_uid'
453
453
  job.generate! :plasma # you wouldn't really call this after fetch but still works
454
454
  job.process! :resize, '30x40'
455
- job.encode! :gif, :bitrate => 20
455
+ job.encode! :gif, 'bitrate' => 20
456
456
  job.to_a.should == [
457
- [:f, 'some_uid'],
458
- [:g, :plasma],
459
- [:p, :resize, '30x40'],
460
- [:e, :gif, {:bitrate => 20}]
457
+ ['f', 'some_uid'],
458
+ ['g', :plasma],
459
+ ['p', :resize, '30x40'],
460
+ ['e', :gif, {'bitrate' => 20}]
461
461
  ]
462
462
  end
463
463
  end
@@ -471,10 +471,10 @@ describe Dragonfly::Job do
471
471
  describe "a well-defined array" do
472
472
  before(:each) do
473
473
  @job = Dragonfly::Job.from_a([
474
- [:f, 'some_uid'],
475
- [:g, :plasma],
476
- [:p, :resize, '30x40'],
477
- [:e, :gif, {:bitrate => 20}]
474
+ ['f', 'some_uid'],
475
+ ['g', 'plasma'],
476
+ ['p', 'resize', '30x40'],
477
+ ['e', 'gif', {'bitrate' => 20}]
478
478
  ], @app)
479
479
  end
480
480
  it "should have the correct step types" do
@@ -487,9 +487,9 @@ describe Dragonfly::Job do
487
487
  end
488
488
  it "should have the correct args" do
489
489
  @job.steps[0].args.should == ['some_uid']
490
- @job.steps[1].args.should == [:plasma]
491
- @job.steps[2].args.should == [:resize, '30x40']
492
- @job.steps[3].args.should == [:gif, {:bitrate => 20}]
490
+ @job.steps[1].args.should == ['plasma']
491
+ @job.steps[2].args.should == ['resize', '30x40']
492
+ @job.steps[3].args.should == ['gif', {'bitrate' => 20}]
493
493
  end
494
494
  it "should have no applied steps" do
495
495
  @job.applied_steps.should be_empty
@@ -500,10 +500,10 @@ describe Dragonfly::Job do
500
500
  end
501
501
 
502
502
  [
503
- :f,
504
- [:f],
503
+ 'f',
504
+ ['f'],
505
505
  [[]],
506
- [[:egg]]
506
+ [['egg']]
507
507
  ].each do |object|
508
508
  it "should raise an error if the object passed in is #{object.inspect}" do
509
509
  lambda {
@@ -521,22 +521,23 @@ describe Dragonfly::Job do
521
521
  describe "serialization" do
522
522
  before(:each) do
523
523
  @app = test_app
524
- @job = Dragonfly::Job.new(@app).fetch('uid').process(:resize_and_crop, :width => 270, :height => 92, :gravity => 'n')
524
+ @job = Dragonfly::Job.new(@app).fetch('uid').process(:resize_and_crop, 'width' => 270, 'height' => 92, 'gravity' => 'n')
525
525
  end
526
526
  it "should serialize itself" do
527
527
  @job.serialize.should =~ /^\w{1,}$/
528
528
  end
529
529
  it "should deserialize to the same as the original" do
530
530
  new_job = Dragonfly::Job.deserialize(@job.serialize, @app)
531
- new_job.to_a.should == @job.to_a
532
- end
533
- it "should correctly deserialize a string serialized with ruby 1.8.7" do
534
- job = Dragonfly::Job.deserialize('BAhbB1sHOgZmSSIIdWlkBjoGRVRbCDoGcDoUcmVzaXplX2FuZF9jcm9wewg6CndpZHRoaQIOAToLaGVpZ2h0aWE6DGdyYXZpdHlJIgZuBjsGVA', @app)
535
- job.to_a.should == @job.to_a
536
- end
537
- it "should correctly deserialize a string serialized with ruby 1.9.2" do
538
- job = Dragonfly::Job.deserialize('BAhbB1sHOgZmIgh1aWRbCDoGcDoUcmVzaXplX2FuZF9jcm9wewg6CndpZHRoaQIOAToLaGVpZ2h0aWE6DGdyYXZpdHkiBm4', @app)
539
- job.to_a.should == @job.to_a
531
+
532
+ new_job.steps.length.should == 2
533
+ fetch_step, process_step = new_job.steps
534
+
535
+ fetch_step.should be_a(Dragonfly::Job::Fetch)
536
+ fetch_step.uid.should == 'uid'
537
+
538
+ process_step.should be_a(Dragonfly::Job::Process)
539
+ process_step.name.should == :resize_and_crop
540
+ process_step.arguments.should == [{'width' => 270, 'height' => 92, 'gravity' => 'n'}]
540
541
  end
541
542
  end
542
543
 
@@ -561,7 +562,7 @@ describe Dragonfly::Job do
561
562
  it "should return nil if there are no steps" do
562
563
  @job.url.should be_nil
563
564
  end
564
-
565
+
565
566
  describe "using url_attrs in the url" do
566
567
  before(:each) do
567
568
  @app.server.url_format = '/media/:job/:zoo'
@@ -585,7 +586,7 @@ describe Dragonfly::Job do
585
586
  @job.url_attrs[:zoo] = 'hair'
586
587
  @job.url(:zoo => 'dare').should == "/media/#{@job.serialize}/dare"
587
588
  end
588
-
589
+
589
590
  describe "basename" do
590
591
  before(:each) do
591
592
  @app.server.url_format = '/:job/:basename'
@@ -649,7 +650,7 @@ describe Dragonfly::Job do
649
650
  new_job = @job.to_fetched_job('some_uid')
650
651
  new_job.data.should == 'HELLO'
651
652
  new_job.to_a.should == [
652
- [:f, 'some_uid']
653
+ ['f', 'some_uid']
653
654
  ]
654
655
  new_job.pending_steps.should be_empty
655
656
  end
@@ -667,7 +668,7 @@ describe Dragonfly::Job do
667
668
 
668
669
  describe "to_unique_s" do
669
670
  it "should use the arrays of args to create the string" do
670
- job = test_app.fetch('uid').process(:gug, 4, :some => 'arg', :and => 'more')
671
+ job = test_app.fetch('uid').process(:gug, 4, 'some' => 'arg', 'and' => 'more')
671
672
  job.to_unique_s.should == 'fuidpgug4andmoresomearg'
672
673
  end
673
674
  end
@@ -677,15 +678,15 @@ describe Dragonfly::Job do
677
678
  @app = test_app
678
679
  @job = @app.fetch('eggs')
679
680
  end
680
-
681
+
681
682
  it "should be of the correct format" do
682
683
  @job.sha.should =~ /^\w{8}$/
683
684
  end
684
-
685
+
685
686
  it "should be the same for the same job steps" do
686
687
  @app.fetch('eggs').sha.should == @job.sha
687
688
  end
688
-
689
+
689
690
  it "should be different for different jobs" do
690
691
  @app.fetch('figs').sha.should_not == @job.sha
691
692
  end
@@ -751,7 +752,7 @@ describe Dragonfly::Job do
751
752
  before(:each) do
752
753
  @app = test_app
753
754
  end
754
-
755
+
755
756
  describe "fetch_step" do
756
757
  it "should return nil if it doesn't exist" do
757
758
  @app.generate(:ponies).process(:jam).fetch_step.should be_nil
@@ -814,10 +815,10 @@ describe Dragonfly::Job do
814
815
  it "should return the generate step otherwise" do
815
816
  step = @app.generate(:ponies).process(:cheese).generate_step
816
817
  step.should be_a(Dragonfly::Job::Generate)
817
- step.args.should == [:ponies]
818
+ step.name.should == :ponies
818
819
  end
819
820
  end
820
-
821
+
821
822
  describe "process_steps" do
822
823
  it "should return the processing steps" do
823
824
  job = @app.fetch('many/ponies').process(:jam).process(:eggs).encode(:gif)
@@ -838,7 +839,7 @@ describe Dragonfly::Job do
838
839
  step.format.should == :cheese
839
840
  end
840
841
  end
841
-
842
+
842
843
  describe "step_types" do
843
844
  it "should return the step types" do
844
845
  job = @app.fetch('eggs').process(:beat, 'strongly').encode(:meringue)
@@ -2,9 +2,9 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Dragonfly::Serializer do
5
-
5
+
6
6
  include Dragonfly::Serializer
7
-
7
+
8
8
  [
9
9
  'a',
10
10
  'sdhflasd',
@@ -22,21 +22,7 @@ describe Dragonfly::Serializer do
22
22
  str.should == string
23
23
  end
24
24
  end
25
-
26
- describe "replacing the '/' character in b64_encode" do
27
- before(:each) do
28
- @string = (127..255).map{|c| c.chr }.join
29
- end
30
- it "should replace '/' with '~'" do
31
- b64_encode(@string).should_not =~ /\//
32
- b64_encode(@string).should =~ /[\w+]+~[\w+]+/
33
- end
34
- it "should correctly encode and decode to the same string" do
35
- str = b64_decode(b64_encode(@string))
36
- str.should == @string
37
- end
38
- end
39
-
25
+
40
26
  [
41
27
  :hello,
42
28
  nil,
@@ -50,7 +36,6 @@ describe Dragonfly::Serializer do
50
36
  ].each do |object|
51
37
  it "should correctly marshal encode #{object.inspect} properly with no padding/line break" do
52
38
  encoded = marshal_encode(object)
53
- # raise encoded.index("\n").inspect
54
39
  encoded.should be_a(String)
55
40
  encoded.should_not =~ /\n|=/
56
41
  end
@@ -58,7 +43,7 @@ describe Dragonfly::Serializer do
58
43
  marshal_decode(marshal_encode(object)).should == object
59
44
  end
60
45
  end
61
-
46
+
62
47
  describe "marshal_decode" do
63
48
  it "should raise an error if the string passed in is empty" do
64
49
  lambda{
@@ -71,5 +56,36 @@ describe Dragonfly::Serializer do
71
56
  }.should raise_error(Dragonfly::Serializer::BadString)
72
57
  end
73
58
  end
74
-
59
+
60
+ [
61
+ [3,4,5],
62
+ {'wo' => 'there'},
63
+ [{'this' => 'should', 'work' => [3, 5.3, nil, {'egg' => false}]}, [], true]
64
+ ].each do |object|
65
+ it "should correctly json encode #{object.inspect} properly with no padding/line break" do
66
+ encoded = json_encode(object)
67
+ encoded.should be_a(String)
68
+ encoded.should_not =~ /\n|=/
69
+ end
70
+ it "should correctly json encode and decode #{object.inspect} to the same object" do
71
+ json_decode(json_encode(object)).should == object
72
+ end
73
+ end
74
+
75
+ describe "json_decode" do
76
+ it "optionally symbolizes keys" do
77
+ json_decode(json_encode('a' => 1), :symbolize_keys => true).should == {:a => 1}
78
+ end
79
+ it "should raise an error if the string passed in is empty" do
80
+ lambda{
81
+ json_decode('')
82
+ }.should raise_error(Dragonfly::Serializer::BadString)
83
+ end
84
+ it "should raise an error if the string passed in is gobbledeegook" do
85
+ lambda{
86
+ json_decode('ahasdkjfhasdkfjh')
87
+ }.should raise_error(Dragonfly::Serializer::BadString)
88
+ end
89
+ end
90
+
75
91
  end
@@ -9,7 +9,7 @@ end
9
9
  describe Dragonfly::Server do
10
10
 
11
11
  describe "responses" do
12
-
12
+
13
13
  before(:each) do
14
14
  @app = test_app
15
15
  @uid = @app.store('HELLO THERE')
@@ -17,7 +17,7 @@ describe Dragonfly::Server do
17
17
  @server.url_format = '/media/:job'
18
18
  @job = @app.fetch(@uid)
19
19
  end
20
-
20
+
21
21
  after(:each) do
22
22
  @app.destroy(@uid)
23
23
  end
@@ -26,13 +26,13 @@ describe Dragonfly::Server do
26
26
  before(:each) do
27
27
  @server.url_format = '/media/:job/:name.:format'
28
28
  end
29
-
29
+
30
30
  [
31
31
  '',
32
32
  '/name',
33
33
  '/name.ext'
34
34
  ].each do |suffix|
35
-
35
+
36
36
  it "should return successfully when given the url with suffix #{suffix.inspect}" do
37
37
  url = "/media/#{@job.serialize}#{suffix}"
38
38
  response = request(@server, url)
@@ -40,7 +40,7 @@ describe Dragonfly::Server do
40
40
  response.body.should == 'HELLO THERE'
41
41
  response.content_type.should == 'application/octet-stream'
42
42
  end
43
-
43
+
44
44
  end
45
45
 
46
46
  it "should return successfully with the correct sha given and protection on" do
@@ -51,24 +51,6 @@ describe Dragonfly::Server do
51
51
  response.body.should == 'HELLO THERE'
52
52
  end
53
53
 
54
-
55
- it "should work ok with + symbols" do
56
- @app.processor.add(:thumb){|t, geometry| "eggs" }
57
- @app.datastore.should_receive(:retrieve).with('2011/04/20/20_55_04_114_female_1.jpg').and_return "EGGS"
58
- response = request(@server, '/media/BAhbB1sHOgZmSSIpMjAxMS8wNC8yMC8yMF81NV8wNF8xMTRfZmVtYWxlXzEuanBnBjoGRVRbCDoGcDoKdGh1bWJJIgwxMDB4NzU+BjsGVA')
59
- response.status.should == 200
60
- response.body.should == 'eggs'
61
- end
62
-
63
- it "should work ok with ~ symbols" do
64
- funny_filename = (127..255).map{|c| c.chr }.join
65
- @app.datastore.should_receive(:retrieve).with(funny_filename).and_return "EGGS"
66
- # the following is the url for 'fetch(funny_filename)'
67
- response = request(@server, '/media/BAhbBlsHOgZmIgGBf4CBgoOEhYaHiImKi4yNjo+QkZKTlJWWl5iZmpucnZ6foKGio6SlpqeoqaqrrK2ur7CxsrO0tba3uLm6u7y9vr~AwcLDxMXGx8jJysvMzc7P0NHS09TV1tfY2drb3N3e3+Dh4uPk5ebn6Onq6+zt7u~w8fLz9PX29~j5+vv8~f7~')
68
- response.status.should == 200
69
- response.body.should == 'EGGS'
70
- end
71
-
72
54
  it "should return a cacheable response" do
73
55
  url = "/media/#{@job.serialize}"
74
56
  cache = Rack::Cache.new(@server, :entitystore => 'heap:/')
@@ -96,7 +78,7 @@ describe Dragonfly::Server do
96
78
  response = request(@server, url)
97
79
  response.status.should == 400
98
80
  end
99
-
81
+
100
82
  it "should return a 400 if wrong sha given and protection on" do
101
83
  @server.protect_from_dos_attacks = true
102
84
  url = "/media/#{@job.serialize}?sha=asdfs"
@@ -113,7 +95,7 @@ describe Dragonfly::Server do
113
95
  response.headers['X-Cascade'].should == 'pass'
114
96
  end
115
97
  end
116
-
98
+
117
99
  it "should return a 404 when the url matches but doesn't correspond to a job" do
118
100
  response = request(@server, '/media/sadhfasdfdsfsdf')
119
101
  response.status.should == 404
@@ -121,7 +103,7 @@ describe Dragonfly::Server do
121
103
  response.content_type.should == 'text/plain'
122
104
  response.headers['X-Cascade'].should be_nil
123
105
  end
124
-
106
+
125
107
  it "should return a 404 when the url isn't known at all" do
126
108
  response = request(@server, '/jfasd/dsfa')
127
109
  response.status.should == 404
@@ -129,23 +111,23 @@ describe Dragonfly::Server do
129
111
  response.content_type.should == 'text/plain'
130
112
  response.headers['X-Cascade'].should == 'pass'
131
113
  end
132
-
114
+
133
115
  it "should return a 404 when the url is a well-encoded but bad array" do
134
- url = "/media/#{Dragonfly::Serializer.marshal_encode([[:egg, {:some => 'args'}]])}"
116
+ url = "/media/#{Dragonfly::Serializer.json_encode([['egg', {'some' => 'args'}]])}"
135
117
  response = request(@server, url)
136
118
  response.status.should == 404
137
119
  response.body.should == 'Not found'
138
120
  response.content_type.should == 'text/plain'
139
121
  response.headers['X-Cascade'].should be_nil
140
122
  end
141
-
123
+
142
124
  it "should return a 403 Forbidden when someone uses fetch_file" do
143
125
  response = request(@server, "/media/#{@app.fetch_file('/some/file.txt').serialize}")
144
126
  response.status.should == 403
145
127
  response.body.should == 'Forbidden'
146
128
  response.content_type.should == 'text/plain'
147
129
  end
148
-
130
+
149
131
  it "should return a 403 Forbidden when someone uses fetch_url" do
150
132
  response = request(@server, "/media/#{@app.fetch_url('some.url').serialize}")
151
133
  response.status.should == 403
@@ -155,14 +137,14 @@ describe Dragonfly::Server do
155
137
  end
156
138
 
157
139
  end
158
-
140
+
159
141
  describe "dragonfly response" do
160
142
  before(:each) do
161
143
  @app = test_app
162
144
  @server = Dragonfly::Server.new(@app)
163
145
  @server.url_format = '/media/:job'
164
146
  end
165
-
147
+
166
148
  it "should return a simple text response" do
167
149
  request(@server, '/dragonfly').should be_a_text_response
168
150
  end
@@ -181,30 +163,30 @@ describe Dragonfly::Server do
181
163
  end
182
164
 
183
165
  describe "urls" do
184
-
166
+
185
167
  before(:each) do
186
168
  @app = test_app
187
169
  @server = Dragonfly::Server.new(@app)
188
170
  @server.url_format = '/media/:job/:basename.:format'
189
171
  @job = @app.fetch('some_uid')
190
172
  end
191
-
173
+
192
174
  it "should generate the correct url when no basename/format" do
193
175
  @server.url_for(@job).should == "/media/#{@job.serialize}"
194
176
  end
195
-
177
+
196
178
  it "should generate the correct url when there is a basename and no format" do
197
179
  @server.url_for(@job, :basename => 'hello').should == "/media/#{@job.serialize}/hello"
198
180
  end
199
-
181
+
200
182
  it "should generate the correct url when there is a basename and different format" do
201
183
  @server.url_for(@job, :basename => 'hello', :format => 'gif').should == "/media/#{@job.serialize}/hello.gif"
202
184
  end
203
185
 
204
186
  it "should add extra params to the url query string" do
205
- @server.url_for(@job, :a => 'thing', :b => 'nuther').should == "/media/#{@job.serialize}?a=thing&b=nuther"
187
+ @server.url_for(@job, :a => 'thing', :b => 'nuther').should match_url "/media/#{@job.serialize}?a=thing&b=nuther"
206
188
  end
207
-
189
+
208
190
  it "should add the host to the url if configured" do
209
191
  @server.url_host = 'http://some.server:4000'
210
192
  @server.url_for(@job).should == "http://some.server:4000/media/#{@job.serialize}"
@@ -218,7 +200,7 @@ describe Dragonfly::Server do
218
200
  @server.url_host = 'http://some.server:4000'
219
201
  @server.url_for(@job, :host => 'https://smeedy').should == "https://smeedy/media/#{@job.serialize}"
220
202
  end
221
-
203
+
222
204
  describe "Denial of Service protection" do
223
205
  before(:each) do
224
206
  @app = test_app
@@ -269,12 +251,12 @@ describe Dragonfly::Server do
269
251
  throw :halt, [200, {}, ['hello']]
270
252
  end
271
253
  end
272
-
254
+
273
255
  it 'return the specified response instead of job.result' do
274
256
  response = request(@server, "/#{@job.serialize}")
275
257
  response.body.should == 'hello'
276
258
  end
277
-
259
+
278
260
  it "should not apply the job if not asked to" do
279
261
  @app.generator.should_not_receive(:generate)
280
262
  response = request(@server, "/#{@job.serialize}")