Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
af88daef
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
af88daef
编写于
5月 10, 2011
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #503 from smartinez87/conventions
Follow code conventions on some tests
上级
fa187ec7
21b61a8a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
30 deletion
+30
-30
activemodel/test/cases/validations/conditional_validation_test.rb
...del/test/cases/validations/conditional_validation_test.rb
+12
-12
activemodel/test/cases/validations/format_validation_test.rb
activemodel/test/cases/validations/format_validation_test.rb
+1
-1
activemodel/test/cases/validations/inclusion_validation_test.rb
...model/test/cases/validations/inclusion_validation_test.rb
+1
-1
activemodel/test/cases/validations/length_validation_test.rb
activemodel/test/cases/validations/length_validation_test.rb
+15
-15
activeresource/test/cases/format_test.rb
activeresource/test/cases/format_test.rb
+1
-1
未找到文件。
activemodel/test/cases/validations/conditional_validation_test.rb
浏览文件 @
af88daef
...
...
@@ -11,7 +11,7 @@ def teardown
def
test_if_validation_using_method_true
# When the method returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
:condition_is_true
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
:condition_is_true
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -20,7 +20,7 @@ def test_if_validation_using_method_true
def
test_unless_validation_using_method_true
# When the method returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
:condition_is_true
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
:condition_is_true
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
assert
t
.
errors
[
:title
].
empty?
...
...
@@ -28,7 +28,7 @@ def test_unless_validation_using_method_true
def
test_if_validation_using_method_false
# When the method returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
:condition_is_true_but_its_not
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
:condition_is_true_but_its_not
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
assert
t
.
errors
[
:title
].
empty?
...
...
@@ -36,7 +36,7 @@ def test_if_validation_using_method_false
def
test_unless_validation_using_method_false
# When the method returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
:condition_is_true_but_its_not
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
:condition_is_true_but_its_not
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -45,7 +45,7 @@ def test_unless_validation_using_method_false
def
test_if_validation_using_string_true
# When the evaluated string returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
"a = 1; a == 1"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
"a = 1; a == 1"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -54,7 +54,7 @@ def test_if_validation_using_string_true
def
test_unless_validation_using_string_true
# When the evaluated string returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
"a = 1; a == 1"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
"a = 1; a == 1"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
assert
t
.
errors
[
:title
].
empty?
...
...
@@ -62,7 +62,7 @@ def test_unless_validation_using_string_true
def
test_if_validation_using_string_false
# When the evaluated string returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
"false"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
"false"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
assert
t
.
errors
[
:title
].
empty?
...
...
@@ -70,7 +70,7 @@ def test_if_validation_using_string_false
def
test_unless_validation_using_string_false
# When the evaluated string returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
"false"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
"false"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -79,7 +79,7 @@ def test_unless_validation_using_string_false
def
test_if_validation_using_block_true
# When the block returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
Proc
.
new
{
|
r
|
r
.
content
.
size
>
4
}
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
...
...
@@ -89,7 +89,7 @@ def test_if_validation_using_block_true
def
test_unless_validation_using_block_true
# When the block returns true
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
Proc
.
new
{
|
r
|
r
.
content
.
size
>
4
}
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
...
...
@@ -98,7 +98,7 @@ def test_unless_validation_using_block_true
def
test_if_validation_using_block_false
# When the block returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:if
=>
Proc
.
new
{
|
r
|
r
.
title
!=
"uhohuhoh"
}
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
valid?
...
...
@@ -107,7 +107,7 @@ def test_if_validation_using_block_false
def
test_unless_validation_using_block_false
# When the block returns false
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
,
:unless
=>
Proc
.
new
{
|
r
|
r
.
title
!=
"uhohuhoh"
}
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
...
...
activemodel/test/cases/validations/format_validation_test.rb
浏览文件 @
af88daef
...
...
@@ -27,7 +27,7 @@ def test_validate_format
end
def
test_validate_format_with_allow_blank
Topic
.
validates_format_of
(
:title
,
:with
=>
/^Validation\smacros \w+!$/
,
:allow_blank
=>
true
)
Topic
.
validates_format_of
(
:title
,
:with
=>
/^Validation\smacros \w+!$/
,
:allow_blank
=>
true
)
assert
Topic
.
new
(
"title"
=>
"Shouldn't be valid"
).
invalid?
assert
Topic
.
new
(
"title"
=>
""
).
valid?
assert
Topic
.
new
(
"title"
=>
nil
).
valid?
...
...
activemodel/test/cases/validations/inclusion_validation_test.rb
浏览文件 @
af88daef
...
...
@@ -42,7 +42,7 @@ def test_validates_inclusion_of
end
def
test_validates_inclusion_of_with_allow_nil
Topic
.
validates_inclusion_of
(
:title
,
:in
=>
%w( a b c d e f g )
,
:allow_nil
=>
true
)
Topic
.
validates_inclusion_of
(
:title
,
:in
=>
%w( a b c d e f g )
,
:allow_nil
=>
true
)
assert
Topic
.
new
(
"title"
=>
"a!"
,
"content"
=>
"abc"
).
invalid?
assert
Topic
.
new
(
"title"
=>
""
,
"content"
=>
"abc"
).
invalid?
...
...
activemodel/test/cases/validations/length_validation_test.rb
浏览文件 @
af88daef
...
...
@@ -11,7 +11,7 @@ def teardown
end
def
test_validates_length_of_with_allow_nil
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:allow_nil
=>
true
)
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:allow_nil
=>
true
)
assert
Topic
.
new
(
"title"
=>
"ab"
).
invalid?
assert
Topic
.
new
(
"title"
=>
""
).
invalid?
...
...
@@ -20,7 +20,7 @@ def test_validates_length_of_with_allow_nil
end
def
test_validates_length_of_with_allow_blank
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:allow_blank
=>
true
)
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:allow_blank
=>
true
)
assert
Topic
.
new
(
"title"
=>
"ab"
).
invalid?
assert
Topic
.
new
(
"title"
=>
""
).
valid?
...
...
@@ -176,16 +176,16 @@ def test_validates_length_of_using_bignum
end
def
test_validates_length_of_nasty_params
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:is
=>
-
6
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:within
=>
6
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:minimum
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:maximum
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:within
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:is
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:is
=>
-
6
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:within
=>
6
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:minimum
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:maximum
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:within
=>
"a"
)
}
assert_raise
(
ArgumentError
)
{
Topic
.
validates_length_of
(
:title
,
:is
=>
"a"
)
}
end
def
test_validates_length_of_custom_errors_for_minimum_with_message
Topic
.
validates_length_of
(
:title
,
:minimum
=>
5
,
:message
=>
"boo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:minimum
=>
5
,
:message
=>
"boo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -193,7 +193,7 @@ def test_validates_length_of_custom_errors_for_minimum_with_message
end
def
test_validates_length_of_custom_errors_for_minimum_with_too_short
Topic
.
validates_length_of
(
:title
,
:minimum
=>
5
,
:too_short
=>
"hoo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:minimum
=>
5
,
:too_short
=>
"hoo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -201,7 +201,7 @@ def test_validates_length_of_custom_errors_for_minimum_with_too_short
end
def
test_validates_length_of_custom_errors_for_maximum_with_message
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:message
=>
"boo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:message
=>
"boo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -222,7 +222,7 @@ def test_validates_length_of_custom_errors_for_in
end
def
test_validates_length_of_custom_errors_for_maximum_with_too_long
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:maximum
=>
5
,
:too_long
=>
"hoo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -244,7 +244,7 @@ def test_validates_length_of_custom_errors_for_both_too_short_and_too_long
end
def
test_validates_length_of_custom_errors_for_is_with_message
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:message
=>
"boo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:message
=>
"boo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -252,7 +252,7 @@ def test_validates_length_of_custom_errors_for_is_with_message
end
def
test_validates_length_of_custom_errors_for_is_with_wrong_length
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:wrong_length
=>
"hoo %{count}"
)
Topic
.
validates_length_of
(
:title
,
:is
=>
5
,
:wrong_length
=>
"hoo %{count}"
)
t
=
Topic
.
new
(
"title"
=>
"uhohuhoh"
,
"content"
=>
"whatever"
)
assert
t
.
invalid?
assert
t
.
errors
[
:title
].
any?
...
...
@@ -331,7 +331,7 @@ def test_validates_length_of_using_is_utf8
end
def
test_validates_length_of_with_block
Topic
.
validates_length_of
:content
,
:minimum
=>
5
,
:too_short
=>
"Your essay must be at least %{count} words."
,
Topic
.
validates_length_of
:content
,
:minimum
=>
5
,
:too_short
=>
"Your essay must be at least %{count} words."
,
:tokenizer
=>
lambda
{
|
str
|
str
.
scan
(
/\w+/
)
}
t
=
Topic
.
new
(
:content
=>
"this content should be long enough"
)
assert
t
.
valid?
...
...
activeresource/test/cases/format_test.rb
浏览文件 @
af88daef
...
...
@@ -86,7 +86,7 @@ def test_setting_format_before_site
def
test_serialization_of_nested_resource
address
=
{
:street
=>
'12345 Street'
}
person
=
{
:name
=>
'Rus'
,
:address
=>
address
}
person
=
{
:name
=>
'Rus'
,
:address
=>
address
}
[
:json
,
:xml
].
each
do
|
format
|
encoded_person
=
ActiveResource
::
Formats
[
format
].
encode
(
person
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录