dragonfly 0.6.2 → 0.7.0
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/.gitignore +2 -0
- data/.specopts +2 -0
- data/.yardopts +11 -5
- data/Gemfile +22 -0
- data/Gemfile.rails.2.3.5 +13 -0
- data/History.md +49 -0
- data/README.md +18 -28
- data/Rakefile +24 -36
- data/VERSION +1 -1
- data/config.ru +4 -1
- data/dragonfly.gemspec +85 -99
- data/extra_docs/Analysers.md +66 -30
- data/extra_docs/Caching.md +22 -0
- data/extra_docs/Configuration.md +116 -0
- data/extra_docs/DataStorage.md +114 -14
- data/extra_docs/Encoding.md +62 -37
- data/extra_docs/GeneralUsage.md +118 -0
- data/extra_docs/Generators.md +92 -0
- data/extra_docs/Heroku.md +51 -0
- data/extra_docs/Index.md +8 -9
- data/extra_docs/MimeTypes.md +18 -17
- data/extra_docs/Models.md +251 -0
- data/extra_docs/Processing.md +94 -70
- data/extra_docs/Rack.md +53 -0
- data/extra_docs/Rails2.md +44 -0
- data/extra_docs/Rails3.md +51 -0
- data/extra_docs/Sinatra.md +21 -0
- data/extra_docs/URLs.md +114 -0
- data/features/images.feature +6 -7
- data/features/no_processing.feature +0 -6
- data/features/rails_2.3.5.feature +1 -1
- data/features/rails_3.0.0.rc.feature +8 -0
- data/features/steps/dragonfly_steps.rb +14 -12
- data/features/steps/rails_steps.rb +20 -9
- data/features/support/env.rb +10 -11
- data/fixtures/files/app/views/albums/new.html.erb +4 -4
- data/fixtures/files/app/views/albums/show.html.erb +1 -1
- data/fixtures/files/features/manage_album_images.feature +1 -1
- data/fixtures/files/features/step_definitions/{album_steps.rb → image_steps.rb} +4 -3
- data/fixtures/files/features/support/paths.rb +2 -0
- data/fixtures/files/features/text_images.feature +7 -0
- data/fixtures/rails_3.0.0.rc/template.rb +21 -0
- data/irbrc.rb +2 -1
- data/lib/dragonfly.rb +4 -16
- data/lib/dragonfly/{active_record_extensions.rb → active_model_extensions.rb} +1 -1
- data/lib/dragonfly/active_model_extensions/attachment.rb +146 -0
- data/lib/dragonfly/{active_record_extensions → active_model_extensions}/class_methods.rb +5 -6
- data/lib/dragonfly/{active_record_extensions → active_model_extensions}/instance_methods.rb +1 -1
- data/lib/dragonfly/{active_record_extensions → active_model_extensions}/validations.rb +5 -9
- data/lib/dragonfly/analyser.rb +59 -0
- data/lib/dragonfly/analysis/file_command_analyser.rb +1 -1
- data/lib/dragonfly/analysis/r_magick_analyser.rb +46 -31
- data/lib/dragonfly/app.rb +138 -173
- data/lib/dragonfly/config/heroku.rb +19 -0
- data/lib/dragonfly/config/r_magick.rb +37 -0
- data/lib/dragonfly/config/{rails_defaults.rb → rails.rb} +6 -7
- data/lib/dragonfly/configurable.rb +30 -27
- data/lib/dragonfly/core_ext/object.rb +1 -1
- data/lib/dragonfly/data_storage/file_data_store.rb +59 -26
- data/lib/dragonfly/data_storage/mongo_data_store.rb +65 -0
- data/lib/dragonfly/data_storage/s3data_store.rb +31 -12
- data/lib/dragonfly/encoder.rb +13 -0
- data/lib/dragonfly/encoding/r_magick_encoder.rb +10 -19
- data/lib/dragonfly/endpoint.rb +43 -0
- data/lib/dragonfly/function_manager.rb +65 -0
- data/lib/dragonfly/{processing/r_magick_text_processor.rb → generation/r_magick_generator.rb} +25 -11
- data/lib/dragonfly/generator.rb +9 -0
- data/lib/dragonfly/job.rb +290 -0
- data/lib/dragonfly/job_builder.rb +39 -0
- data/lib/dragonfly/job_definitions.rb +26 -0
- data/lib/dragonfly/job_endpoint.rb +17 -0
- data/lib/dragonfly/loggable.rb +28 -0
- data/lib/dragonfly/middleware.rb +21 -14
- data/lib/dragonfly/processing/r_magick_processor.rb +71 -48
- data/lib/dragonfly/processor.rb +9 -0
- data/lib/dragonfly/r_magick_utils.rb +24 -0
- data/lib/dragonfly/rails/images.rb +10 -7
- data/lib/dragonfly/routed_endpoint.rb +42 -0
- data/lib/dragonfly/serializer.rb +32 -0
- data/lib/dragonfly/simple_cache.rb +23 -0
- data/lib/dragonfly/simple_endpoint.rb +64 -0
- data/lib/dragonfly/temp_object.rb +77 -45
- data/spec/argument_matchers.rb +7 -17
- data/spec/dragonfly/active_model_extensions/active_model_setup.rb +97 -0
- data/spec/dragonfly/active_model_extensions/active_record_setup.rb +85 -0
- data/spec/dragonfly/{active_record_extensions → active_model_extensions}/model_spec.rb +282 -244
- data/spec/dragonfly/active_model_extensions/spec_helper.rb +11 -0
- data/spec/dragonfly/analyser_spec.rb +123 -0
- data/spec/dragonfly/analysis/file_command_analyser_spec.rb +2 -2
- data/spec/dragonfly/analysis/r_magick_analyser_spec.rb +10 -1
- data/spec/dragonfly/app_spec.rb +175 -69
- data/spec/dragonfly/configurable_spec.rb +14 -0
- data/spec/dragonfly/data_storage/data_store_spec.rb +36 -9
- data/spec/dragonfly/data_storage/file_data_store_spec.rb +61 -38
- data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +18 -0
- data/spec/dragonfly/data_storage/s3_data_store_spec.rb +34 -39
- data/spec/dragonfly/deprecation_spec.rb +20 -0
- data/spec/dragonfly/function_manager_spec.rb +154 -0
- data/spec/dragonfly/generation/r_magick_generator_spec.rb +119 -0
- data/spec/dragonfly/job_builder_spec.rb +37 -0
- data/spec/dragonfly/job_definitions_spec.rb +35 -0
- data/spec/dragonfly/job_endpoint_spec.rb +66 -0
- data/spec/dragonfly/job_spec.rb +605 -0
- data/spec/dragonfly/loggable_spec.rb +80 -0
- data/spec/dragonfly/middleware_spec.rb +37 -17
- data/spec/dragonfly/processing/r_magick_processor_spec.rb +182 -166
- data/spec/dragonfly/routed_endpoint_spec.rb +48 -0
- data/spec/dragonfly/serializer_spec.rb +61 -0
- data/spec/dragonfly/simple_cache_spec.rb +27 -0
- data/spec/dragonfly/simple_endpoint_spec.rb +78 -0
- data/spec/dragonfly/temp_object_spec.rb +154 -119
- data/spec/simple_matchers.rb +22 -0
- data/spec/spec_helper.rb +28 -4
- data/yard/templates/default/layout/html/layout.erb +18 -11
- metadata +89 -190
- data/config.rb +0 -5
- data/extra_docs/ActiveRecord.md +0 -196
- data/extra_docs/ExampleUseCases.md +0 -189
- data/extra_docs/GettingStarted.md +0 -114
- data/extra_docs/Shortcuts.md +0 -118
- data/extra_docs/UsingWithRails.md +0 -81
- data/features/rails_3.0.0.beta3.feature +0 -7
- data/fixtures/rails_3.0.0.beta3/template.rb +0 -16
- data/lib/dragonfly/active_record_extensions/attachment.rb +0 -170
- data/lib/dragonfly/analyser_list.rb +0 -9
- data/lib/dragonfly/analysis/base.rb +0 -10
- data/lib/dragonfly/belongs_to_app.rb +0 -24
- data/lib/dragonfly/config/heroku_rails_images.rb +0 -23
- data/lib/dragonfly/config/r_magick_images.rb +0 -69
- data/lib/dragonfly/config/r_magick_text.rb +0 -25
- data/lib/dragonfly/config/rails_images.rb +0 -13
- data/lib/dragonfly/data_storage/base.rb +0 -21
- data/lib/dragonfly/data_storage/base64_data_store.rb +0 -23
- data/lib/dragonfly/data_storage/transparent_data_store.rb +0 -21
- data/lib/dragonfly/delegatable.rb +0 -14
- data/lib/dragonfly/delegator.rb +0 -62
- data/lib/dragonfly/encoder_list.rb +0 -9
- data/lib/dragonfly/encoding/base.rb +0 -14
- data/lib/dragonfly/encoding/transparent_encoder.rb +0 -14
- data/lib/dragonfly/extended_temp_object.rb +0 -120
- data/lib/dragonfly/parameters.rb +0 -163
- data/lib/dragonfly/processing/base.rb +0 -10
- data/lib/dragonfly/processor_list.rb +0 -9
- data/lib/dragonfly/url_handler.rb +0 -147
- data/spec/dragonfly/active_record_extensions/attachment_spec.rb +0 -8
- data/spec/dragonfly/active_record_extensions/migration.rb +0 -42
- data/spec/dragonfly/active_record_extensions/models.rb +0 -6
- data/spec/dragonfly/active_record_extensions/spec_helper.rb +0 -24
- data/spec/dragonfly/belongs_to_app_spec.rb +0 -55
- data/spec/dragonfly/delegatable_spec.rb +0 -32
- data/spec/dragonfly/delegator_spec.rb +0 -145
- data/spec/dragonfly/extended_temp_object_spec.rb +0 -71
- data/spec/dragonfly/parameters_spec.rb +0 -298
- data/spec/dragonfly/processing/r_magick_text_processor_spec.rb +0 -84
- data/spec/dragonfly/url_handler_spec.rb +0 -247
- data/spec/dragonfly_spec.rb +0 -16
- data/spec/ginger_scenarios.rb +0 -13
@@ -1,84 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
describe Dragonfly::Processing::RMagickTextProcessor do
|
4
|
-
|
5
|
-
describe "text" do
|
6
|
-
before(:each) do
|
7
|
-
@processor = Dragonfly::Processing::RMagickTextProcessor.new
|
8
|
-
@text = Dragonfly::TempObject.new("mmm")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should create a text image, defaulted to png" do
|
12
|
-
image = @processor.text(@text, :font_size => 12)
|
13
|
-
image.should have_width(20..40) # approximate
|
14
|
-
image.should have_height(10..20)
|
15
|
-
image.should have_format('png')
|
16
|
-
end
|
17
|
-
|
18
|
-
# it "should ignore percent characters used by rmagick"
|
19
|
-
|
20
|
-
describe "padding" do
|
21
|
-
before(:each) do
|
22
|
-
no_padding_text = @processor.text(@text, :font_size => 12)
|
23
|
-
@width = image_properties(no_padding_text)[:width].to_i
|
24
|
-
@height = image_properties(no_padding_text)[:height].to_i
|
25
|
-
end
|
26
|
-
it "1 number shortcut" do
|
27
|
-
image = @processor.text(@text, :padding => '10')
|
28
|
-
image.should have_width(@width + 20)
|
29
|
-
image.should have_height(@height + 20)
|
30
|
-
end
|
31
|
-
it "2 numbers shortcut" do
|
32
|
-
image = @processor.text(@text, :padding => '10 5')
|
33
|
-
image.should have_width(@width + 10)
|
34
|
-
image.should have_height(@height + 20)
|
35
|
-
end
|
36
|
-
it "3 numbers shortcut" do
|
37
|
-
image = @processor.text(@text, :padding => '10 5 8')
|
38
|
-
image.should have_width(@width + 10)
|
39
|
-
image.should have_height(@height + 18)
|
40
|
-
end
|
41
|
-
it "4 numbers shortcut" do
|
42
|
-
image = @processor.text(@text, :padding => '1 2 3 4')
|
43
|
-
image.should have_width(@width + 6)
|
44
|
-
image.should have_height(@height + 4)
|
45
|
-
end
|
46
|
-
it "should override the general padding declaration with the specific one (e.g. 'padding-left')" do
|
47
|
-
image = @processor.text(@text, :padding => '10', 'padding-left' => 9)
|
48
|
-
image.should have_width(@width + 19)
|
49
|
-
image.should have_height(@height + 20)
|
50
|
-
end
|
51
|
-
it "should ignore 'px' suffixes" do
|
52
|
-
image = @processor.text(@text, :padding => '1px 2px 3px 4px')
|
53
|
-
image.should have_width(@width + 6)
|
54
|
-
image.should have_height(@height + 4)
|
55
|
-
end
|
56
|
-
it "bad padding string" do
|
57
|
-
lambda{
|
58
|
-
@processor.text(@text, :padding => '1 2 3 4 5')
|
59
|
-
}.should raise_error(ArgumentError)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe Dragonfly::Processing::RMagickTextProcessor::HashWithCssStyleKeys do
|
65
|
-
before(:each) do
|
66
|
-
@hash = Dragonfly::Processing::RMagickTextProcessor::HashWithCssStyleKeys[
|
67
|
-
:font_style => 'normal',
|
68
|
-
:'font-weight' => 'bold',
|
69
|
-
'font_colour' => 'white',
|
70
|
-
'font-size' => 23,
|
71
|
-
:hello => 'there'
|
72
|
-
]
|
73
|
-
end
|
74
|
-
describe "accessing using underscore symbol style" do
|
75
|
-
it{ @hash[:font_style].should == 'normal' }
|
76
|
-
it{ @hash[:font_weight].should == 'bold' }
|
77
|
-
it{ @hash[:font_colour].should == 'white' }
|
78
|
-
it{ @hash[:font_size].should == 23 }
|
79
|
-
it{ @hash[:hello].should == 'there' }
|
80
|
-
it{ @hash[:non_existent_key].should be_nil }
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
@@ -1,247 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
-
|
3
|
-
describe Dragonfly::UrlHandler do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
@url_handler = Dragonfly::UrlHandler.new
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "extracting parameters from the url" do
|
10
|
-
|
11
|
-
before(:each) do
|
12
|
-
@url_handler.configure{|c| c.protect_from_dos_attacks = false}
|
13
|
-
@path = "/images/some_image.jpg"
|
14
|
-
@query_string = "m=b&o[d]=e&o[j]=k&e[l]=m"
|
15
|
-
@parameters = @url_handler.url_to_parameters(@path, @query_string)
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should correctly extract the uid" do
|
19
|
-
@parameters.uid.should == 'images/some_image'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should take into account the path prefix if there is one" do
|
23
|
-
@url_handler.path_prefix = '/images'
|
24
|
-
parameters = @url_handler.url_to_parameters('/images/2009/some_image.jpg', @query_string)
|
25
|
-
parameters.uid.should == '2009/some_image'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should raise an UnknownUrl error if the url doesn't have the path prefix" do
|
29
|
-
@url_handler.path_prefix = '/images'
|
30
|
-
lambda{
|
31
|
-
parameters = @url_handler.url_to_parameters('/wrongprefix/2009/some_image.jpg', @query_string)
|
32
|
-
}.should raise_error(Dragonfly::UrlHandler::UnknownUrl)
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should correctly extract the format" do
|
36
|
-
@parameters.format.should == 'jpg'
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should correctly extract the processing method" do
|
40
|
-
@parameters.processing_method.should == 'b'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should correctly extract the processing_options" do
|
44
|
-
@parameters.processing_options.should == {:j => 'k', :d => 'e'}
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should correctly extract the encoding" do
|
48
|
-
@parameters.encoding.should == {:l => 'm'}
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should have processing_options and encoding as optional" do
|
52
|
-
parameters = @url_handler.url_to_parameters(@path, 'm=b')
|
53
|
-
parameters.processing_options.should == {}
|
54
|
-
parameters.encoding.should == {}
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should use the parameters class passed in if initialized with one" do
|
58
|
-
parameters_class = mock('parameters_class')
|
59
|
-
url_handler = Dragonfly::UrlHandler.new(parameters_class)
|
60
|
-
url_handler.stub!(:validate_parameters)
|
61
|
-
parameters_class.should_receive(:new)
|
62
|
-
url_handler.url_to_parameters(@path, @query_string)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should not set the format if the path doesn't have an extension" do
|
66
|
-
parameters = @url_handler.url_to_parameters('/hello', @query_string)
|
67
|
-
parameters.uid.should == 'hello'
|
68
|
-
parameters.format.should be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should raise an UnknownUrl error if the path doesn't have a uid bit" do
|
72
|
-
lambda{
|
73
|
-
@url_handler.url_to_parameters('.hello', @query_string)
|
74
|
-
}.should raise_error(Dragonfly::UrlHandler::UnknownUrl)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should raise an UnknownUrl error if the path is only slashes" do
|
78
|
-
lambda{
|
79
|
-
@url_handler.url_to_parameters('/./', @query_string)
|
80
|
-
}.should raise_error(Dragonfly::UrlHandler::UnknownUrl)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should set most of the path as the uid if there is more than one dot" do
|
84
|
-
parameters = @url_handler.url_to_parameters('/hello.old.bean', @query_string)
|
85
|
-
parameters.uid.should == 'hello.old'
|
86
|
-
parameters.format.should == 'bean'
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should unescape any url-escaped characters" do
|
90
|
-
parameters = @url_handler.url_to_parameters('/hello%20bean.jpg', 'm=whats%20up')
|
91
|
-
parameters.uid.should == 'hello bean'
|
92
|
-
parameters.processing_method.should == 'whats up'
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
|
97
|
-
describe "forming a url from parameters" do
|
98
|
-
before(:each) do
|
99
|
-
@parameters = Dragonfly::Parameters.new
|
100
|
-
@parameters.uid = 'thisisunique'
|
101
|
-
@parameters.processing_method = 'b'
|
102
|
-
@parameters.processing_options = {:d => 'e', :j => 'k'}
|
103
|
-
@parameters.format = :gif
|
104
|
-
@parameters.encoding = {:x => 'y'}
|
105
|
-
@url_handler.configure{|c| c.protect_from_dos_attacks = false}
|
106
|
-
end
|
107
|
-
it "should correctly form a query string" do
|
108
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/thisisunique.gif?m=b&o[d]=e&o[j]=k&e[x]=y')
|
109
|
-
end
|
110
|
-
it "should correctly form a query string when dos protection turned on" do
|
111
|
-
@url_handler.configure{|c| c.protect_from_dos_attacks = true}
|
112
|
-
@parameters.should_receive(:generate_sha).and_return('thisismysha12345')
|
113
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/thisisunique.gif?m=b&o[d]=e&o[j]=k&e[x]=y&s=thisismysha12345')
|
114
|
-
end
|
115
|
-
it "should leave out any nil parameters" do
|
116
|
-
@parameters.processing_method = nil
|
117
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/thisisunique.gif?o[d]=e&o[j]=k&e[x]=y')
|
118
|
-
end
|
119
|
-
it "should leave out the format if there is none" do
|
120
|
-
@parameters.format = nil
|
121
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/thisisunique?m=b&o[d]=e&o[j]=k&e[x]=y')
|
122
|
-
end
|
123
|
-
it "should leave out any empty parameters" do
|
124
|
-
@parameters.processing_options = {}
|
125
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/thisisunique.gif?m=b&e[x]=y')
|
126
|
-
end
|
127
|
-
it "should prefix with the path_prefix if there is one" do
|
128
|
-
@url_handler.path_prefix = '/images'
|
129
|
-
@url_handler.parameters_to_url(@parameters).should match_url('/images/thisisunique.gif?m=b&o[d]=e&o[j]=k&e[x]=y')
|
130
|
-
end
|
131
|
-
it "should escape any non-url friendly characters except for '/'" do
|
132
|
-
parameters = Dragonfly::Parameters.new :uid => 'hello/u"u', :processing_method => 'm"m', :format => 'jpg'
|
133
|
-
@url_handler.parameters_to_url(parameters).should == '/hello/u%22u.jpg?m=m%22m'
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
describe "protecting from DOS attacks with SHA" do
|
138
|
-
|
139
|
-
before(:each) do
|
140
|
-
@url_handler.configure{|c|
|
141
|
-
c.protect_from_dos_attacks = true
|
142
|
-
c.secret = 'secret'
|
143
|
-
c.sha_length = 16
|
144
|
-
}
|
145
|
-
@path = "/images/some_image.jpg"
|
146
|
-
@query_string = "m=b&o[d]=e&o[j]=k"
|
147
|
-
@parameters = Dragonfly::Parameters.new
|
148
|
-
Dragonfly::Parameters.stub!(:new).and_return(@parameters)
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should return the parameters as normal if the sha is ok" do
|
152
|
-
@parameters.should_receive(:generate_sha).with('secret', 16).and_return('thisismysha12345')
|
153
|
-
lambda{
|
154
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=thisismysha12345")
|
155
|
-
}.should_not raise_error
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should raise an error if the sha is incorrect" do
|
159
|
-
@parameters.should_receive(:generate_sha).with('secret', 16).and_return('thisismysha12345')
|
160
|
-
lambda{
|
161
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=heyNOTmysha12345")
|
162
|
-
}.should raise_error(Dragonfly::UrlHandler::IncorrectSHA)
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should raise an error if the sha isn't given" do
|
166
|
-
lambda{
|
167
|
-
@url_handler.url_to_parameters(@path, @query_string)
|
168
|
-
}.should raise_error(Dragonfly::UrlHandler::SHANotGiven)
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "specifying the SHA length" do
|
172
|
-
|
173
|
-
before(:each) do
|
174
|
-
@url_handler.configure{|c|
|
175
|
-
c.sha_length = 3
|
176
|
-
}
|
177
|
-
Digest::SHA1.should_receive(:hexdigest).and_return("thisismysha12345")
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should use a SHA of the specified length" do
|
181
|
-
lambda{
|
182
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=thi")
|
183
|
-
}.should_not raise_error
|
184
|
-
end
|
185
|
-
|
186
|
-
it "should raise an error if the SHA is correct but too long" do
|
187
|
-
lambda{
|
188
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=this")
|
189
|
-
}.should raise_error(Dragonfly::UrlHandler::IncorrectSHA)
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should raise an error if the SHA is correct but too short" do
|
193
|
-
lambda{
|
194
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=th")
|
195
|
-
}.should raise_error(Dragonfly::UrlHandler::IncorrectSHA)
|
196
|
-
end
|
197
|
-
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should use the secret given to create the sha" do
|
201
|
-
@url_handler.configure{|c| c.secret = 'digby' }
|
202
|
-
Digest::SHA1.should_receive(:hexdigest).with(string_matching(/digby/)).and_return('thisismysha12345')
|
203
|
-
@url_handler.url_to_parameters(@path, "#{@query_string}&s=thisismysha12345")
|
204
|
-
end
|
205
|
-
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "#url_for" do
|
209
|
-
|
210
|
-
it "should pass parameters from Parameter.from_args plus the uid to parameters_to_url" do
|
211
|
-
parameters_class = Class.new(Dragonfly::Parameters)
|
212
|
-
url_handler = Dragonfly::UrlHandler.new(parameters_class)
|
213
|
-
parameters_class.should_receive(:from_args).with(:a, :b, :c).and_return parameters_class.new(:processing_method => :resize)
|
214
|
-
url_handler.should_receive(:parameters_to_url).with(parameters_matching(:processing_method => :resize, :uid => 'some_uid')).and_return 'some.url'
|
215
|
-
url_handler.url_for('some_uid', :a, :b, :c)
|
216
|
-
end
|
217
|
-
|
218
|
-
end
|
219
|
-
|
220
|
-
describe "sanity check" do
|
221
|
-
it "parameters_to_url should exactly reverse map url_to_parameters" do
|
222
|
-
Digest::SHA1.should_receive(:hexdigest).exactly(:twice).and_return('thisismysha12345')
|
223
|
-
path = "/images/some_image.gif"
|
224
|
-
query_string = "m=b&o[d]=e&o[j]=k&e[l]=m&s=thisismysha12345"
|
225
|
-
parameters = @url_handler.url_to_parameters(path, query_string)
|
226
|
-
@url_handler.parameters_to_url(parameters).should match_url("#{path}?#{query_string}")
|
227
|
-
end
|
228
|
-
|
229
|
-
it "url_to_parameters should exactly reverse map parameters_to_url" do
|
230
|
-
@url_handler.configure{|c| c.protect_from_dos_attacks = true}
|
231
|
-
parameters = Dragonfly::Parameters.new(
|
232
|
-
:processing_method => 'b',
|
233
|
-
:processing_options => {
|
234
|
-
:d => 'e',
|
235
|
-
:j => 'k'
|
236
|
-
},
|
237
|
-
:format => 'jpg',
|
238
|
-
:encoding => {:x => 'y'},
|
239
|
-
:uid => 'thisisunique'
|
240
|
-
)
|
241
|
-
|
242
|
-
url = @url_handler.parameters_to_url(parameters)
|
243
|
-
@url_handler.url_to_parameters(*url.split('?')).should == parameters
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
end
|
data/spec/dragonfly_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe "Dragonfly" do
|
4
|
-
|
5
|
-
it "should return RMagickConfiguration as Config::RMagickImages, with a deprecation warning" do
|
6
|
-
Dragonfly.should_receive(:puts).with(string_matching(/WARNING/))
|
7
|
-
Dragonfly::RMagickConfiguration.should == Dragonfly::Config::RMagickImages
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should raise an error for other undefined constants" do
|
11
|
-
lambda{
|
12
|
-
Dragonfly::Eggheads
|
13
|
-
}.should raise_error(NameError)
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
data/spec/ginger_scenarios.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'ginger'
|
2
|
-
|
3
|
-
Ginger.configure do |config|
|
4
|
-
config.aliases["active_record"] = "activerecord" # Because the gem name is 'activerecord', but the require is 'active_record'
|
5
|
-
|
6
|
-
activerecord_2_3_5 = Ginger::Scenario.new("ActiveRecord 2.3.5")
|
7
|
-
activerecord_2_3_5[/^active_?record$/] = "2.3.5"
|
8
|
-
|
9
|
-
activerecord_3_0_0 = Ginger::Scenario.new("ActiveRecord 3.0.0 beta3")
|
10
|
-
activerecord_3_0_0[/^active_?record$/] = "3.0.0.beta3"
|
11
|
-
|
12
|
-
config.scenarios << activerecord_2_3_5 << activerecord_3_0_0
|
13
|
-
end
|