Permalink
Browse files

Removed warnings about #errors in Rails 3

  • Loading branch information...
1 parent 724cc7e commit a4d1b0ebb3fea21fbaeddd11f9e09f0e894077e9 @jyurek jyurek committed May 1, 2010
@@ -57,7 +57,7 @@ def allow_types?(types)
file = StringIO.new(".")
file.content_type = type
(subject = @subject.new).attachment_for(@attachment_name).assign(file)
- subject.valid? && subject.errors.on(:"#{@attachment_name}_content_type").blank?
+ subject.valid? && subject.errors[:"#{@attachment_name}_content_type"].blank?
end
end
@@ -39,14 +39,14 @@ def description
def error_when_not_valid?
(subject = @subject.new).send(@attachment_name).assign(nil)
subject.valid?
- not subject.errors.on(:"#{@attachment_name}_file_name").blank?
+ not subject.errors[:"#{@attachment_name}_file_name"].blank?
end
def no_error_when_valid?
@file = StringIO.new(".")
(subject = @subject.new).send(@attachment_name).assign(@file)
subject.valid?
- subject.errors.on(:"#{@attachment_name}_file_name").blank?
+ subject.errors[:"#{@attachment_name}_file_name"].blank?
end
end
end
@@ -69,7 +69,7 @@ def passes_validation_with_size(new_size)
(subject = @subject.new).send(@attachment_name).assign(file)
subject.valid?
- subject.errors.on(:"#{@attachment_name}_file_size").blank?
+ subject.errors[:"#{@attachment_name}_file_size"].blank?
end
def lower_than_low?
@@ -235,11 +235,11 @@ def self.should_validate validation, options, valid_file, invalid_file
end
if validation == :presence
should "have an error on the attachment" do
- assert @dummy.errors.on(:avatar_file_name)
+ assert @dummy.errors[:avatar_file_name]
end
else
should "not have an error on the attachment" do
- assert_nil @dummy.errors.on(:avatar_file_name), @dummy.errors.full_messages.join(", ")
+ assert @dummy.errors[:avatar_file_name].blank?, @dummy.errors.full_messages.join(", ")
end
end
end
@@ -288,7 +288,7 @@ def self.should_validate validation, options, valid_file, invalid_file
end
should "have a file size min/max error message" do
- assert_match %r/between 0 and 10240 bytes/, @dummy.errors.on(:avatar_file_size)
+ assert @dummy.errors[:avatar_file_size].any?{|e| e.match %r/between 0 and 10240 bytes/ }
end
end
end

0 comments on commit a4d1b0e

Please sign in to comment.