mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update description
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
66f546644b
commit
31199a9e4a
5 changed files with 22 additions and 24 deletions
|
@ -1,9 +1,5 @@
|
|||
require 'test/unit'
|
||||
require File.dirname(__FILE__) + '/../abstract_unit'
|
||||
require "#{File.dirname(__FILE__)}/../testing_sandbox"
|
||||
require File.dirname(__FILE__) + '/../../lib/action_view/helpers/text_helper'
|
||||
require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/numeric' # for human_size
|
||||
require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/hash' # for stringify_keys
|
||||
require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/object.rb' # for blank?
|
||||
|
||||
class TextHelperTest < Test::Unit::TestCase
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
@ -29,6 +25,7 @@ class TextHelperTest < Test::Unit::TestCase
|
|||
|
||||
def test_truncate_multibyte_without_kcode
|
||||
result = execute_in_sandbox(<<-'CODE')
|
||||
require File.dirname(__FILE__) + '/../../activesupport/lib/active_support/core_ext/kernel'
|
||||
require "#{File.dirname(__FILE__)}/../lib/action_view/helpers/text_helper"
|
||||
include ActionView::Helpers::TextHelper
|
||||
truncate("\354\225\210\353\205\225\355\225\230\354\204\270\354\232\224", 10)
|
||||
|
@ -42,6 +39,7 @@ class TextHelperTest < Test::Unit::TestCase
|
|||
$KCODE = "u"
|
||||
require 'jcode'
|
||||
|
||||
require File.dirname(__FILE__) + '/../../activesupport/lib/active_support/core_ext/kernel'
|
||||
require "#{File.dirname(__FILE__)}/../lib/action_view/helpers/text_helper"
|
||||
include ActionView::Helpers::TextHelper
|
||||
truncate("\354\225\204\353\246\254\353\236\221 \354\225\204\353\246\254\353\236 \354\225\204\353\235\274\353\246\254\354\230\244", 10)
|
||||
|
|
|
@ -2106,7 +2106,7 @@ in effect. Added :readonly finder constraint. Calling an association collectio
|
|||
end
|
||||
end
|
||||
|
||||
This will add an error to the tune of "is too short (min is 3 characters)" or "is too long (min is 20 characters)" if
|
||||
This will add an error to the tune of "is too short (minimum is 3 characters)" or "is too long (minimum is 20 characters)" if
|
||||
the password is outside the boundry. The messages can be changed by passing a third and forth parameter as message strings.
|
||||
|
||||
* Implemented a clone method that works properly with AR. It returns a clone of the record that
|
||||
|
|
|
@ -31,8 +31,8 @@ module ActiveRecord
|
|||
:accepted => "must be accepted",
|
||||
:empty => "can't be empty",
|
||||
:blank => "can't be blank",
|
||||
:too_long => "is too long (max is %d characters)",
|
||||
:too_short => "is too short (min is %d characters)",
|
||||
:too_long => "is too long (maximum is %d characters)",
|
||||
:too_short => "is too short (minimum is %d characters)",
|
||||
:wrong_length => "is the wrong length (should be %d characters)",
|
||||
:taken => "has already been taken",
|
||||
:not_a_number => "is not a number"
|
||||
|
@ -415,7 +415,7 @@ module ActiveRecord
|
|||
# * <tt>in</tt> - A synonym(or alias) for :within
|
||||
# * <tt>allow_nil</tt> - Attribute may be nil; skip validation.
|
||||
#
|
||||
# * <tt>too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (max is %d characters)")
|
||||
# * <tt>too_long</tt> - The error message if the attribute goes over the maximum (default is: "is too long (maximum is %d characters)")
|
||||
# * <tt>too_short</tt> - The error message if the attribute goes under the minimum (default is: "is too short (min is %d characters)")
|
||||
# * <tt>wrong_length</tt> - The error message if using the :is method and the attribute is the wrong size (default is: "is the wrong length (should be %d characters)")
|
||||
# * <tt>message</tt> - The error message to use for a :minimum, :maximum, or :is violation. An alias of the appropriate too_long/too_short/wrong_length message
|
||||
|
|
|
@ -156,11 +156,11 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
def test_errors_on_boundary_breaking
|
||||
developer = Developer.new("name" => "xs")
|
||||
assert !developer.save
|
||||
assert_equal "is too short (min is 3 characters)", developer.errors.on("name")
|
||||
assert_equal "is too short (minimum is 3 characters)", developer.errors.on("name")
|
||||
|
||||
developer.name = "All too very long for this boundary, it really is"
|
||||
assert !developer.save
|
||||
assert_equal "is too long (max is 20 characters)", developer.errors.on("name")
|
||||
assert_equal "is too long (maximum is 20 characters)", developer.errors.on("name")
|
||||
|
||||
developer.name = "Just right"
|
||||
assert developer.save
|
||||
|
@ -402,17 +402,17 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
t.title = "not"
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too short (min is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too short (minimum is 5 characters)", t.errors["title"]
|
||||
|
||||
t.title = ""
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too short (min is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too short (minimum is 5 characters)", t.errors["title"]
|
||||
|
||||
t.title = nil
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too short (min is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too short (minimum is 5 characters)", t.errors["title"]
|
||||
end
|
||||
|
||||
def test_optionally_validates_length_of_using_minimum
|
||||
|
@ -434,7 +434,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
t.title = "notvalid"
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too long (max is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too long (maximum is 5 characters)", t.errors["title"]
|
||||
|
||||
t.title = ""
|
||||
assert t.valid?
|
||||
|
@ -458,14 +458,14 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
|
||||
t = Topic.new("title" => "a!", "content" => "I'm ooooooooh so very long")
|
||||
assert !t.valid?
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too long (max is 5 characters)", t.errors.on(:content)
|
||||
assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content)
|
||||
|
||||
t.title = nil
|
||||
t.content = nil
|
||||
assert !t.valid?
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:content)
|
||||
assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too short (minimum is 3 characters)", t.errors.on(:content)
|
||||
|
||||
t.title = "abe"
|
||||
t.content = "mad"
|
||||
|
@ -662,7 +662,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
t.title = "一二三四"
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too short (min is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too short (minimum is 5 characters)", t.errors["title"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -676,7 +676,7 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
t.title = "一二34五六"
|
||||
assert !t.valid?
|
||||
assert t.errors.on(:title)
|
||||
assert_equal "is too long (max is 5 characters)", t.errors["title"]
|
||||
assert_equal "is too long (maximum is 5 characters)", t.errors["title"]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -686,8 +686,8 @@ class ValidationsTest < Test::Unit::TestCase
|
|||
|
||||
t = Topic.new("title" => "一二", "content" => "12三四五六七")
|
||||
assert !t.valid?
|
||||
assert_equal "is too short (min is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too long (max is 5 characters)", t.errors.on(:content)
|
||||
assert_equal "is too short (minimum is 3 characters)", t.errors.on(:title)
|
||||
assert_equal "is too long (maximum is 5 characters)", t.errors.on(:content)
|
||||
t.title = "一二三"
|
||||
t.content = "12三"
|
||||
assert t.valid?
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace :db do
|
|||
end
|
||||
|
||||
namespace :fixtures do
|
||||
desc "Load fixtures into the current environment's database. Load a single fixture using FIXTURE=x"
|
||||
desc "Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y"
|
||||
task :load => :environment do
|
||||
require 'active_record/fixtures'
|
||||
ActiveRecord::Base.establish_connection(RAILS_ENV.to_sym)
|
||||
|
|
Loading…
Reference in a new issue