Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6f4a556b
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,发现更多精彩内容 >>
提交
6f4a556b
编写于
12月 21, 2013
作者:
G
Guillermo Iguaran
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13443 from schneems/schneems/fix-master-tests
Fix DB Console tests
上级
6d255b74
dd93a5f4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
26 addition
and
24 deletion
+26
-24
railties/test/application/initializers/frameworks_test.rb
railties/test/application/initializers/frameworks_test.rb
+1
-1
railties/test/application/rake/dbs_test.rb
railties/test/application/rake/dbs_test.rb
+3
-3
railties/test/commands/dbconsole_test.rb
railties/test/commands/dbconsole_test.rb
+22
-20
未找到文件。
railties/test/application/initializers/frameworks_test.rb
浏览文件 @
6f4a556b
...
...
@@ -216,7 +216,7 @@ def from_bar_helper
require
"
#{
app_path
}
/config/environment"
orig_database_url
=
ENV
.
delete
(
"DATABASE_URL"
)
orig_rails_env
,
Rails
.
env
=
Rails
.
env
,
'development'
database_url_db_name
=
"db/database_url_db.sqlite3"
database_url_db_name
=
File
.
join
(
app_path
,
"db/database_url_db.sqlite3"
)
ENV
[
"DATABASE_URL"
]
=
"sqlite3://:@localhost/
#{
database_url_db_name
}
"
ActiveRecord
::
Base
.
establish_connection
assert
ActiveRecord
::
Base
.
connection
...
...
railties/test/application/rake/dbs_test.rb
浏览文件 @
6f4a556b
...
...
@@ -16,11 +16,11 @@ def teardown
end
def
database_url_db_name
"db/database_url_db.sqlite3"
File
.
join
(
app_path
,
"db/database_url_db.sqlite3"
)
end
def
set_database_url
ENV
[
'DATABASE_URL'
]
=
"sqlite3://:@localhost/
#{
database_url_db_name
}
"
ENV
[
'DATABASE_URL'
]
=
File
.
join
(
"sqlite3://:@localhost"
,
database_url_db_name
)
# ensure it's using the DATABASE_URL
FileUtils
.
rm_rf
(
"
#{
app_path
}
/config/database.yml"
)
end
...
...
@@ -60,7 +60,7 @@ def db_migrate_and_status
`rails generate model book title:string;
bundle exec rake db:migrate`
output
=
`bundle exec rake db:migrate:status`
assert_match
(
/database:\s+\S+
#{
expected
[
:database
]
}
/
,
output
)
assert_match
(
%r{database:
\s
+
\S
*
#{
Regexp
.
escape
(
expected
[
:database
])
}
}
,
output
)
assert_match
(
/up\s+\d{14}\s+Create books/
,
output
)
end
end
...
...
railties/test/commands/dbconsole_test.rb
浏览文件 @
6f4a556b
...
...
@@ -38,36 +38,38 @@ def test_config_with_no_db_config
end
def
test_config_with_database_url_only
ENV
[
'DATABASE_URL'
]
=
'
sqlite3
://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
ENV
[
'DATABASE_URL'
]
=
'
postgresql
://foo:bar@localhost:9000/foo_test?pool=5&timeout=3000'
app_db_config
(
nil
)
assert_equal
Rails
::
DBConsole
.
new
.
config
.
sort
,
{
"adapter"
=>
"sqlite3
"
,
"host"
=>
"localhost"
,
"port"
=>
9000
,
"database"
=>
"foo_test"
,
"username"
=>
"foo"
,
"password"
=>
"bar"
,
"pool"
=>
"5"
,
"timeout"
=>
"3000"
expected
=
{
"adapter"
=>
"postgresql
"
,
"host"
=>
"localhost"
,
"port"
=>
9000
,
"database"
=>
"foo_test"
,
"username"
=>
"foo"
,
"password"
=>
"bar"
,
"pool"
=>
"5"
,
"timeout"
=>
"3000"
}.
sort
assert_equal
expected
,
Rails
::
DBConsole
.
new
.
config
.
sort
end
def
test_config_choose_database_url_if_exists
ENV
[
'DATABASE_URL'
]
=
'sqlite3://foo:bar@dburl:9000/foo_test?pool=5&timeout=3000'
host
=
"database-url-host.com"
ENV
[
'DATABASE_URL'
]
=
"postgresql://foo:bar@
#{
host
}
:9000/foo_test?pool=5&timeout=3000"
sample_config
=
{
"test"
=>
{
"adapter"
=>
"sqlite3
"
,
"host"
=>
"localhost
"
,
"port"
=>
9000
,
"database"
=>
"foo_test"
,
"username"
=>
"foo"
,
"password"
=>
"bar"
,
"pool"
=>
"5"
,
"timeout"
=>
"3000"
"adapter"
=>
"postgresql
"
,
"host"
=>
"not-the-
#{
host
}
"
,
"port"
=>
9000
,
"database"
=>
"foo_test"
,
"username"
=>
"foo"
,
"password"
=>
"bar"
,
"pool"
=>
"5"
,
"timeout"
=>
"3000"
}
}
app_db_config
(
sample_config
)
assert_equal
Rails
::
DBConsole
.
new
.
config
[
"host"
],
"dburl"
assert_equal
host
,
Rails
::
DBConsole
.
new
.
config
[
"host"
]
end
def
test_env
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录