Skip to content
Browse files

too long

  • Loading branch information...
1 parent 71467b0 commit d60bfcee8dfb8b6ac1842af9bbc214f746ffa846 @ruseel committed Nov 20, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 app/models/topic.rb
  2. +6 −0 test/unit/topic_test.rb
View
2 app/models/topic.rb
@@ -10,7 +10,7 @@ class Topic < ActiveRecord::Base
allow_nil: true,
converter: :to_i
- validates :subject, presence: true, length: { minimum: 3 }
+ validates :subject, presence: true, length: { minimum: 3, maximum: 50 }
validates :body, presence: true
default_scope { order("boardish desc") }
View
6 test/unit/topic_test.rb
@@ -27,6 +27,12 @@ class TopicTest < ActiveSupport::TestCase
assert t.errors[:subject].join(',').include?("is too short")
end
+ test "subject length is too long" do
+ t=Topic.create(subject: "a"*51, body: @topic.body)
+ assert_equal false, t.valid?
+ assert t.errors[:subject].join(',').include?("is too long")
+ end
+
test "create sub topic" do
parent=Topic.create(subject: "parent", body: "parent")
children=Topic.create(subject: "children", body: "children", parent: parent)

0 comments on commit d60bfce

Please sign in to comment.
Something went wrong with that request. Please try again.