Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add default translation for spoofed media type error

  • Loading branch information...
commit 00787da621735b8681ab035a78b85b4412f0dc5c 1 parent 81669c1
@morgoth morgoth authored
View
1  lib/paperclip/locales/en.yml
@@ -2,6 +2,7 @@ en:
errors:
messages:
in_between: "must be in between %{min} and %{max}"
+ spoofed_media_type: "media type is spoofed"
number:
human:
View
20 test/validators/media_type_spoof_detection_validator_test.rb
@@ -6,7 +6,27 @@ def setup
@dummy = Dummy.new
end
+ def build_validator(options = {})
+ @validator = Paperclip::Validators::MediaTypeSpoofDetectionValidator.new(options.merge(
+ :attributes => :avatar
+ ))
+ end
+
should "be on the attachment without being explicitly added" do
assert Dummy.validators_on(:avatar).any?{ |validator| validator.kind == :media_type_spoof_detection }
end
+
+ should "return default error message for spoofed media type" do
+ build_validator
+
+ # Make avatar dirty
+ file = File.new(fixture_file("5k.png"), "rb")
+ @dummy.avatar.assign(file)
+
+ detector = mock("detector", :spoofed? => true)
+ Paperclip::MediaTypeSpoofDetector.stubs(:using).returns(detector)
+ @validator.validate(@dummy)
+
+ assert_equal "media type is spoofed", @dummy.errors[:avatar].first
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.