remove unneeded test model for ActiveModel test cases.

This commit is contained in:
Aditya Kapoor 2014-06-28 22:27:06 +05:30
parent 13770587ef
commit 94b6207910
2 changed files with 17 additions and 26 deletions

@ -4,7 +4,6 @@
require 'models/topic'
require 'models/reply'
require 'models/custom_reader'
require 'models/automobile'
require 'active_support/json'
require 'active_support/xml_mini'
@ -283,25 +282,30 @@ def test_list_of_validators_will_be_empty_when_empty
end
def test_validations_on_the_instance_level
auto = Automobile.new
Topic.validates :title, :author_name, presence: true
Topic.validates :content, length: { minimum: 10 }
assert auto.invalid?
assert_equal 3, auto.errors.size
topic = Topic.new
assert topic.invalid?
assert_equal 3, topic.errors.size
auto.make = 'Toyota'
auto.model = 'Corolla'
auto.approved = '1'
assert auto.valid?
topic.title = 'Some Title'
topic.author_name = 'Some Author'
topic.content = 'Some Content Whose Length is more than 10.'
assert topic.valid?
end
def test_validate
auto = Automobile.new
Topic.validate do
validates_presence_of :title, :author_name
validates_length_of :content, minimum: 10
end
assert_empty auto.errors
topic = Topic.new
assert_empty topic.errors
auto.validate
assert_not_empty auto.errors
topic.validate
assert_not_empty topic.errors
end
def test_strict_validation_in_validates

@ -1,13 +0,0 @@
class Automobile
include ActiveModel::Validations
validate :validations
attr_accessor :make, :model, :approved
def validations
validates_presence_of :make
validates_length_of :model, within: 2..10
validates_acceptance_of :approved, allow_nil: false
end
end