Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0ab9301f
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,发现更多精彩内容 >>
提交
0ab9301f
编写于
7月 09, 2014
作者:
A
Abdelkader Boudih
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added enable_extension! to helper
上级
7025d776
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
26 deletion
+25
-26
activerecord/test/cases/adapters/postgresql/array_test.rb
activerecord/test/cases/adapters/postgresql/array_test.rb
+2
-6
activerecord/test/cases/adapters/postgresql/citext_test.rb
activerecord/test/cases/adapters/postgresql/citext_test.rb
+2
-7
activerecord/test/cases/adapters/postgresql/ltree_test.rb
activerecord/test/cases/adapters/postgresql/ltree_test.rb
+1
-3
activerecord/test/cases/adapters/postgresql/uuid_test.rb
activerecord/test/cases/adapters/postgresql/uuid_test.rb
+6
-5
activerecord/test/cases/helper.rb
activerecord/test/cases/helper.rb
+11
-3
activerecord/test/cases/migration/rename_table_test.rb
activerecord/test/cases/migration/rename_table_test.rb
+2
-1
activerecord/test/schema/schema.rb
activerecord/test/schema/schema.rb
+1
-1
未找到文件。
activerecord/test/cases/adapters/postgresql/array_test.rb
浏览文件 @
0ab9301f
...
...
@@ -12,12 +12,7 @@ class PgArray < ActiveRecord::Base
def
setup
@connection
=
ActiveRecord
::
Base
.
connection
unless
@connection
.
extension_enabled?
(
'hstore'
)
@connection
.
enable_extension
'hstore'
@connection
.
commit_db_transaction
end
@connection
.
reconnect!
enable_extension!
(
'hstore'
,
@connection
)
@connection
.
transaction
do
@connection
.
create_table
(
'pg_arrays'
)
do
|
t
|
...
...
@@ -32,6 +27,7 @@ def setup
teardown
do
@connection
.
execute
'drop table if exists pg_arrays'
disable_extension!
(
'hstore'
,
@connection
)
end
def
test_column
...
...
activerecord/test/cases/adapters/postgresql/citext_test.rb
浏览文件 @
0ab9301f
...
...
@@ -10,12 +10,7 @@ class Citext < ActiveRecord::Base
def
setup
@connection
=
ActiveRecord
::
Base
.
connection
unless
@connection
.
extension_enabled?
(
'citext'
)
@connection
.
enable_extension
'citext'
@connection
.
commit_db_transaction
end
@connection
.
reconnect!
enable_extension!
(
'citext'
,
@connection
)
@connection
.
create_table
(
'citexts'
)
do
|
t
|
t
.
citext
'cival'
...
...
@@ -24,7 +19,7 @@ def setup
teardown
do
@connection
.
execute
'DROP TABLE IF EXISTS citexts;'
@connection
.
execute
'DROP EXTENSION IF EXISTS citext CASCADE;'
disable_extension!
(
'citext'
,
@connection
)
end
def
test_citext_enabled
...
...
activerecord/test/cases/adapters/postgresql/ltree_test.rb
浏览文件 @
0ab9301f
...
...
@@ -9,9 +9,7 @@ class Ltree < ActiveRecord::Base
def
setup
@connection
=
ActiveRecord
::
Base
.
connection
unless
@connection
.
extension_enabled?
(
'ltree'
)
@connection
.
enable_extension
'ltree'
end
enable_extension!
(
'ltree'
,
@connection
)
@connection
.
transaction
do
@connection
.
create_table
(
'ltrees'
)
do
|
t
|
...
...
activerecord/test/cases/adapters/postgresql/uuid_test.rb
浏览文件 @
0ab9301f
...
...
@@ -118,7 +118,7 @@ class UUID < ActiveRecord::Base
end
setup
do
enable_
uuid_ossp!
(
connection
)
enable_
extension!
(
'uuid-ossp'
,
connection
)
connection
.
create_table
(
'pg_uuids'
,
id: :uuid
,
default:
'uuid_generate_v1()'
)
do
|
t
|
t
.
string
'name'
...
...
@@ -144,6 +144,7 @@ class UUID < ActiveRecord::Base
drop_table
"pg_uuids"
drop_table
'pg_uuids_2'
connection
.
execute
'DROP FUNCTION IF EXISTS my_uuid_generator();'
disable_extension!
(
'uuid-ossp'
,
connection
)
end
if
ActiveRecord
::
Base
.
connection
.
supports_extensions?
...
...
@@ -189,7 +190,7 @@ class PostgresqlUUIDTestNilDefault < ActiveRecord::TestCase
include
PostgresqlUUIDHelper
setup
do
enable_
uuid_ossp!
(
connection
)
enable_
extension!
(
'uuid-ossp'
,
connection
)
connection
.
create_table
(
'pg_uuids'
,
id:
false
)
do
|
t
|
t
.
primary_key
:id
,
:uuid
,
default:
nil
...
...
@@ -199,6 +200,7 @@ class PostgresqlUUIDTestNilDefault < ActiveRecord::TestCase
teardown
do
drop_table
"pg_uuids"
disable_extension!
(
'uuid-ossp'
,
connection
)
end
if
ActiveRecord
::
Base
.
connection
.
supports_extensions?
...
...
@@ -226,7 +228,7 @@ class UuidComment < ActiveRecord::Base
end
setup
do
enable_
uuid_ossp!
(
connection
)
enable_
extension!
(
'uuid-ossp'
,
connection
)
connection
.
transaction
do
connection
.
create_table
(
'pg_uuid_posts'
,
id: :uuid
)
do
|
t
|
...
...
@@ -240,10 +242,9 @@ class UuidComment < ActiveRecord::Base
end
teardown
do
connection
.
transaction
do
drop_table
"pg_uuid_comments"
drop_table
"pg_uuid_posts"
end
disable_extension!
(
'uuid-ossp'
,
connection
)
end
if
ActiveRecord
::
Base
.
connection
.
supports_extensions?
...
...
activerecord/test/cases/helper.rb
浏览文件 @
0ab9301f
...
...
@@ -119,15 +119,23 @@ def verify_default_timezone_config
end
end
def
enable_
uuid_ossp!
(
connection
)
def
enable_
extension!
(
extension
,
connection
)
return
false
unless
connection
.
supports_extensions?
return
connection
.
reconnect!
if
connection
.
extension_enabled?
(
'uuid-ossp'
)
return
connection
.
reconnect!
if
connection
.
extension_enabled?
(
extension
)
connection
.
enable_extension
'uuid-ossp'
connection
.
enable_extension
extension
connection
.
commit_db_transaction
connection
.
reconnect!
end
def
disable_extension!
(
extension
,
connection
)
return
false
unless
connection
.
supports_extensions?
return
true
unless
connection
.
extension_enabled?
(
extension
)
connection
.
disable_extension
extension
connection
.
reconnect!
end
unless
ENV
[
'FIXTURE_DEBUG'
]
module
ActiveRecord::TestFixtures::ClassMethods
def
try_to_load_dependency_with_silence
(
*
args
)
...
...
activerecord/test/cases/migration/rename_table_test.rb
浏览文件 @
0ab9301f
...
...
@@ -78,11 +78,12 @@ def test_rename_table_for_postgresql_should_also_rename_default_sequence
end
def
test_renaming_table_doesnt_attempt_to_rename_non_existent_sequences
enable_
uuid_ossp!
(
connection
)
enable_
extension!
(
'uuid-ossp'
,
connection
)
connection
.
create_table
:cats
,
id: :uuid
assert_nothing_raised
{
rename_table
:cats
,
:felines
}
assert
connection
.
table_exists?
:felines
ensure
disable_extension!
(
'uuid-ossp'
,
connection
)
connection
.
drop_table
:cats
if
connection
.
table_exists?
:cats
connection
.
drop_table
:felines
if
connection
.
table_exists?
:felines
end
...
...
activerecord/test/schema/schema.rb
浏览文件 @
0ab9301f
...
...
@@ -10,7 +10,7 @@ def except(adapter_names_to_exclude)
#put adapter specific setup here
case
adapter_name
when
"PostgreSQL"
enable_
uuid_ossp!
(
ActiveRecord
::
Base
.
connection
)
enable_
extension!
(
'uuid-ossp'
,
ActiveRecord
::
Base
.
connection
)
create_table
:uuid_parents
,
id: :uuid
,
force:
true
do
|
t
|
t
.
string
:name
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录