Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
3911a7c1
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,发现更多精彩内容 >>
提交
3911a7c1
编写于
3月 18, 2010
作者:
A
Aaron Patterson
提交者:
wycats
3月 18, 2010
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
squelching more warnings in the AR tests. [#4218 state:resolved]
Signed-off-by:
N
wycats
<
wycats@gmail.com
>
上级
191a2f78
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
14 deletion
+45
-14
activerecord/lib/active_record/railties/log_subscriber.rb
activerecord/lib/active_record/railties/log_subscriber.rb
+6
-1
activerecord/test/cases/callbacks_test.rb
activerecord/test/cases/callbacks_test.rb
+1
-1
activerecord/test/cases/fixtures_test.rb
activerecord/test/cases/fixtures_test.rb
+6
-6
activerecord/test/cases/transactions_test.rb
activerecord/test/cases/transactions_test.rb
+32
-6
未找到文件。
activerecord/lib/active_record/railties/log_subscriber.rb
浏览文件 @
3911a7c1
module
ActiveRecord
module
ActiveRecord
module
Railties
module
Railties
class
LogSubscriber
<
Rails
::
LogSubscriber
class
LogSubscriber
<
Rails
::
LogSubscriber
def
initialize
super
@odd_or_even
=
false
end
def
sql
(
event
)
def
sql
(
event
)
name
=
'%s (%.1fms)'
%
[
event
.
payload
[
:name
],
event
.
duration
]
name
=
'%s (%.1fms)'
%
[
event
.
payload
[
:name
],
event
.
duration
]
sql
=
event
.
payload
[
:sql
].
squeeze
(
' '
)
sql
=
event
.
payload
[
:sql
].
squeeze
(
' '
)
...
@@ -24,4 +29,4 @@ def logger
...
@@ -24,4 +29,4 @@ def logger
end
end
end
end
end
end
end
end
\ No newline at end of file
activerecord/test/cases/callbacks_test.rb
浏览文件 @
3911a7c1
...
@@ -139,7 +139,7 @@ class CallbackCancellationDeveloper < ActiveRecord::Base
...
@@ -139,7 +139,7 @@ class CallbackCancellationDeveloper < ActiveRecord::Base
attr_reader
:after_save_called
,
:after_create_called
,
:after_update_called
,
:after_destroy_called
attr_reader
:after_save_called
,
:after_create_called
,
:after_update_called
,
:after_destroy_called
attr_accessor
:cancel_before_save
,
:cancel_before_create
,
:cancel_before_update
,
:cancel_before_destroy
attr_accessor
:cancel_before_save
,
:cancel_before_create
,
:cancel_before_update
,
:cancel_before_destroy
before_save
{
!
@cancel_before_save
}
before_save
{
defined?
(
@cancel_before_save
)
?
!
@cancel_before_save
:
false
}
before_create
{
!
@cancel_before_create
}
before_create
{
!
@cancel_before_create
}
before_update
{
!
@cancel_before_update
}
before_update
{
!
@cancel_before_update
}
before_destroy
{
!
@cancel_before_destroy
}
before_destroy
{
!
@cancel_before_destroy
}
...
...
activerecord/test/cases/fixtures_test.rb
浏览文件 @
3911a7c1
...
@@ -244,14 +244,14 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase
...
@@ -244,14 +244,14 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase
fixtures
:topics
,
:developers
,
:accounts
fixtures
:topics
,
:developers
,
:accounts
def
test_without_complete_instantiation
def
test_without_complete_instantiation
assert
_nil
@first
assert
!
defined?
(
@first
)
assert
_nil
@topics
assert
!
defined?
(
@topics
)
assert
_nil
@developers
assert
!
defined?
(
@developers
)
assert
_nil
@accounts
assert
!
defined?
(
@accounts
)
end
end
def
test_fixtures_from_root_yml_without_instantiation
def
test_fixtures_from_root_yml_without_instantiation
assert
_nil
@unknown
assert
!
defined?
(
@unknown
),
"@unknown is not defined"
end
end
def
test_accessor_methods
def
test_accessor_methods
...
@@ -279,7 +279,7 @@ class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase
...
@@ -279,7 +279,7 @@ class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase
fixtures
:topics
,
:developers
,
:accounts
fixtures
:topics
,
:developers
,
:accounts
def
test_without_instance_instantiation
def
test_without_instance_instantiation
assert
_nil
@first
assert
!
defined?
(
@first
),
"@first is not defined"
assert_not_nil
@topics
assert_not_nil
@topics
assert_not_nil
@developers
assert_not_nil
@developers
assert_not_nil
@accounts
assert_not_nil
@accounts
...
...
activerecord/test/cases/transactions_test.rb
浏览文件 @
3911a7c1
...
@@ -51,6 +51,7 @@ def commit_db_transaction
...
@@ -51,6 +51,7 @@ def commit_db_transaction
assert
!
Topic
.
find
(
2
).
approved?
,
"Second should have been unapproved"
assert
!
Topic
.
find
(
2
).
approved?
,
"Second should have been unapproved"
ensure
ensure
class
<<
Topic
.
connection
class
<<
Topic
.
connection
remove_method
:commit_db_transaction
alias
:commit_db_transaction
:real_commit_db_transaction
rescue
nil
alias
:commit_db_transaction
:real_commit_db_transaction
rescue
nil
end
end
end
end
...
@@ -382,28 +383,53 @@ def test_sqlite_add_column_in_transaction
...
@@ -382,28 +383,53 @@ def test_sqlite_add_column_in_transaction
private
private
def
add_exception_raising_after_save_callback_to_topic
def
add_exception_raising_after_save_callback_to_topic
Topic
.
class_eval
"def after_save_for_transaction; raise 'Make the transaction rollback' end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method(:after_save_for_transaction)
def after_save_for_transaction
raise 'Make the transaction rollback'
end
eoruby
end
end
def
remove_exception_raising_after_save_callback_to_topic
def
remove_exception_raising_after_save_callback_to_topic
Topic
.
class_eval
"def after_save_for_transaction; end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method :after_save_for_transaction
def after_save_for_transaction; end
eoruby
end
end
def
add_exception_raising_after_create_callback_to_topic
def
add_exception_raising_after_create_callback_to_topic
Topic
.
class_eval
"def after_create_for_transaction; raise 'Make the transaction rollback' end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method(:after_create_for_transaction)
def after_create_for_transaction
raise 'Make the transaction rollback'
end
eoruby
end
end
def
remove_exception_raising_after_create_callback_to_topic
def
remove_exception_raising_after_create_callback_to_topic
Topic
.
class_eval
"def after_create_for_transaction; end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method :after_create_for_transaction
def after_create_for_transaction; end
eoruby
end
end
%w(validation save destroy)
.
each
do
|
filter
|
%w(validation save destroy)
.
each
do
|
filter
|
define_method
(
"add_cancelling_before_
#{
filter
}
_with_db_side_effect_to_topic"
)
do
define_method
(
"add_cancelling_before_
#{
filter
}
_with_db_side_effect_to_topic"
)
do
Topic
.
class_eval
"def before_
#{
filter
}
_for_transaction() Book.create; false end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method :before_
#{
filter
}
_for_transaction
def before_
#{
filter
}
_for_transaction
Book.create
false
end
eoruby
end
end
define_method
(
"remove_cancelling_before_
#{
filter
}
_with_db_side_effect_to_topic"
)
do
define_method
(
"remove_cancelling_before_
#{
filter
}
_with_db_side_effect_to_topic"
)
do
Topic
.
class_eval
"def before_
#{
filter
}
_for_transaction; end"
Topic
.
class_eval
<<-
eoruby
,
__FILE__
,
__LINE__
+
1
remove_method :before_
#{
filter
}
_for_transaction
def before_
#{
filter
}
_for_transaction; end
eoruby
end
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录