Skip to content

Commit 16452ba

Browse files
committed
Allow 50 character titles #26
1 parent 18448c9 commit 16452ba

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Diff for: app/models/todo.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Todo < ActiveRecord::Base
99

1010
validates :user, presence: true
1111

12-
validates :title, presence: true, length: { in: 5..35, message: "must be 5 to 35 characters long!" }, format: { with: /\A[A-Z][\w\!\,\.\'\ ]+\z/, message: "must be alphanumeric, begin with a capital letter and can include white space or these characters: !,." }
12+
validates :title, presence: true, length: { in: 5..50, message: "must be 5 to 35 characters long!" }, format: { with: /\A[A-Z][\w\!\,\.\'\ ]+\z/, message: "must be alphanumeric, begin with a capital letter and can include white space or these characters: !,." }
1313

1414
validates :description, length: { in: 0..255, message: "must be 10 to 255 characters long!" }, format: { with: /\A[\w\!\,\.\(\)\&\^\@\#\$\{\}\"\'\\\/\|\;\:\+\-\%\<\>\*\?\=\~\`\s]+\z/, message: "must be alphanumeric and can include white space or these characters: w!,.()&^@#${}\"'\/|;:+-%<>*?=s~`" }, allow_blank: true
1515

Diff for: test/models/todo_test.rb

+6
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,10 @@ class TodoTest < ActiveSupport::TestCase
6161

6262
assert todo.save, "Todo did not save with empty description"
6363
end
64+
65+
test "todo title length" do
66+
todo = Todo.new(:title => "A0123456789012345678901234567890123456789012345678", :description => "", :user => users(:one), :completed => false)
67+
68+
assert todo.save, "Todo title is #{todo.title.length} characters long."
69+
end
6470
end

0 commit comments

Comments
 (0)