dragonfly 0.7.5 → 0.7.6

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.

@@ -8,23 +8,23 @@ end
8
8
  describe Dragonfly::App do
9
9
 
10
10
  describe ".instance" do
11
-
11
+
12
12
  it "should create a new instance if it didn't already exist" do
13
13
  app = Dragonfly::App.instance(:images)
14
14
  app.should be_a(Dragonfly::App)
15
15
  end
16
-
16
+
17
17
  it "should return an existing instance if called by name" do
18
18
  app = Dragonfly::App.instance(:images)
19
19
  Dragonfly::App.instance(:images).should == app
20
20
  end
21
-
21
+
22
22
  it "should also work using square brackets" do
23
23
  Dragonfly[:images].should == Dragonfly::App.instance(:images)
24
24
  end
25
-
25
+
26
26
  end
27
-
27
+
28
28
  describe ".new" do
29
29
  it "should not be callable" do
30
30
  lambda{
@@ -69,7 +69,7 @@ describe Dragonfly::App do
69
69
  other_app.mime_type_for(:mark).should == 'second/one'
70
70
  end
71
71
  end
72
-
72
+
73
73
  describe "#resolve_mime_type" do
74
74
  before(:each) do
75
75
  @app = test_app
@@ -129,7 +129,7 @@ describe Dragonfly::App do
129
129
  end
130
130
 
131
131
  end
132
-
132
+
133
133
  end
134
134
 
135
135
  describe "without path prefix or DOS protection" do
@@ -184,7 +184,40 @@ describe Dragonfly::App do
184
184
  @app.url_for(@job, :host => 'https://smeedy').should =~ %r{^https://smeedy/\w+$}
185
185
  end
186
186
  end
187
+
188
+ describe "url_suffix" do
189
+ before(:each) do
190
+ @app = test_app
191
+ @job = Dragonfly::Job.new(@app)
192
+ end
193
+ it "should add the suffix to the url if configured" do
194
+ @app.url_suffix = 'hellodudes'
195
+ @app.url_for(@job).should =~ /\w+hellodudes$/
196
+ end
197
+ it "should add the suffix to the url if passed in" do
198
+ @app.url_for(@job, :suffix => '/howdy.pardner').should =~ /\w+\/howdy\.pardner$/
199
+ end
200
+ it "should favour the passed in one" do
201
+ @app.url_suffix = 'hellodudes'
202
+ @app.url_for(@job, :suffix => '/howdy.pardner').should =~ /\w+\/howdy\.pardner$/
203
+ end
204
+ it "should accept a proc yielding the job" do
205
+ @app.url_suffix = proc{|job| job.uid }
206
+ @job.fetch!('some_uid')
207
+ @app.url_for(@job).should =~ /\w+some_uid$/
208
+ end
209
+ end
187
210
 
211
+ describe "url params" do
212
+ before(:each) do
213
+ @app = test_app
214
+ @job = Dragonfly::Job.new(@app)
215
+ end
216
+ it "should add extra params to the url query string" do
217
+ @app.url_for(@job, :suffix => '/suffix', :a => 'thing', :b => 'nuther').should =~ /\w+\/suffix\?a=thing&b=nuther$/
218
+ end
219
+ end
220
+
188
221
  describe "Denial of Service protection" do
189
222
  before(:each) do
190
223
  @app = test_app
@@ -200,7 +233,7 @@ describe Dragonfly::App do
200
233
  before(:each) do
201
234
  @app = test_app
202
235
  end
203
-
236
+
204
237
  {
205
238
  :rmagick => Dragonfly::Config::RMagick,
206
239
  :r_magick => Dragonfly::Config::RMagick,
@@ -108,11 +108,9 @@ describe Dragonfly::Configurable do
108
108
  @lazy.sound.should == 'mooo!'
109
109
  @lazy.sound.should == 'mooo!'
110
110
  end
111
- it "should also call a block which has been set as part of the configuration" do
112
- @cow.should_receive(:fart).exactly(:once).and_return('paaarrp!')
111
+ it "should not call an explicitly passed in proc" do
113
112
  @lazy.configure{|c| c.sound = lambda{ @cow.fart }}
114
- @lazy.sound.should == 'paaarrp!'
115
- @lazy.sound.should == 'paaarrp!'
113
+ @lazy.sound.should be_a(Proc)
116
114
  end
117
115
  end
118
116
 
@@ -58,7 +58,7 @@ describe Dragonfly::DataStorage::FileDataStore do
58
58
 
59
59
  it "should use a different filename" do
60
60
  touch_file("#{@file_pattern_prefix}file")
61
- @data_store.should_receive(:disambiguate).with('file').and_return('file_2')
61
+ @data_store.should_receive(:disambiguate).with("#{@file_pattern_prefix}file").and_return("#{@file_pattern_prefix}file_2")
62
62
  it_should_write_to_file("#{@file_pattern_prefix}file_2", @temp_object)
63
63
  @data_store.store(@temp_object)
64
64
  end
@@ -66,19 +66,32 @@ describe Dragonfly::DataStorage::FileDataStore do
66
66
  it "should use a different filename taking into account the name and ext" do
67
67
  @temp_object.should_receive(:name).at_least(:once).and_return('hello.png')
68
68
  touch_file("#{@file_pattern_prefix}hello.png")
69
- @data_store.should_receive(:disambiguate).with('hello.png').and_return('blah.png')
69
+ @data_store.should_receive(:disambiguate).with("#{@file_pattern_prefix}hello.png").and_return("#{@file_pattern_prefix}blah.png")
70
70
  @data_store.store(@temp_object)
71
71
  end
72
72
 
73
73
  it "should keep trying until it finds a free filename" do
74
74
  touch_file("#{@file_pattern_prefix}file")
75
75
  touch_file("#{@file_pattern_prefix}file_2")
76
- @data_store.should_receive(:disambiguate).with('file').and_return('file_2')
77
- @data_store.should_receive(:disambiguate).with('file_2').and_return('file_3')
76
+ @data_store.should_receive(:disambiguate).with("#{@file_pattern_prefix}file").and_return("#{@file_pattern_prefix}file_2")
77
+ @data_store.should_receive(:disambiguate).with("#{@file_pattern_prefix}file_2").and_return("#{@file_pattern_prefix}file_3")
78
78
  it_should_write_to_file("#{@file_pattern_prefix}file_3", @temp_object)
79
79
  @data_store.store(@temp_object)
80
80
  end
81
81
 
82
+ describe "specifying the uid" do
83
+ it "should allow for specifying the path to use" do
84
+ it_should_write_to_file("#{@data_store.root_path}/hello/there/mate.png", @temp_object)
85
+ @data_store.store(@temp_object, :path => 'hello/there/mate.png')
86
+ end
87
+ it "should correctly disambiguate if the file exists" do
88
+ touch_file("#{@data_store.root_path}/hello/there/mate.png")
89
+ @data_store.should_receive(:disambiguate).with("#{@data_store.root_path}/hello/there/mate.png").and_return("#{@data_store.root_path}/hello/there/mate_2.png")
90
+ it_should_write_to_file("#{@data_store.root_path}/hello/there/mate_2.png", @temp_object)
91
+ @data_store.store(@temp_object, :path => 'hello/there/mate.png')
92
+ end
93
+ end
94
+
82
95
  end
83
96
 
84
97
  describe "return value" do
@@ -98,13 +111,13 @@ describe Dragonfly::DataStorage::FileDataStore do
98
111
 
99
112
  describe "disambiguate" do
100
113
  it "should add a suffix" do
101
- @data_store.disambiguate('file').should =~ /^file_\w+$/
114
+ @data_store.disambiguate('/some/file').should =~ %r{^/some/file_\w+$}
102
115
  end
103
116
  it "should add a suffix to the basename" do
104
- @data_store.disambiguate('file.png').should =~ /^file_\w+\.png$/
117
+ @data_store.disambiguate('/some/file.png').should =~ %r{^/some/file_\w+\.png$}
105
118
  end
106
119
  it "should be random(-ish)" do
107
- @data_store.disambiguate('file').should_not == @data_store.disambiguate('file')
120
+ @data_store.disambiguate('/some/file').should_not == @data_store.disambiguate('/some/file')
108
121
  end
109
122
  end
110
123
 
@@ -1,33 +1,41 @@
1
1
  require File.dirname(__FILE__) + '/../../spec_helper'
2
2
  require File.dirname(__FILE__) + '/data_store_spec'
3
+ require 'yaml'
3
4
 
4
5
  describe Dragonfly::DataStorage::S3DataStore do
5
6
 
6
7
  # Change this to test it with an actual internet connection
7
- enabled = false
8
-
8
+ if File.exist?(file = File.expand_path('../../../../.s3_spec.yml', __FILE__))
9
+ config = YAML.load_file(file)
10
+ KEY = config['key']
11
+ SECRET = config['secret']
12
+ enabled = config['enabled']
13
+ else
14
+ enabled = false
15
+ end
16
+
9
17
  if enabled
10
18
 
11
19
  describe "common data_store behaviour" do
12
-
20
+
13
21
  before(:each) do
14
22
  @data_store = Dragonfly::DataStorage::S3DataStore.new
15
23
  @data_store.configure do |d|
16
24
  d.bucket_name = 'dragonfly_test'
17
- d.access_key_id = 'XXX'
18
- d.secret_access_key = 'XXX'
25
+ d.access_key_id = KEY
26
+ d.secret_access_key = SECRET
19
27
  end
20
28
  end
21
-
29
+
22
30
  it_should_behave_like 'data_store'
23
-
31
+
24
32
  describe "store" do
25
33
  it "should return a unique identifier for each storage" do
26
34
  temp_object = Dragonfly::TempObject.new('gollum')
27
35
  temp_object2 = Dragonfly::TempObject.new('gollum')
28
36
  @data_store.store(temp_object).should_not == @data_store.store(temp_object2)
29
37
  end
30
-
38
+
31
39
  it "should work ok with files with funny names" do
32
40
  temp_object = Dragonfly::TempObject.new('eggheads',
33
41
  :name => 'A Picture with many spaces in its name (at 20:00 pm).png'
@@ -37,8 +45,16 @@ describe Dragonfly::DataStorage::S3DataStore do
37
45
  data, extra = @data_store.retrieve(uid)
38
46
  data.should == 'eggheads'
39
47
  end
48
+
49
+ it "should allow for setting the path manually" do
50
+ temp_object = Dragonfly::TempObject.new('eggheads')
51
+ uid = @data_store.store(temp_object, :path => 'hello/there')
52
+ uid.should == 'hello/there'
53
+ data, extra = @data_store.retrieve(uid)
54
+ data.should == 'eggheads'
55
+ end
40
56
  end
41
-
57
+
42
58
  end
43
59
 
44
60
  end
@@ -1,6 +1,7 @@
1
+ # encoding: utf-8
1
2
  require File.dirname(__FILE__) + '/../spec_helper'
2
3
 
3
- ## General tests for Endpoint module go here as it's a pretty simple wrapper around that
4
+ ## General tests for Response go here as it's a pretty simple wrapper around that
4
5
 
5
6
  describe Dragonfly::JobEndpoint do
6
7
 
@@ -9,58 +10,111 @@ describe Dragonfly::JobEndpoint do
9
10
  Rack::MockRequest.new(endpoint).get('', opts)
10
11
  end
11
12
 
12
- describe "errors" do
13
+ before(:each) do
14
+ @app = test_app
15
+ @app.datastore.stub!(:retrieve).with('egg').and_return(["GUNGLE", {:name => 'gung.txt'}])
16
+ @job = Dragonfly::Job.new(@app).fetch('egg')
17
+ end
13
18
 
14
- before(:each) do
15
- @app = test_app
16
- @app.datastore.stub!(:retrieve).with('egg').and_return(["GUNGLE", {:name => 'gung.txt'}])
17
- @job = Dragonfly::Job.new(@app).fetch('egg')
18
- end
19
+ it "should return a correct response if successful" do
20
+ response = make_request(@job)
21
+ response.status.should == 200
22
+ response['ETag'].should =~ /^"\w+"$/
23
+ response['Cache-Control'].should == "public, max-age=31536000"
24
+ response['Content-Type'].should == 'text/plain'
25
+ response['Content-Length'].should == '6'
26
+ response['Content-Disposition'].should == 'filename="gung.txt"'
27
+ response.body.should == 'GUNGLE'
28
+ end
19
29
 
20
- it "should return a correct response if successful" do
30
+ it "should return 404 if the datastore raises data not found" do
31
+ @job.should_receive(:apply).and_raise(Dragonfly::DataStorage::DataNotFound)
32
+ response = make_request(@job)
33
+ response.status.should == 404
34
+ end
35
+
36
+ describe "ETag" do
37
+ it "should return an ETag" do
21
38
  response = make_request(@job)
22
- response.status.should == 200
23
- response['ETag'].should =~ /^"\w+"$/
24
- response['Cache-Control'].should == "public, max-age=31536000"
25
- response['Content-Type'].should == 'text/plain'
26
- response['Content-Length'].should == '6'
27
- response.body.should == 'GUNGLE'
39
+ response.headers['ETag'].should =~ /^"\w+"$/
28
40
  end
29
41
 
30
- it "should return 404 if the datastore raises data not found" do
31
- @job.should_receive(:apply).and_raise(Dragonfly::DataStorage::DataNotFound)
32
- response = make_request(@job)
33
- response.status.should == 404
42
+ [
43
+ "dingle",
44
+ "dingle, eggheads",
45
+ '"dingle", "eggheads"',
46
+ '*'
47
+ ].each do |header|
48
+ it "should return a 304 if the correct ETag is specified in HTTP_IF_NONE_MATCH header e.g. #{header}" do
49
+ @job.should_receive(:unique_signature).at_least(:once).and_return('dingle')
50
+ response = make_request(@job, 'HTTP_IF_NONE_MATCH' => header)
51
+ response.status.should == 304
52
+ response['ETag'].should == '"dingle"'
53
+ response['Cache-Control'].should == "public, max-age=31536000"
54
+ response.body.should be_empty
55
+ end
56
+ end
57
+
58
+ it "should not have applied any steps if the correct ETag is specified in HTTP_IF_NONE_MATCH header" do
59
+ response = make_request(@job, 'HTTP_IF_NONE_MATCH' => @job.unique_signature)
60
+ @job.applied_steps.should be_empty
61
+ end
62
+ end
63
+
64
+ describe "Content Disposition" do
65
+ before(:each) do
66
+ @app.encoder.add{|temp_object, format| temp_object }
34
67
  end
35
68
 
36
- describe "ETag" do
37
- it "should return an ETag" do
69
+ describe "filename" do
70
+ it "should return the original name" do
38
71
  response = make_request(@job)
39
- response.headers['ETag'].should =~ /^"\w+"$/
72
+ response['Content-Disposition'].should == 'filename="gung.txt"'
40
73
  end
41
-
42
- [
43
- "dingle",
44
- "dingle, eggheads",
45
- '"dingle", "eggheads"',
46
- '*'
47
- ].each do |header|
48
- it "should return a 304 if the correct ETag is specified in HTTP_IF_NONE_MATCH header e.g. #{header}" do
49
- @job.should_receive(:unique_signature).at_least(:once).and_return('dingle')
50
- response = make_request(@job, 'HTTP_IF_NONE_MATCH' => header)
51
- response.status.should == 304
52
- response['ETag'].should == '"dingle"'
53
- response['Cache-Control'].should == "public, max-age=31536000"
54
- response.body.should be_empty
55
- end
74
+ it "should return a filename with a different extension if it's been encoded" do
75
+ response = make_request(@job.encode(:doogs))
76
+ response['Content-Disposition'].should == 'filename="gung.doogs"'
56
77
  end
57
-
58
- it "should not have applied any steps if the correct ETag is specified in HTTP_IF_NONE_MATCH header" do
59
- response = make_request(@job, 'HTTP_IF_NONE_MATCH' => @job.unique_signature)
60
- @job.applied_steps.should be_empty
78
+ it "should not have the filename if name doesn't exist" do
79
+ response = make_request(@app.new_job("ADFSDF"))
80
+ response['Content-Disposition'].should be_nil
81
+ end
82
+ it "should cope with filenames with no ext" do
83
+ response = make_request(@app.new_job("ASDF", :name => 'asdf'))
84
+ response['Content-Disposition'].should == 'filename="asdf"'
85
+ end
86
+ it "should uri encode funny characters" do
87
+ response = make_request(@app.new_job("ASDF", :name => '£@$£ `'))
88
+ response['Content-Disposition'].should == 'filename="%C2%A3@$%C2%A3%20%60"'
89
+ end
90
+ it "should allow for setting the filename using a block" do
91
+ @app.content_filename = proc{|job, request|
92
+ job.basename.reverse.upcase + request['a']
93
+ }
94
+ response = make_request(@job, 'QUERY_STRING' => 'a=egg')
95
+ response['Content-Disposition'].should == 'filename="GNUGegg"'
96
+ end
97
+ it "should not include the filename if configured to be nil" do
98
+ @app.content_filename = nil
99
+ response = make_request(@job)
100
+ response['Content-Disposition'].should be_nil
101
+ end
102
+ end
103
+
104
+ describe "content disposition" do
105
+ it "should use the app's configured content-disposition" do
106
+ @app.content_disposition = :attachment
107
+ response = make_request(@job)
108
+ response['Content-Disposition'].should == 'attachment; filename="gung.txt"'
109
+ end
110
+ it "should allow using a block to set the content disposition" do
111
+ @app.content_disposition = proc{|job, request|
112
+ job.basename + request['blah']
113
+ }
114
+ response = make_request(@job, 'QUERY_STRING' => 'blah=yo')
115
+ response['Content-Disposition'].should == 'gungyo; filename="gung.txt"'
61
116
  end
62
117
  end
63
-
64
118
  end
65
119
 
66
120
  end
@@ -176,6 +176,15 @@ describe Dragonfly::Job do
176
176
  temp_object.meta.should == {:a => :b}
177
177
  temp_object.format.should == :txt
178
178
  end
179
+
180
+ it "should allow returning an array with extra attributes from the processor" do
181
+ @app.processor.should_receive(:process).with(@temp_object, :resize, '20x30').and_return(['hi', {:name => 'hello_20x30.txt', :meta => {:eggs => 'asdf'}}])
182
+ temp_object = @job.apply.temp_object
183
+ temp_object.data.should == 'hi'
184
+ temp_object.name.should == 'hello_20x30.txt'
185
+ temp_object.meta.should == {:a => :b, :eggs => 'asdf'}
186
+ temp_object.format.should == :txt
187
+ end
179
188
  end
180
189
 
181
190
  describe "encode" do
@@ -202,6 +211,20 @@ describe Dragonfly::Job do
202
211
  @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return('alo')
203
212
  @job.apply.temp_object.format.should == :gif
204
213
  end
214
+
215
+ it "should allow returning an array with extra attributes form the encoder" do
216
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return(['alo', {:name => 'doobie', :meta => {:eggs => 'fish'}}])
217
+ temp_object = @job.apply.temp_object
218
+ temp_object.data.should == 'alo'
219
+ temp_object.name.should == 'doobie'
220
+ temp_object.meta.should == {:a => :b, :eggs => 'fish'}
221
+ end
222
+
223
+ it "not allow overriding the format" do
224
+ @app.encoder.should_receive(:encode).with(@temp_object, :gif, :bitrate => 'mumma').and_return(['alo', {:format => :png}])
225
+ temp_object = @job.apply.temp_object
226
+ temp_object.format.should == :gif
227
+ end
205
228
  end
206
229
  end
207
230
 
@@ -499,6 +522,9 @@ describe Dragonfly::Job do
499
522
  Dragonfly::Job.from_path("/images/#{@serialized}", @app).should be_a(Dragonfly::Job)
500
523
  }.should raise_error(Dragonfly::Serializer::BadString)
501
524
  end
525
+ it "should ignore any suffix" do
526
+ Dragonfly::Job.from_path("/#{@serialized}asdfJASKLDF*()!@$%{}|/GGG/.png.your.mum", @app).should be_a(Dragonfly::Job)
527
+ end
502
528
  end
503
529
 
504
530
  describe "serialization" do
@@ -602,4 +628,146 @@ describe Dragonfly::Job do
602
628
  end
603
629
  end
604
630
 
631
+ describe "setting the name" do
632
+ before(:each) do
633
+ @app = test_app
634
+ @job = @app.new_job("HELLO", :name => 'not.me')
635
+ end
636
+ it "should allow setting the name" do
637
+ @job.name = 'wassup.doc'
638
+ @job.name.should == 'wassup.doc'
639
+ end
640
+ end
641
+
642
+ describe "setting the meta" do
643
+ before(:each) do
644
+ @app = test_app
645
+ @job = @app.new_job("HiThere", :meta => {:five => 'beans'})
646
+ end
647
+ it "should allow setting the meta" do
648
+ @job.meta = {:doogie => 'ladders'}
649
+ @job.meta.should == {:doogie => 'ladders'}
650
+ end
651
+ it "should allow updating the meta" do
652
+ @job.meta[:doogie] = 'ladders'
653
+ @job.meta.should == {:five => 'beans', :doogie => 'ladders'}
654
+ end
655
+ end
656
+
657
+ describe "b64_data" do
658
+ before(:each) do
659
+ @app = test_app
660
+ end
661
+ it "should return a string using the data:URI schema" do
662
+ job = @app.new_job("HELLO", :name => 'text.txt')
663
+ job.b64_data.should == "data:text/plain;base64,SEVMTE8=\n"
664
+ end
665
+ end
666
+
667
+ describe "querying stuff without applying steps" do
668
+ before(:each) do
669
+ @app = test_app
670
+ end
671
+
672
+ describe "fetch_step" do
673
+ it "should return nil if it doesn't exist" do
674
+ @app.generate(:ponies).process(:jam).fetch_step.should be_nil
675
+ end
676
+ it "should return the fetch step otherwise" do
677
+ step = @app.fetch('hello').process(:cheese).fetch_step
678
+ step.should be_a(Dragonfly::Job::Fetch)
679
+ step.uid.should == 'hello'
680
+ end
681
+ end
682
+ describe "fetched uid" do
683
+ describe "when there's no fetch step" do
684
+ before(:each) do
685
+ @job = @app.new_job("AGG")
686
+ end
687
+ it "should return nil for uid" do
688
+ @job.uid.should be_nil
689
+ end
690
+ it "should return nil for uid_basename" do
691
+ @job.uid_basename.should be_nil
692
+ end
693
+ it "should return nil for uid_extname" do
694
+ @job.uid_extname.should be_nil
695
+ end
696
+ end
697
+ describe "when there is a fetch step" do
698
+ before(:each) do
699
+ @job = @app.fetch('gungedin/innit.blud')
700
+ end
701
+ it "should return the uid" do
702
+ @job.uid.should == 'gungedin/innit.blud'
703
+ end
704
+ it "should return the uid_basename" do
705
+ @job.uid_basename.should == 'innit'
706
+ end
707
+ it "should return the uid_extname" do
708
+ @job.uid_extname.should == '.blud'
709
+ end
710
+ end
711
+ end
712
+
713
+ describe "fetch_file_step" do
714
+ it "should return nil if it doesn't exist" do
715
+ @app.generate(:ponies).process(:jam).fetch_file_step.should be_nil
716
+ end
717
+ it "should return the fetch_file step otherwise" do
718
+ step = @app.fetch_file('/my/file.png').process(:cheese).fetch_file_step
719
+ step.should be_a(Dragonfly::Job::FetchFile)
720
+ step.path.should == '/my/file.png'
721
+ end
722
+ end
723
+
724
+ describe "generate_step" do
725
+ it "should return nil if it doesn't exist" do
726
+ @app.fetch('many/ponies').process(:jam).generate_step.should be_nil
727
+ end
728
+ it "should return the generate step otherwise" do
729
+ step = @app.generate(:ponies).process(:cheese).generate_step
730
+ step.should be_a(Dragonfly::Job::Generate)
731
+ step.args.should == [:ponies]
732
+ end
733
+ end
734
+
735
+ describe "process_steps" do
736
+ it "should return the processing steps" do
737
+ job = @app.fetch('many/ponies').process(:jam).process(:eggs).encode(:gif)
738
+ job.process_steps.should match_steps([
739
+ Dragonfly::Job::Process,
740
+ Dragonfly::Job::Process
741
+ ])
742
+ end
743
+ end
744
+
745
+ describe "encode_step" do
746
+ it "should return nil if it doesn't exist" do
747
+ @app.generate(:ponies).encode_step.should be_nil
748
+ end
749
+ it "should return the last encode step otherwise" do
750
+ step = @app.fetch('hello').encode(:smells).encode(:cheese).encode_step
751
+ step.should be_a(Dragonfly::Job::Encode)
752
+ step.format.should == :cheese
753
+ end
754
+ end
755
+ describe "encoded_format" do
756
+ it "should return nil if there's no encode step" do
757
+ @app.new_job('asdf').encoded_format.should be_nil
758
+ end
759
+ it "should return the last encoded format if it exists" do
760
+ @app.fetch('gungedin').encode(:a).encode(:b).encoded_format.should == :b
761
+ end
762
+ end
763
+ describe "encoded_extname" do
764
+ it "should return nil if there's no encode step" do
765
+ @app.new_job('asdf').encoded_extname.should be_nil
766
+ end
767
+ it "should return the last encoded format as an extname if it exists" do
768
+ @app.fetch('gungedin').encode(:a).encode(:b).encoded_extname.should == '.b'
769
+ end
770
+ end
771
+ end
772
+
605
773
  end