Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
11b884e5
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 搜索 >>
未验证
提交
11b884e5
编写于
3月 31, 2018
作者:
E
Eileen M. Uchitelle
提交者:
GitHub
3月 31, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #32396 from eugeneius/database_configurations_url
Fix two-level database configurations with URLs
上级
088cf269
726e21e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
11 deletion
+53
-11
activerecord/lib/active_record/database_configurations.rb
activerecord/lib/active_record/database_configurations.rb
+1
-1
activerecord/test/cases/tasks/database_tasks_test.rb
activerecord/test/cases/tasks/database_tasks_test.rb
+52
-10
未找到文件。
activerecord/lib/active_record/database_configurations.rb
浏览文件 @
11b884e5
...
...
@@ -43,7 +43,7 @@ def self.configs_for(env, configs = ActiveRecord::Base.configurations, &blk) # :
# Given an env, spec and config creates DatabaseConfig structs with
# each attribute set.
def
self
.
walk_configs
(
env_name
,
spec_name
,
config
)
# :nodoc:
if
config
[
"database"
]
||
env_name
==
"default"
if
config
[
"database"
]
||
config
[
"url"
]
||
env_name
==
"default"
DatabaseConfig
.
new
(
env_name
,
spec_name
,
config
)
else
config
.
each_pair
.
map
do
|
sub_spec_name
,
sub_config
|
...
...
activerecord/test/cases/tasks/database_tasks_test.rb
浏览文件 @
11b884e5
...
...
@@ -179,7 +179,7 @@ def setup
@configurations
=
{
"development"
=>
{
"database"
=>
"dev-db"
},
"test"
=>
{
"database"
=>
"test-db"
},
"production"
=>
{
"
database"
=>
"prod-db
"
}
"production"
=>
{
"
url"
=>
"prod-db-url
"
}
}
ActiveRecord
::
Base
.
stubs
(
:configurations
).
returns
(
@configurations
)
...
...
@@ -188,7 +188,16 @@ def setup
def
test_creates_current_environment_database
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"database"
=>
"prod-db"
)
with
(
"database"
=>
"test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
create_current
(
ActiveSupport
::
StringInquirer
.
new
(
"test"
)
)
end
def
test_creates_current_environment_database_with_url
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"url"
=>
"prod-db-url"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
create_current
(
ActiveSupport
::
StringInquirer
.
new
(
"production"
)
...
...
@@ -237,7 +246,7 @@ def setup
@configurations
=
{
"development"
=>
{
"primary"
=>
{
"database"
=>
"dev-db"
},
"secondary"
=>
{
"database"
=>
"secondary-dev-db"
}
},
"test"
=>
{
"primary"
=>
{
"database"
=>
"test-db"
},
"secondary"
=>
{
"database"
=>
"secondary-test-db"
}
},
"production"
=>
{
"primary"
=>
{
"
database"
=>
"prod-db"
},
"secondary"
=>
{
"database"
=>
"secondary-prod-db
"
}
}
"production"
=>
{
"primary"
=>
{
"
url"
=>
"prod-db-url"
},
"secondary"
=>
{
"url"
=>
"secondary-prod-db-url
"
}
}
}
ActiveRecord
::
Base
.
stubs
(
:configurations
).
returns
(
@configurations
)
...
...
@@ -246,10 +255,22 @@ def setup
def
test_creates_current_environment_database
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"database"
=>
"prod-db"
)
with
(
"database"
=>
"test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"database"
=>
"secondary-test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
create_current
(
ActiveSupport
::
StringInquirer
.
new
(
"test"
)
)
end
def
test_creates_current_environment_database_with_url
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"url"
=>
"prod-db-url"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:create
).
with
(
"
database"
=>
"secondary-prod-db
"
)
with
(
"
url"
=>
"secondary-prod-db-url
"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
create_current
(
ActiveSupport
::
StringInquirer
.
new
(
"production"
)
...
...
@@ -374,7 +395,7 @@ def setup
@configurations
=
{
"development"
=>
{
"database"
=>
"dev-db"
},
"test"
=>
{
"database"
=>
"test-db"
},
"production"
=>
{
"
database"
=>
"prod-db
"
}
"production"
=>
{
"
url"
=>
"prod-db-url
"
}
}
ActiveRecord
::
Base
.
stubs
(
:configurations
).
returns
(
@configurations
)
...
...
@@ -382,7 +403,16 @@ def setup
def
test_drops_current_environment_database
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"database"
=>
"prod-db"
)
with
(
"database"
=>
"test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
drop_current
(
ActiveSupport
::
StringInquirer
.
new
(
"test"
)
)
end
def
test_drops_current_environment_database_with_url
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"url"
=>
"prod-db-url"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
drop_current
(
ActiveSupport
::
StringInquirer
.
new
(
"production"
)
...
...
@@ -421,7 +451,7 @@ def setup
@configurations
=
{
"development"
=>
{
"primary"
=>
{
"database"
=>
"dev-db"
},
"secondary"
=>
{
"database"
=>
"secondary-dev-db"
}
},
"test"
=>
{
"primary"
=>
{
"database"
=>
"test-db"
},
"secondary"
=>
{
"database"
=>
"secondary-test-db"
}
},
"production"
=>
{
"primary"
=>
{
"
database"
=>
"prod-db"
},
"secondary"
=>
{
"database"
=>
"secondary-prod-db
"
}
}
"production"
=>
{
"primary"
=>
{
"
url"
=>
"prod-db-url"
},
"secondary"
=>
{
"url"
=>
"secondary-prod-db-url
"
}
}
}
ActiveRecord
::
Base
.
stubs
(
:configurations
).
returns
(
@configurations
)
...
...
@@ -429,10 +459,22 @@ def setup
def
test_drops_current_environment_database
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"database"
=>
"prod-db"
)
with
(
"database"
=>
"test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"database"
=>
"secondary-test-db"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
drop_current
(
ActiveSupport
::
StringInquirer
.
new
(
"test"
)
)
end
def
test_drops_current_environment_database_with_url
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"url"
=>
"prod-db-url"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
expects
(
:drop
).
with
(
"
database"
=>
"secondary-prod-db
"
)
with
(
"
url"
=>
"secondary-prod-db-url
"
)
ActiveRecord
::
Tasks
::
DatabaseTasks
.
drop_current
(
ActiveSupport
::
StringInquirer
.
new
(
"production"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录