Permalink
Browse files

Remove unused tests

  • Loading branch information...
1 parent fe706c6 commit 84d2d087b6def29f46b318d4db5950167a5c2809 @sikachu sikachu committed Mar 16, 2012
Showing with 0 additions and 150 deletions.
  1. +0 −150 test/paperclip_test.rb
View
@@ -191,161 +191,11 @@ class ::SubDummy < Dummy; end
end
end
- context "a validation with an if guard clause" do
- context "as a lambda" do
- setup do
- Dummy.send(:"validates_attachment_presence", :avatar, :if => lambda{|i| i.foo })
- @dummy = Dummy.new
- @dummy.stubs(:avatar_file_name).returns(nil)
- end
-
- should "attempt validation if the guard returns true" do
- @dummy.expects(:foo).returns(true)
- assert ! @dummy.valid?
- end
-
- should "not attempt validation if the guard returns false" do
- @dummy.expects(:foo).returns(false)
- assert @dummy.valid?
- end
- end
-
- context "as a method name" do
- setup do
- Dummy.send(:"validates_attachment_presence", :avatar, :if => :foo)
- @dummy = Dummy.new
- @dummy.stubs(:avatar_file_name).returns(nil)
- end
-
- should "attempt validation if the guard returns true" do
- @dummy.expects(:foo).returns(true)
- assert ! @dummy.valid?
- end
-
- should "not attempt validation if the guard returns false" do
- @dummy.expects(:foo).returns(false)
- assert @dummy.valid?
- end
- end
- end
-
- context "a validation with an unless guard clause" do
- context "as a lambda" do
- setup do
- Dummy.send(:"validates_attachment_presence", :avatar, :unless => lambda{|i| i.foo })
- @dummy = Dummy.new
- @dummy.stubs(:avatar_file_name).returns(nil)
- end
-
- should "attempt validation if the guard returns true" do
- @dummy.expects(:foo).returns(false)
- assert ! @dummy.valid?
- end
-
- should "not attempt validation if the guard returns false" do
- @dummy.expects(:foo).returns(true)
- assert @dummy.valid?
- end
- end
-
- context "as a method name" do
- setup do
- Dummy.send(:"validates_attachment_presence", :avatar, :unless => :foo)
- @dummy = Dummy.new
- @dummy.stubs(:avatar_file_name).returns(nil)
- end
-
- should "attempt validation if the guard returns true" do
- @dummy.expects(:foo).returns(false)
- assert ! @dummy.valid?
- end
-
- should "not attempt validation if the guard returns false" do
- @dummy.expects(:foo).returns(true)
- assert @dummy.valid?
- end
- end
- end
-
should "not have Attachment in the ActiveRecord::Base namespace" do
assert_raises(NameError) do
ActiveRecord::Base::Attachment
end
end
-
- def self.should_validate validation, options, valid_file, invalid_file
- context "with #{validation} validation and #{options.inspect} options" do
- setup do
- rebuild_class
- Dummy.send(:"validates_attachment_#{validation}", :avatar, options)
- @dummy = Dummy.new
- end
- context "and assigning nil" do
- setup do
- @dummy.avatar = nil
- @dummy.valid?
- end
- if validation == :presence
- should "have an error on the attachment" do
- assert @dummy.errors[:avatar]
- assert @dummy.errors[:avatar_file_name]
- end
- else
- should "not have an error on the attachment" do
- assert @dummy.errors.blank?, @dummy.errors.full_messages.join(", ")
- end
- end
- end
- context "and assigned a valid file" do
- setup do
- @dummy.avatar = valid_file
- @dummy.valid?
- end
- should "not have an error" do
- assert_equal 0, @dummy.errors.size, @dummy.errors.full_messages.join(", ")
- end
- end
- context "and assigned an invalid file" do
- setup do
- @dummy.avatar = invalid_file
- @dummy.valid?
- end
- should "have an error" do
- assert @dummy.errors.size > 0
- end
- end
- end
- end
-
- [[:presence, {}, "5k.png", nil],
- [:size, {:in => 1..10240}, "5k.png", "12k.png"],
- [:size, {:less_than => 10240}, "5k.png", "12k.png"],
- [:size, {:greater_than => 8096}, "12k.png", "5k.png"],
- [:content_type, {:content_type => "image/png"}, "5k.png", "text.txt"],
- [:content_type, {:content_type => "text/plain"}, "text.txt", "5k.png"],
- [:content_type, {:content_type => %r{image/.*}}, "5k.png", "text.txt"]].each do |args|
- validation, options, valid_file, invalid_file = args
- valid_file &&= File.open(File.join(FIXTURES_DIR, valid_file), "rb")
- invalid_file &&= File.open(File.join(FIXTURES_DIR, invalid_file), "rb")
-
- should_validate validation, options, valid_file, invalid_file
- end
-
- context "with size validation and less_than 10240 option" do
- context "and assigned an invalid file" do
- setup do
- Dummy.send(:"validates_attachment_size", :avatar, :less_than => 10240)
- @dummy = Dummy.new
- @dummy.avatar &&= File.open(File.join(FIXTURES_DIR, "12k.png"), "rb")
- @dummy.valid?
- end
-
- should "have a file size min/max error message" do
- assert_includes @dummy.errors[:avatar_file_size], "must be less than 10240 Bytes"
- end
- end
- end
-
end
context "configuring a custom processor" do

0 comments on commit 84d2d08

Please sign in to comment.