Permalink
Browse files

Merge pull request #15959 from aditya-kapoor/remove-unneeded-cases

remove unneeded test model for ActiveModel test cases.
  • Loading branch information...
2 parents c56997e + 94b6207 commit 74c31ac5fe44b2e2b46e660932e6ca266b11fd58 @rafaelfranca rafaelfranca committed Jul 29, 2014
Showing with 17 additions and 26 deletions.
  1. +17 −13 activemodel/test/cases/validations_test.rb
  2. +0 −13 activemodel/test/models/automobile.rb
@@ -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'
@@ -290,25 +289,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
-
- auto.make = 'Toyota'
- auto.model = 'Corolla'
- auto.approved = '1'
+ topic = Topic.new
+ assert topic.invalid?
+ assert_equal 3, topic.errors.size
- 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

0 comments on commit 74c31ac

Please sign in to comment.