Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ef877bbc
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,发现更多精彩内容 >>
提交
ef877bbc
编写于
1月 01, 2015
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18288 from claudiob/add-skip-action-mailer
Add --skip-action-mailer (or -M) to rails generate
上级
4ba0e2fc
b6f50b3f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
75 addition
and
4 deletion
+75
-4
railties/CHANGELOG.md
railties/CHANGELOG.md
+4
-0
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+5
-1
railties/lib/rails/generators/rails/app/templates/config/application.rb
...ails/generators/rails/app/templates/config/application.rb
+1
-1
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
...rails/app/templates/config/environments/development.rb.tt
+2
-0
railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
.../rails/app/templates/config/environments/production.rb.tt
+2
-0
railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
...rators/rails/app/templates/config/environments/test.rb.tt
+2
-0
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
...ies/lib/rails/generators/rails/plugin/plugin_generator.rb
+2
-1
railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
...ls/generators/rails/plugin/templates/rails/application.rb
+1
-1
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+28
-0
railties/test/generators/plugin_generator_test.rb
railties/test/generators/plugin_generator_test.rb
+28
-0
未找到文件。
railties/CHANGELOG.md
浏览文件 @
ef877bbc
*
Add
`--skip-action-mailer`
option to the app generator.
*claudiob*
*
Autoload any second level directories called
`app/*/concerns`
.
*Alex Robbin*
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
ef877bbc
...
...
@@ -38,6 +38,10 @@ def self.add_shared_options_for(name)
class_option
:skip_keeps
,
type: :boolean
,
default:
false
,
desc:
'Skip source control .keep files'
class_option
:skip_action_mailer
,
type: :boolean
,
aliases:
"-M"
,
default:
false
,
desc:
"Skip Action Mailer files"
class_option
:skip_active_record
,
type: :boolean
,
aliases:
'-O'
,
default:
false
,
desc:
'Skip Active Record files'
...
...
@@ -164,7 +168,7 @@ def database_gemfile_entry
end
def
include_all_railties?
!
options
[
:skip_active_record
]
&&
!
options
[
:skip_test_unit
]
&&
!
options
[
:skip_sprockets
]
options
.
values_at
(
:skip_active_record
,
:skip_action_mailer
,
:skip_test_unit
,
:skip_sprockets
).
none?
end
def
comment_if
(
value
)
...
...
railties/lib/rails/generators/rails/app/templates/config/application.rb
浏览文件 @
ef877bbc
...
...
@@ -8,7 +8,7 @@
require
"active_job/railtie"
<
%= comment_if :skip_active_record %>require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
<%=
comment_if
:skip_action_mailer
%>
require
"action_mailer/railtie"
require
"action_view/railtie"
<
%= comment_if :skip_sprockets %>require "sprockets/railtie"
<%=
comment_if
:skip_test_unit
%>
require
"rails/test_unit/railtie"
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
浏览文件 @
ef877bbc
...
...
@@ -12,9 +12,11 @@ Rails.application.configure do
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
<%- unless options.skip_action_mailer? -%>
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
<%- end -%>
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
浏览文件 @
ef877bbc
...
...
@@ -61,10 +61,12 @@ Rails.application.configure do
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
<%- unless options.skip_action_mailer? -%>
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
<%- end -%>
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
浏览文件 @
ef877bbc
...
...
@@ -25,11 +25,13 @@ Rails.application.configure do
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
<%- unless options.skip_action_mailer? -%>
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
<%- end -%>
# Randomize the order test cases are executed.
config.active_support.test_order = :random
...
...
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
浏览文件 @
ef877bbc
...
...
@@ -74,7 +74,8 @@ def test
end
PASSTHROUGH_OPTIONS
=
[
:skip_active_record
,
:skip_javascript
,
:database
,
:javascript
,
:quiet
,
:pretend
,
:force
,
:skip
:skip_active_record
,
:skip_action_mailer
,
:skip_javascript
,
:database
,
:javascript
,
:quiet
,
:pretend
,
:force
,
:skip
]
def
generate_test_dummy
(
force
=
false
)
...
...
railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
浏览文件 @
ef877bbc
...
...
@@ -6,7 +6,7 @@
# Pick the frameworks you want:
<
%= comment_if :skip_active_record %>require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
<%=
comment_if
:skip_action_mailer
%>
require
"action_mailer/railtie"
require
"action_view/railtie"
<
%= comment_if :skip_sprockets %>require "sprockets/railtie"
<%=
comment_if
:skip_test_unit
%>
require
"rails/test_unit/railtie"
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
ef877bbc
...
...
@@ -259,6 +259,20 @@ def test_config_jdbc_database_when_no_option_given
end
end
def
test_generator_without_skips
run_generator
assert_file
"config/application.rb"
,
/\s+require\s+["']rails\/all["']/
assert_file
"config/environments/development.rb"
do
|
content
|
assert_match
(
/config\.action_mailer\.raise_delivery_errors = false/
,
content
)
end
assert_file
"config/environments/test.rb"
do
|
content
|
assert_match
(
/config\.action_mailer\.delivery_method = :test/
,
content
)
end
assert_file
"config/environments/production.rb"
do
|
content
|
assert_match
(
/# config\.action_mailer\.raise_delivery_errors = false/
,
content
)
end
end
def
test_generator_if_skip_active_record_is_given
run_generator
[
destination_root
,
"--skip-active-record"
]
assert_no_file
"config/database.yml"
...
...
@@ -268,6 +282,20 @@ def test_generator_if_skip_active_record_is_given
end
end
def
test_generator_if_skip_action_mailer_is_given
run_generator
[
destination_root
,
"--skip-action-mailer"
]
assert_file
"config/application.rb"
,
/#\s+require\s+["']action_mailer\/railtie["']/
assert_file
"config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
assert_file
"config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
assert_file
"config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
end
def
test_generator_if_skip_sprockets_is_given
run_generator
[
destination_root
,
"--skip-sprockets"
]
assert_no_file
"config/initializers/assets.rb"
...
...
railties/test/generators/plugin_generator_test.rb
浏览文件 @
ef877bbc
...
...
@@ -140,6 +140,20 @@ def test_dont_generate_development_dependency
end
end
def
test_app_generator_without_skips
run_generator
assert_file
"test/dummy/config/application.rb"
,
/\s+require\s+["']rails\/all["']/
assert_file
"test/dummy/config/environments/development.rb"
do
|
content
|
assert_match
(
/config\.action_mailer\.raise_delivery_errors = false/
,
content
)
end
assert_file
"test/dummy/config/environments/test.rb"
do
|
content
|
assert_match
(
/config\.action_mailer\.delivery_method = :test/
,
content
)
end
assert_file
"test/dummy/config/environments/production.rb"
do
|
content
|
assert_match
(
/# config\.action_mailer\.raise_delivery_errors = false/
,
content
)
end
end
def
test_active_record_is_removed_from_frameworks_if_skip_active_record_is_given
run_generator
[
destination_root
,
"--skip-active-record"
]
assert_file
"test/dummy/config/application.rb"
,
/#\s+require\s+["']active_record\/railtie["']/
...
...
@@ -153,6 +167,20 @@ def test_ensure_that_skip_active_record_option_is_passed_to_app_generator
end
end
def
test_action_mailer_is_removed_from_frameworks_if_skip_action_mailer_is_given
run_generator
[
destination_root
,
"--skip-action-mailer"
]
assert_file
"test/dummy/config/application.rb"
,
/#\s+require\s+["']action_mailer\/railtie["']/
assert_file
"test/dummy/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
assert_file
"test/dummy/config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
assert_file
"test/dummy/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.action_mailer/
,
content
)
end
end
def
test_ensure_that_database_option_is_passed_to_app_generator
run_generator
[
destination_root
,
"--database"
,
"postgresql"
]
assert_file
"test/dummy/config/database.yml"
,
/postgres/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录