Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
8b0753b4
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,发现更多精彩内容 >>
提交
8b0753b4
编写于
6月 26, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15916 from sgrif/sg-test-update-all
Consolidate testing of update_all type casting
上级
031588eb
58d38d6d
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
28 addition
and
30 deletion
+28
-30
activerecord/test/cases/adapters/postgresql/array_test.rb
activerecord/test/cases/adapters/postgresql/array_test.rb
+0
-10
activerecord/test/cases/adapters/postgresql/hstore_test.rb
activerecord/test/cases/adapters/postgresql/hstore_test.rb
+0
-10
activerecord/test/cases/adapters/postgresql/json_test.rb
activerecord/test/cases/adapters/postgresql/json_test.rb
+0
-10
activerecord/test/cases/relation_test.rb
activerecord/test/cases/relation_test.rb
+28
-0
未找到文件。
activerecord/test/cases/adapters/postgresql/array_test.rb
浏览文件 @
8b0753b4
...
...
@@ -192,16 +192,6 @@ def test_attribute_for_inspect_for_array_field
assert_equal
(
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...]"
,
record
.
attribute_for_inspect
(
:ratings
))
end
def
test_update_all
pg_array
=
PgArray
.
create!
tags:
[
"one"
,
"two"
,
"three"
]
PgArray
.
update_all
tags:
[
"four"
,
"five"
]
assert_equal
[
"four"
,
"five"
],
pg_array
.
reload
.
tags
PgArray
.
update_all
tags:
[]
assert_equal
[],
pg_array
.
reload
.
tags
end
def
test_escaping
unknown
=
'foo\\",bar,baz,\\'
tags
=
[
"hello_
#{
unknown
}
"
]
...
...
activerecord/test/cases/adapters/postgresql/hstore_test.rb
浏览文件 @
8b0753b4
...
...
@@ -295,16 +295,6 @@ def test_multiline
assert_cycle
(
"a
\n
b"
=>
"c
\n
d"
)
end
def
test_update_all
hstore
=
Hstore
.
create!
tags:
{
"one"
=>
"two"
}
Hstore
.
update_all
tags:
{
"three"
=>
"four"
}
assert_equal
({
"three"
=>
"four"
},
hstore
.
reload
.
tags
)
Hstore
.
update_all
tags:
{
}
assert_equal
({
},
hstore
.
reload
.
tags
)
end
class
TagCollection
def
initialize
(
hash
);
@hash
=
hash
end
def
to_hash
;
@hash
end
...
...
activerecord/test/cases/adapters/postgresql/json_test.rb
浏览文件 @
8b0753b4
...
...
@@ -155,16 +155,6 @@ def test_yaml_round_trip_with_store_accessors
assert_equal
"320×480"
,
y
.
resolution
end
def
test_update_all
json
=
JsonDataType
.
create!
payload:
{
"one"
=>
"two"
}
JsonDataType
.
update_all
payload:
{
"three"
=>
"four"
}
assert_equal
({
"three"
=>
"four"
},
json
.
reload
.
payload
)
JsonDataType
.
update_all
payload:
{
}
assert_equal
({
},
json
.
reload
.
payload
)
end
def
test_changes_in_place
json
=
JsonDataType
.
new
assert_not
json
.
changed?
...
...
activerecord/test/cases/relation_test.rb
浏览文件 @
8b0753b4
...
...
@@ -235,5 +235,33 @@ def test_relation_merging_with_merged_joins_as_strings
posts_with_special_comments_with_ratings
=
Post
.
group
(
"posts.id"
).
joins
(
:special_comments
).
merge
(
special_comments_with_ratings
)
assert_equal
3
,
authors
(
:david
).
posts
.
merge
(
posts_with_special_comments_with_ratings
).
count
.
length
end
class
EnsureRoundTripTypeCasting
<
ActiveRecord
::
Type
::
Value
def
type
:string
end
def
type_cast_from_database
(
value
)
raise
value
unless
value
==
"type cast for database"
"type cast from database"
end
def
type_cast_for_database
(
value
)
raise
value
unless
value
==
"value from user"
"type cast for database"
end
end
class
UpdateAllTestModel
<
ActiveRecord
::
Base
self
.
table_name
=
'posts'
attribute
:body
,
EnsureRoundTripTypeCasting
.
new
end
def
test_update_all_goes_through_normal_type_casting
UpdateAllTestModel
.
update_all
(
body:
"value from user"
,
type:
nil
)
# No STI
assert_equal
"type cast from database"
,
UpdateAllTestModel
.
first
.
body
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录