Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
57e9495e
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,体验更适合开发者的 AI 搜索 >>
提交
57e9495e
编写于
7月 16, 2017
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix `create_with` with multiparameter attributes
上级
16f2b204
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
16 deletion
+34
-16
activerecord/lib/active_record/scoping.rb
activerecord/lib/active_record/scoping.rb
+2
-3
activerecord/test/cases/multiparameter_attributes_test.rb
activerecord/test/cases/multiparameter_attributes_test.rb
+32
-13
未找到文件。
activerecord/lib/active_record/scoping.rb
浏览文件 @
57e9495e
...
...
@@ -33,9 +33,8 @@ def scope_attributes? # :nodoc:
def
populate_with_current_scope_attributes
# :nodoc:
return
unless
self
.
class
.
scope_attributes?
self
.
class
.
scope_attributes
.
each
do
|
att
,
value
|
send
(
"
#{
att
}
="
,
value
)
if
respond_to?
(
"
#{
att
}
="
)
end
attributes
=
self
.
class
.
scope_attributes
_assign_attributes
(
attributes
)
if
attributes
.
any?
end
def
initialize_internals_callback
# :nodoc:
...
...
activerecord/test/cases/multiparameter_attributes_test.rb
浏览文件 @
57e9495e
...
...
@@ -271,6 +271,12 @@ def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attr
ensure
Topic
.
reset_column_information
end
def
test_multiparameter_attributes_setting_time_attribute
topic
=
Topic
.
new
(
"bonus_time(4i)"
=>
"01"
,
"bonus_time(5i)"
=>
"05"
)
assert_equal
1
,
topic
.
bonus_time
.
hour
assert_equal
5
,
topic
.
bonus_time
.
min
end
end
def
test_multiparameter_attributes_on_time_with_empty_seconds
...
...
@@ -285,14 +291,6 @@ def test_multiparameter_attributes_on_time_with_empty_seconds
end
end
unless
current_adapter?
:OracleAdapter
def
test_multiparameter_attributes_setting_time_attribute
topic
=
Topic
.
new
(
"bonus_time(4i)"
=>
"01"
,
"bonus_time(5i)"
=>
"05"
)
assert_equal
1
,
topic
.
bonus_time
.
hour
assert_equal
5
,
topic
.
bonus_time
.
min
end
end
def
test_multiparameter_attributes_setting_date_attribute
topic
=
Topic
.
new
(
"written_on(1i)"
=>
"1952"
,
"written_on(2i)"
=>
"3"
,
"written_on(3i)"
=>
"11"
)
assert_equal
1952
,
topic
.
written_on
.
year
...
...
@@ -300,13 +298,34 @@ def test_multiparameter_attributes_setting_date_attribute
assert_equal
11
,
topic
.
written_on
.
day
end
def
test_create_with_multiparameter_attributes_setting_date_attribute
topic
=
Topic
.
create_with
(
"written_on(1i)"
=>
"1952"
,
"written_on(2i)"
=>
"3"
,
"written_on(3i)"
=>
"11"
).
new
assert_equal
1952
,
topic
.
written_on
.
year
assert_equal
3
,
topic
.
written_on
.
month
assert_equal
11
,
topic
.
written_on
.
day
end
def
test_multiparameter_attributes_setting_date_and_time_attribute
topic
=
Topic
.
new
(
"written_on(1i)"
=>
"1952"
,
"written_on(2i)"
=>
"3"
,
"written_on(3i)"
=>
"11"
,
"written_on(4i)"
=>
"13"
,
"written_on(5i)"
=>
"55"
)
"written_on(1i)"
=>
"1952"
,
"written_on(2i)"
=>
"3"
,
"written_on(3i)"
=>
"11"
,
"written_on(4i)"
=>
"13"
,
"written_on(5i)"
=>
"55"
)
assert_equal
1952
,
topic
.
written_on
.
year
assert_equal
3
,
topic
.
written_on
.
month
assert_equal
11
,
topic
.
written_on
.
day
assert_equal
13
,
topic
.
written_on
.
hour
assert_equal
55
,
topic
.
written_on
.
min
end
def
test_create_with_multiparameter_attributes_setting_date_and_time_attribute
topic
=
Topic
.
create_with
(
"written_on(1i)"
=>
"1952"
,
"written_on(2i)"
=>
"3"
,
"written_on(3i)"
=>
"11"
,
"written_on(4i)"
=>
"13"
,
"written_on(5i)"
=>
"55"
).
new
assert_equal
1952
,
topic
.
written_on
.
year
assert_equal
3
,
topic
.
written_on
.
month
assert_equal
11
,
topic
.
written_on
.
day
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录