Skip to content

Commit

Permalink
validator for rotate processor
Browse files Browse the repository at this point in the history
  • Loading branch information
markevans committed May 15, 2021
1 parent bf14fb1 commit bcbe125
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/dragonfly/image_magick/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require "dragonfly/image_magick/processors/encode"
require "dragonfly/image_magick/processors/thumb"
require "dragonfly/image_magick/commands"
require "dragonfly/param_validators"

module Dragonfly
module ImageMagick
Expand Down Expand Up @@ -61,6 +62,7 @@ def call(app, opts = {})
app.add_processor :encode, Processors::Encode.new
app.add_processor :thumb, Processors::Thumb.new
app.add_processor :rotate do |content, amount|
ParamValidators.validate!(amount, &ParamValidators.is_number)
Commands.convert(content, "-rotate #{amount}")
end

Expand Down
6 changes: 6 additions & 0 deletions spec/dragonfly/image_magick/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
image.width.should == 355
image.height.should == 280
end

it "disallows bad parameters" do
expect {
image.rotate!("90 -write bad.png").apply
}.to raise_error(Dragonfly::ParamValidators::InvalidParameter)
end
end
end

Expand Down

0 comments on commit bcbe125

Please sign in to comment.