Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
63f0c048
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,发现更多精彩内容 >>
未验证
提交
63f0c048
编写于
11月 06, 2017
作者:
R
Rafael França
提交者:
GitHub
11月 06, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #30101 from bogdanvlviv/initialization-active_storage
Provide initialization of Active Storage
上级
256a44c4
cb8553c9
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
385 addition
and
104 deletion
+385
-104
activejob/test/support/integration/dummy_app_template.rb
activejob/test/support/integration/dummy_app_template.rb
+0
-2
activejob/test/support/integration/helper.rb
activejob/test/support/integration/helper.rb
+1
-0
railties/CHANGELOG.md
railties/CHANGELOG.md
+6
-0
railties/lib/rails/all.rb
railties/lib/rails/all.rb
+1
-1
railties/lib/rails/app_updater.rb
railties/lib/rails/app_updater.rb
+6
-5
railties/lib/rails/generators/actions.rb
railties/lib/rails/generators/actions.rb
+7
-1
railties/lib/rails/generators/app_base.rb
railties/lib/rails/generators/app_base.rb
+80
-49
railties/lib/rails/generators/rails/app/app_generator.rb
railties/lib/rails/generators/rails/app/app_generator.rb
+7
-2
railties/lib/rails/generators/rails/app/templates/Gemfile
railties/lib/rails/generators/rails/app/templates/Gemfile
+2
-1
railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
...ls/app/templates/app/assets/javascripts/application.js.tt
+2
-0
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
+3
-0
railties/lib/rails/generators/rails/app/templates/gitignore
railties/lib/rails/generators/rails/app/templates/gitignore
+2
-0
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
...ies/lib/rails/generators/rails/plugin/plugin_generator.rb
+1
-1
railties/lib/rails/generators/rails/plugin/templates/gitignore
...ies/lib/rails/generators/rails/plugin/templates/gitignore
+3
-0
railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
...ls/generators/rails/plugin/templates/rails/application.rb
+1
-1
railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
...ls/generators/rails/plugin/templates/rails/javascripts.js
+3
-0
railties/test/application/bin_setup_test.rb
railties/test/application/bin_setup_test.rb
+4
-0
railties/test/application/integration_test_case_test.rb
railties/test/application/integration_test_case_test.rb
+5
-2
railties/test/application/rackup_test.rb
railties/test/application/rackup_test.rb
+1
-0
railties/test/application/rake/dbs_test.rb
railties/test/application/rake/dbs_test.rb
+4
-0
railties/test/application/test_runner_test.rb
railties/test/application/test_runner_test.rb
+5
-0
railties/test/application/test_test.rb
railties/test/application/test_test.rb
+5
-0
railties/test/generators/actions_test.rb
railties/test/generators/actions_test.rb
+16
-0
railties/test/generators/app_generator_test.rb
railties/test/generators/app_generator_test.rb
+69
-5
railties/test/generators/plugin_generator_test.rb
railties/test/generators/plugin_generator_test.rb
+2
-3
railties/test/generators/plugin_test_runner_test.rb
railties/test/generators/plugin_test_runner_test.rb
+1
-1
railties/test/generators/scaffold_controller_generator_test.rb
...ies/test/generators/scaffold_controller_generator_test.rb
+2
-0
railties/test/generators/shared_generator_tests.rb
railties/test/generators/shared_generator_tests.rb
+112
-8
railties/test/generators/test_runner_in_engine_test.rb
railties/test/generators/test_runner_in_engine_test.rb
+1
-1
railties/test/isolation/abstract_unit.rb
railties/test/isolation/abstract_unit.rb
+1
-0
railties/test/railties/engine_test.rb
railties/test/railties/engine_test.rb
+27
-20
未找到文件。
activejob/test/support/integration/dummy_app_template.rb
浏览文件 @
63f0c048
...
...
@@ -4,8 +4,6 @@
generate
"delayed_job:active_record"
,
"--quiet"
end
rails_command
(
"db:migrate"
)
initializer
"activejob.rb"
,
<<-
CODE
require "
#{
File
.
expand_path
(
"jobs_manager.rb"
,
__dir__
)
}
"
JobsManager.current_manager.setup
...
...
activejob/test/support/integration/helper.rb
浏览文件 @
63f0c048
...
...
@@ -18,6 +18,7 @@
require
"
#{
dummy_app_path
}
/config/environment.rb"
ActiveRecord
::
Migrator
.
migrations_paths
=
[
Rails
.
root
.
join
(
"db/migrate"
).
to_s
]
ActiveRecord
::
Tasks
::
DatabaseTasks
.
migrate
require
"rails/test_help"
Rails
.
backtrace_cleaner
.
remove_silencers!
...
...
railties/CHANGELOG.md
浏览文件 @
63f0c048
*
`rails new`
and
`rails plugin new`
get
`Active Storage`
by default.
Add ability to skip
`Active Storage`
with
`--skip-active-storage`
and do so automatically when
`--skip-active-record`
is used.
*bogdanvlviv*
*
Gemfile for new apps: upgrade redis-rb from ~> 3.0 to 4.0.
*Jeremy Daer*
...
...
railties/lib/rails/all.rb
浏览文件 @
63f0c048
...
...
@@ -4,12 +4,12 @@
%w(
active_record/railtie
active_storage/engine
action_controller/railtie
action_view/railtie
action_mailer/railtie
active_job/railtie
action_cable/engine
active_storage/engine
rails/test_unit/railtie
sprockets/railtie
)
.
each
do
|
railtie
|
...
...
railties/lib/rails/app_updater.rb
浏览文件 @
63f0c048
...
...
@@ -21,11 +21,12 @@ def app_generator
private
def
generator_options
options
=
{
api:
!!
Rails
.
application
.
config
.
api_only
,
update:
true
}
options
[
:skip_active_record
]
=
!
defined?
(
ActiveRecord
::
Railtie
)
options
[
:skip_action_mailer
]
=
!
defined?
(
ActionMailer
::
Railtie
)
options
[
:skip_action_cable
]
=
!
defined?
(
ActionCable
::
Engine
)
options
[
:skip_sprockets
]
=
!
defined?
(
Sprockets
::
Railtie
)
options
[
:skip_puma
]
=
!
defined?
(
Puma
)
options
[
:skip_active_record
]
=
!
defined?
(
ActiveRecord
::
Railtie
)
options
[
:skip_active_storage
]
=
!
defined?
(
ActiveStorage
::
Engine
)
||
!
defined?
(
ActiveRecord
::
Railtie
)
options
[
:skip_action_mailer
]
=
!
defined?
(
ActionMailer
::
Railtie
)
options
[
:skip_action_cable
]
=
!
defined?
(
ActionCable
::
Engine
)
options
[
:skip_sprockets
]
=
!
defined?
(
Sprockets
::
Railtie
)
options
[
:skip_puma
]
=
!
defined?
(
Puma
)
options
end
end
...
...
railties/lib/rails/generators/actions.rb
浏览文件 @
63f0c048
...
...
@@ -221,6 +221,7 @@ def generate(what, *args)
# rake("db:migrate")
# rake("db:migrate", env: "production")
# rake("gems:install", sudo: true)
# rake("gems:install", capture: true)
def
rake
(
command
,
options
=
{})
execute_command
:rake
,
command
,
options
end
...
...
@@ -230,6 +231,7 @@ def rake(command, options = {})
# rails_command("db:migrate")
# rails_command("db:migrate", env: "production")
# rails_command("gems:install", sudo: true)
# rails_command("gems:install", capture: true)
def
rails_command
(
command
,
options
=
{})
execute_command
:rails
,
command
,
options
end
...
...
@@ -292,7 +294,11 @@ def execute_command(executor, command, options = {}) # :doc:
log
executor
,
command
env
=
options
[
:env
]
||
ENV
[
"RAILS_ENV"
]
||
"development"
sudo
=
options
[
:sudo
]
&&
!
Gem
.
win_platform?
?
"sudo "
:
""
in_root
{
run
(
"
#{
sudo
}#{
extify
(
executor
)
}
#{
command
}
RAILS_ENV=
#{
env
}
"
,
verbose:
false
)
}
config
=
{
verbose:
false
}
config
.
merge!
(
capture:
options
[
:capture
])
if
options
[
:capture
]
in_root
{
run
(
"
#{
sudo
}#{
extify
(
executor
)
}
#{
command
}
RAILS_ENV=
#{
env
}
"
,
config
)
}
end
# Add an extension to the given name based on the platform.
...
...
railties/lib/rails/generators/app_base.rb
浏览文件 @
63f0c048
...
...
@@ -26,75 +26,78 @@ def self.strict_args_position
end
def
self
.
add_shared_options_for
(
name
)
class_option
:template
,
type: :string
,
aliases:
"-m"
,
desc:
"Path to some
#{
name
}
template (can be a filesystem path or URL)"
class_option
:template
,
type: :string
,
aliases:
"-m"
,
desc:
"Path to some
#{
name
}
template (can be a filesystem path or URL)"
class_option
:database
,
type: :string
,
aliases:
"-d"
,
default:
"sqlite3"
,
desc:
"Preconfigure for selected database (options:
#{
DATABASES
.
join
(
'/'
)
}
)"
class_option
:database
,
type: :string
,
aliases:
"-d"
,
default:
"sqlite3"
,
desc:
"Preconfigure for selected database (options:
#{
DATABASES
.
join
(
'/'
)
}
)"
class_option
:skip_yarn
,
type: :boolean
,
default:
false
,
desc:
"Don't use Yarn for managing JavaScript dependencies"
class_option
:skip_yarn
,
type: :boolean
,
default:
false
,
desc:
"Don't use Yarn for managing JavaScript dependencies"
class_option
:skip_gemfile
,
type: :boolean
,
default:
false
,
desc:
"Don't create a Gemfile"
class_option
:skip_gemfile
,
type: :boolean
,
default:
false
,
desc:
"Don't create a Gemfile"
class_option
:skip_git
,
type: :boolean
,
aliases:
"-G"
,
default:
false
,
desc:
"Skip .gitignore file"
class_option
:skip_git
,
type: :boolean
,
aliases:
"-G"
,
default:
false
,
desc:
"Skip .gitignore file"
class_option
:skip_keeps
,
type: :boolean
,
default:
false
,
desc:
"Skip source control .keep files"
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_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"
class_option
:skip_active_record
,
type: :boolean
,
aliases:
"-O"
,
default:
false
,
desc:
"Skip Active Record files"
class_option
:skip_
puma
,
type: :boolean
,
aliases:
"-P"
,
default:
false
,
desc:
"Skip Puma related
files"
class_option
:skip_
active_storage
,
type: :boolean
,
default:
false
,
desc:
"Skip Active Storage
files"
class_option
:skip_
action_cable
,
type: :boolean
,
aliases:
"-C
"
,
default:
false
,
desc:
"Skip Action Cable
files"
class_option
:skip_
puma
,
type: :boolean
,
aliases:
"-P
"
,
default:
false
,
desc:
"Skip Puma related
files"
class_option
:skip_
sprockets
,
type: :boolean
,
aliases:
"-S
"
,
default:
false
,
desc:
"Skip Sprockets
files"
class_option
:skip_
action_cable
,
type: :boolean
,
aliases:
"-C
"
,
default:
false
,
desc:
"Skip Action Cable
files"
class_option
:skip_spr
ing
,
type: :boolean
,
default:
false
,
desc:
"Don't install Spring application preloader
"
class_option
:skip_spr
ockets
,
type: :boolean
,
aliases:
"-S"
,
default:
false
,
desc:
"Skip Sprockets files
"
class_option
:skip_
listen
,
type: :boolean
,
default:
false
,
desc:
"Don't generate configuration that depends on the listen gem
"
class_option
:skip_
spring
,
type: :boolean
,
default:
false
,
desc:
"Don't install Spring application preloader
"
class_option
:skip_
coffee
,
type: :boolean
,
default:
false
,
desc:
"Don't use CoffeeScript
"
class_option
:skip_
listen
,
type: :boolean
,
default:
false
,
desc:
"Don't generate configuration that depends on the listen gem
"
class_option
:skip_
javascript
,
type: :boolean
,
aliases:
"-J"
,
default:
false
,
desc:
"Skip JavaScript files
"
class_option
:skip_
coffee
,
type: :boolean
,
default:
false
,
desc:
"Don't use CoffeeScript
"
class_option
:skip_
turbolinks
,
type: :boolean
,
default:
false
,
desc:
"Skip turbolinks gem
"
class_option
:skip_
javascript
,
type: :boolean
,
aliases:
"-J"
,
default:
false
,
desc:
"Skip JavaScript files
"
class_option
:skip_t
est
,
type: :boolean
,
aliases:
"-T"
,
default:
false
,
desc:
"Skip test files
"
class_option
:skip_t
urbolinks
,
type: :boolean
,
default:
false
,
desc:
"Skip turbolinks gem
"
class_option
:skip_
system_test
,
type: :boolean
,
default:
false
,
desc:
"Skip system
test files"
class_option
:skip_
test
,
type: :boolean
,
aliases:
"-T"
,
default:
false
,
desc:
"Skip
test files"
class_option
:
dev
,
type: :boolean
,
default:
false
,
desc:
"Setup the
#{
name
}
with Gemfile pointing to your Rails checkout
"
class_option
:
skip_system_test
,
type: :boolean
,
default:
false
,
desc:
"Skip system test files
"
class_option
:
edge
,
type: :boolean
,
default:
false
,
desc:
"Setup the
#{
name
}
with Gemfile pointing to Rails repository
"
class_option
:
dev
,
type: :boolean
,
default:
false
,
desc:
"Setup the
#{
name
}
with Gemfile pointing to your Rails checkout
"
class_option
:
rc
,
type: :string
,
default:
nil
,
desc:
"Path to file containing extra configuration options for rails command
"
class_option
:
edge
,
type: :boolean
,
default:
false
,
desc:
"Setup the
#{
name
}
with Gemfile pointing to Rails repository
"
class_option
:
no_rc
,
type: :boolean
,
default:
false
,
desc:
"Skip loading of extra configuration options from .railsrc file
"
class_option
:
rc
,
type: :string
,
default:
nil
,
desc:
"Path to file containing extra configuration options for rails command
"
class_option
:help
,
type: :boolean
,
aliases:
"-h"
,
group: :rails
,
desc:
"Show this help message and quit"
class_option
:no_rc
,
type: :boolean
,
default:
false
,
desc:
"Skip loading of extra configuration options from .railsrc file"
class_option
:help
,
type: :boolean
,
aliases:
"-h"
,
group: :rails
,
desc:
"Show this help message and quit"
end
def
initialize
(
*
args
)
...
...
@@ -193,11 +196,29 @@ def webserver_gemfile_entry # :doc:
end
def
include_all_railties?
# :doc:
options
.
values_at
(
:skip_active_record
,
:skip_action_mailer
,
:skip_test
,
:skip_sprockets
,
:skip_action_cable
).
none?
[
options
.
values_at
(
:skip_active_record
,
:skip_action_mailer
,
:skip_test
,
:skip_sprockets
,
:skip_action_cable
),
skip_active_storage?
].
flatten
.
none?
end
def
comment_if
(
value
)
# :doc:
options
[
value
]
?
"# "
:
""
question
=
"
#{
value
}
?"
comment
=
if
respond_to?
(
question
,
true
)
send
(
question
)
else
options
[
value
]
end
comment
?
"# "
:
""
end
def
keeps?
# :doc:
...
...
@@ -208,6 +229,10 @@ def sqlite3? # :doc:
!
options
[
:skip_active_record
]
&&
options
[
:database
]
==
"sqlite3"
end
def
skip_active_storage?
# :doc:
options
[
:skip_active_storage
]
||
options
[
:skip_active_record
]
end
class
GemfileEntry
<
Struct
.
new
(
:name
,
:version
,
:comment
,
:options
,
:commented_out
)
def
initialize
(
name
,
version
,
comment
,
options
=
{},
commented_out
=
false
)
super
...
...
@@ -434,6 +459,12 @@ def generate_spring_binstubs
end
end
def
run_active_storage
unless
skip_active_storage?
rails_command
"active_storage:install"
,
capture:
options
[
:quiet
]
end
end
def
empty_directory_with_keep_file
(
destination
,
config
=
{})
empty_directory
(
destination
,
config
)
keep_file
(
destination
)
...
...
railties/lib/rails/generators/rails/app/app_generator.rb
浏览文件 @
63f0c048
...
...
@@ -114,7 +114,7 @@ def config
template
"cable.yml"
unless
options
[
:skip_action_cable
]
template
"puma.rb"
unless
options
[
:skip_puma
]
template
"spring.rb"
if
spring_install?
template
"storage.yml"
template
"storage.yml"
unless
skip_active_storage?
directory
"environments"
directory
"initializers"
...
...
@@ -139,7 +139,7 @@ def config_when_updating
template
"config/cable.yml"
end
if
!
active_storage_config_exist
if
!
skip_active_storage?
&&
!
active_storage_config_exist
template
"config/storage.yml"
end
...
...
@@ -355,6 +355,10 @@ def create_system_test_files
build
(
:system_test
)
if
depends_on_system_test?
end
def
create_storage_files
build
(
:storage
)
unless
skip_active_storage?
end
def
create_tmp_files
build
(
:tmp
)
end
...
...
@@ -457,6 +461,7 @@ def finish_template
public_task
:apply_rails_template
,
:run_bundle
public_task
:run_webpack
,
:generate_spring_binstubs
public_task
:run_active_storage
def
run_after_bundle_callbacks
@after_bundle_callbacks
.
each
(
&
:call
)
...
...
railties/lib/rails/generators/rails/app/templates/Gemfile
浏览文件 @
63f0c048
...
...
@@ -20,9 +20,10 @@ ruby <%= "'#{RUBY_VERSION}'" -%>
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
<
% unless
skip_active_storage?
-
%>
# Use ActiveStorage variant
# gem 'mini_magick', '~>
4.8
'
<% end -%>
# Use Capistrano for deployment
# gem '
capistrano
-
rails
', group: :development
...
...
railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt
浏览文件 @
63f0c048
...
...
@@ -12,7 +12,9 @@
//
<% unless options[:skip_javascript] -%>
//= require rails-ujs
<% unless skip_active_storage? -%>
//= require activestorage
<% end -%>
<% unless options[:skip_turbolinks] -%>
//= require turbolinks
<% end -%>
...
...
railties/lib/rails/generators/rails/app/templates/config/application.rb
浏览文件 @
63f0c048
...
...
@@ -8,10 +8,10 @@
require
"active_model/railtie"
require
"active_job/railtie"
<
%= comment_if :skip_active_record %>require "active_record/railtie"
<%=
comment_if
:skip_active_storage
%>
require
"active_storage/engine"
require
"action_controller/railtie"
<
%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
require "action_view/railtie"
require
"active_storage/engine"
<%=
comment_if
:skip_action_cable
%>
require
"action_cable/engine"
<
%= comment_if :skip_sprockets %>require "sprockets/railtie"
<%=
comment_if
:skip_test
%>
require
"rails/test_unit/railtie"
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt
浏览文件 @
63f0c048
...
...
@@ -27,8 +27,10 @@ Rails.application.configure do
config.cache_store = :null_store
end
<%- unless skip_active_storage? -%>
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
<%- end -%>
<%- unless options.skip_action_mailer? -%>
# Don't care if the mailer can't send.
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt
浏览文件 @
63f0c048
...
...
@@ -44,9 +44,11 @@ Rails.application.configure do
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
<%- unless skip_active_storage? -%>
# Store uploaded files on the local file system (see config/storage.yml for options)
config.active_storage.service = :local
<%- end -%>
<%- unless options[:skip_action_cable] -%>
# Mount Action Cable outside main process or domain
# config.action_cable.mount_path = nil
...
...
railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt
浏览文件 @
63f0c048
...
...
@@ -28,8 +28,11 @@ Rails.application.configure do
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
<%- unless skip_active_storage? -%>
# Store uploaded files on the local file system in a temporary directory
config.active_storage.service = :test
<%- end -%>
<%- unless options.skip_action_mailer? -%>
config.action_mailer.perform_caching = false
...
...
railties/lib/rails/generators/rails/app/templates/gitignore
浏览文件 @
63f0c048
...
...
@@ -21,8 +21,10 @@
!/tmp/.keep
<% end -%>
<% unless skip_active_storage? -%>
# Ignore uploaded files in development
/storage/*
<% end -%>
<% unless options.skip_yarn? -%>
/node_modules
...
...
railties/lib/rails/generators/rails/plugin/plugin_generator.rb
浏览文件 @
63f0c048
...
...
@@ -87,7 +87,7 @@ def test
end
PASSTHROUGH_OPTIONS
=
[
:skip_active_record
,
:skip_action_mailer
,
:skip_javascript
,
:skip_action_cable
,
:skip_sprockets
,
:database
,
:skip_active_record
,
:skip_acti
ve_storage
,
:skip_acti
on_mailer
,
:skip_javascript
,
:skip_action_cable
,
:skip_sprockets
,
:database
,
:javascript
,
:skip_yarn
,
:api
,
:quiet
,
:pretend
,
:skip
]
...
...
railties/lib/rails/generators/rails/plugin/templates/gitignore
浏览文件 @
63f0c048
...
...
@@ -11,5 +11,8 @@ pkg/
<%= dummy_path %>/node_modules/
<%= dummy_path %>/yarn-error.log
<% end -%>
<% unless skip_active_storage? -%>
<%= dummy_path %>/storage/
<% end -%>
<%= dummy_path %>/tmp/
<% end -%>
railties/lib/rails/generators/rails/plugin/templates/rails/application.rb
浏览文件 @
63f0c048
...
...
@@ -8,10 +8,10 @@
require
"active_model/railtie"
require
"active_job/railtie"
<
%= comment_if :skip_active_record %>require "active_record/railtie"
<%=
comment_if
:skip_active_storage
%>
require
"active_storage/engine"
require
"action_controller/railtie"
<
%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
require "action_view/railtie"
require
"active_storage/engine"
<%=
comment_if
:skip_action_cable
%>
require
"action_cable/engine"
<
%= comment_if :skip_sprockets %>require "sprockets/railtie"
<%=
comment_if
:skip_test
%>
require
"rails/test_unit/railtie"
...
...
railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js
浏览文件 @
63f0c048
...
...
@@ -10,4 +10,7 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
<%
unless
skip_active_storage
?
-%>
//= require activestorage
<%
end
-%>
//= require_tree .
railties/test/application/bin_setup_test.rb
浏览文件 @
63f0c048
...
...
@@ -16,6 +16,8 @@ def teardown
def
test_bin_setup
Dir
.
chdir
(
app_path
)
do
FileUtils
.
rm_rf
(
"db/migrate"
)
app_file
"db/schema.rb"
,
<<-
RUBY
ActiveRecord::Schema.define(version: 20140423102712) do
create_table(:articles) {}
...
...
@@ -37,6 +39,8 @@ def test_bin_setup
def
test_bin_setup_output
Dir
.
chdir
(
app_path
)
do
FileUtils
.
rm_rf
(
"db/migrate"
)
app_file
"db/schema.rb"
,
""
output
=
`bin/setup 2>&1`
...
...
railties/test/application/integration_test_case_test.rb
浏览文件 @
63f0c048
# frozen_string_literal: true
require
"isolation/abstract_unit"
require
"env_helpers"
module
ApplicationTests
class
IntegrationTestCaseTest
<
ActiveSupport
::
TestCase
include
ActiveSupport
::
Testing
::
Isolation
include
ActiveSupport
::
Testing
::
Isolation
,
EnvHelpers
setup
do
build_app
...
...
@@ -39,13 +40,14 @@ class MailerIntegrationTest < ActionDispatch::IntegrationTest
end
RUBY
with_rails_env
(
"test"
)
{
rails
(
"db:migrate"
)
}
output
=
rails
(
"test"
)
assert_match
(
/0 failures, 0 errors/
,
output
)
end
end
class
IntegrationTestDefaultApp
<
ActiveSupport
::
TestCase
include
ActiveSupport
::
Testing
::
Isolation
include
ActiveSupport
::
Testing
::
Isolation
,
EnvHelpers
setup
do
build_app
...
...
@@ -66,6 +68,7 @@ def test_app_returns_action_dispatch_test_app_by_default
end
RUBY
with_rails_env
(
"test"
)
{
rails
(
"db:migrate"
)
}
output
=
rails
(
"test"
)
assert_match
(
/0 failures, 0 errors/
,
output
)
end
...
...
railties/test/application/rackup_test.rb
浏览文件 @
63f0c048
...
...
@@ -26,6 +26,7 @@ def teardown
test
"config.ru can be racked up"
do
Dir
.
chdir
app_path
do
FileUtils
.
rm_rf
(
"db/migrate"
)
@app
=
rackup
assert_welcome
get
(
"/"
)
end
...
...
railties/test/application/rake/dbs_test.rb
浏览文件 @
63f0c048
...
...
@@ -287,6 +287,8 @@ def db_test_load_structure
ENV
.
delete
"RAILS_ENV"
ENV
.
delete
"RACK_ENV"
Dir
.
chdir
(
app_path
)
{
FileUtils
.
rm_rf
(
"db/migrate"
)
}
app_file
"db/schema.rb"
,
<<-
RUBY
ActiveRecord::Schema.define(version: "1") do
create_table :users do |t|
...
...
@@ -308,6 +310,8 @@ def db_test_load_structure
end
test
"db:setup sets ar_internal_metadata"
do
Dir
.
chdir
(
app_path
)
{
FileUtils
.
rm_rf
(
"db/migrate"
)
}
app_file
"db/schema.rb"
,
""
rails
"db:setup"
...
...
railties/test/application/test_runner_test.rb
浏览文件 @
63f0c048
...
...
@@ -11,6 +11,7 @@ class TestRunnerTest < ActiveSupport::TestCase
def
setup
build_app
create_schema
remove_migrations
end
def
teardown
...
...
@@ -727,6 +728,10 @@ def create_schema
app_file
"db/schema.rb"
,
""
end
def
remove_migrations
Dir
.
chdir
(
app_path
)
{
FileUtils
.
rm_rf
(
"db/migrate"
)
}
end
def
create_test_file
(
path
=
:unit
,
name
=
"test"
,
pass:
true
)
app_file
"test/
#{
path
}
/
#{
name
}
_test.rb"
,
<<-
RUBY
require 'test_helper'
...
...
railties/test/application/test_test.rb
浏览文件 @
63f0c048
...
...
@@ -8,6 +8,7 @@ class TestTest < ActiveSupport::TestCase
def
setup
build_app
remove_migrations
end
def
teardown
...
...
@@ -320,6 +321,10 @@ class UserTest < ActiveSupport::TestCase
end
private
def
remove_migrations
Dir
.
chdir
(
app_path
)
{
FileUtils
.
rm_rf
(
"db/migrate"
)
}
end
def
assert_unsuccessful_run
(
name
,
message
)
result
=
run_test_file
(
name
)
assert_not_equal
0
,
$?
.
to_i
...
...
railties/test/generators/actions_test.rb
浏览文件 @
63f0c048
...
...
@@ -308,6 +308,14 @@ def test_rails_with_env_option_should_run_rake_command_in_env
end
end
test
"rake command with capture option should run rake command with capture"
do
assert_called_with
(
generator
,
:run
,
[
"rake log:clear RAILS_ENV=development"
,
verbose:
false
,
capture:
true
])
do
with_rails_env
nil
do
action
:rake
,
"log:clear"
,
capture:
true
end
end
end
test
"rails command should run rails_command with default env"
do
assert_called_with
(
generator
,
:run
,
[
"rails log:clear RAILS_ENV=development"
,
verbose:
false
])
do
with_rails_env
nil
do
...
...
@@ -346,6 +354,14 @@ def test_env_option_should_win_over_rails_env_variable_when_running_rails
end
end
test
"rails command with capture option should run rails_command with capture"
do
assert_called_with
(
generator
,
:run
,
[
"rails log:clear RAILS_ENV=development"
,
verbose:
false
,
capture:
true
])
do
with_rails_env
nil
do
action
:rails_command
,
"log:clear"
,
capture:
true
end
end
end
def
test_capify_should_run_the_capify_command
content
=
capture
(
:stderr
)
do
assert_called_with
(
generator
,
:run
,
[
"capify ."
,
verbose:
false
])
do
...
...
railties/test/generators/app_generator_test.rb
浏览文件 @
63f0c048
...
...
@@ -68,6 +68,7 @@
config/spring.rb
config/storage.yml
db
db/migrate
db/seeds.rb
lib
lib/tasks
...
...
@@ -75,6 +76,7 @@
log
package.json
public
storage
test/application_system_test_case.rb
test/test_helper.rb
test/fixtures
...
...
@@ -89,6 +91,7 @@
tmp
tmp/cache
tmp/cache/assets
tmp/storage
)
class
AppGeneratorTest
<
Rails
::
Generators
::
TestCase
...
...
@@ -296,6 +299,65 @@ def test_app_update_does_not_generate_action_cable_contents_when_skip_action_cab
end
end
def
test_active_storage_mini_magick_gem
run_generator
assert_file
"Gemfile"
,
/^# gem 'mini_magick'/
end
def
test_app_update_does_not_generate_active_storage_contents_when_skip_active_storage_is_given
app_root
=
File
.
join
(
destination_root
,
"myapp"
)
run_generator
[
app_root
,
"--skip-active-storage"
]
FileUtils
.
cd
(
app_root
)
do
quietly
{
system
(
"bin/rails app:update"
)
}
end
assert_file
"
#{
app_root
}
/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
app_root
}
/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
app_root
}
/config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_no_file
"
#{
app_root
}
/config/storage.yml"
assert_file
"
#{
app_root
}
/Gemfile"
do
|
content
|
assert_no_match
(
/gem 'mini_magick'/
,
content
)
end
end
def
test_app_update_does_not_generate_active_storage_contents_when_skip_active_record_is_given
app_root
=
File
.
join
(
destination_root
,
"myapp"
)
run_generator
[
app_root
,
"--skip-active-record"
]
FileUtils
.
cd
(
app_root
)
do
quietly
{
system
(
"bin/rails app:update"
)
}
end
assert_file
"
#{
app_root
}
/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
app_root
}
/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
app_root
}
/config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_no_file
"
#{
app_root
}
/config/storage.yml"
assert_file
"
#{
app_root
}
/Gemfile"
do
|
content
|
assert_no_match
(
/gem 'mini_magick'/
,
content
)
end
end
def
test_application_names_are_not_singularized
run_generator
[
File
.
join
(
destination_root
,
"hats"
)]
assert_file
"hats/config/environment.rb"
,
/Rails\.application\.initialize!/
...
...
@@ -347,7 +409,7 @@ def test_config_postgresql_database
end
def
test_config_jdbcmysql_database
run_generator
([
destination_root
,
"-d"
,
"jdbcmysql"
])
run_generator
([
destination_root
,
"-d"
,
"jdbcmysql"
,
"--skip-active-storage"
])
assert_file
"config/database.yml"
,
/mysql/
assert_gem
"activerecord-jdbcmysql-adapter"
end
...
...
@@ -365,7 +427,7 @@ def test_config_jdbcpostgresql_database
end
def
test_config_jdbc_database
run_generator
([
destination_root
,
"-d"
,
"jdbc"
])
run_generator
([
destination_root
,
"-d"
,
"jdbc"
,
"--skip-active-storage"
])
assert_file
"config/database.yml"
,
/jdbc/
assert_file
"config/database.yml"
,
/mssql/
assert_gem
"activerecord-jdbc-adapter"
...
...
@@ -742,7 +804,7 @@ def test_after_bundle_callback
template
end
sequence
=
[
"git init"
,
"install"
,
"exec spring binstub --all"
,
"echo ran after_bundle"
]
sequence
=
[
"git init"
,
"install"
,
"exec spring binstub --all"
,
"
active_storage:install"
,
"
echo ran after_bundle"
]
@sequence_step
||=
0
ensure_bundler_first
=
->
command
,
options
=
nil
do
assert_equal
sequence
[
@sequence_step
],
command
,
"commands should be called in sequence
#{
sequence
}
"
...
...
@@ -752,12 +814,14 @@ def test_after_bundle_callback
generator
([
destination_root
],
template:
path
).
stub
(
:open
,
check_open
,
template
)
do
generator
.
stub
(
:bundle_command
,
ensure_bundler_first
)
do
generator
.
stub
(
:run
,
ensure_bundler_first
)
do
quietly
{
generator
.
invoke_all
}
generator
.
stub
(
:rails_command
,
ensure_bundler_first
)
do
quietly
{
generator
.
invoke_all
}
end
end
end
end
assert_equal
4
,
@sequence_step
assert_equal
5
,
@sequence_step
end
def
test_system_tests_directory_generated
...
...
railties/test/generators/plugin_generator_test.rb
浏览文件 @
63f0c048
...
...
@@ -230,7 +230,7 @@ def test_template_from_dir_pwd
end
def
test_ensure_that_tests_work
run_generator
run_generator
[
destination_root
,
"--skip-active-storage"
]
FileUtils
.
cd
destination_root
quietly
{
system
"bundle install"
}
assert_match
(
/1 runs, 1 assertions, 0 failures, 0 errors/
,
`bin/test 2>&1`
)
...
...
@@ -240,8 +240,7 @@ def test_ensure_that_tests_works_in_full_mode
run_generator
[
destination_root
,
"--full"
,
"--skip_active_record"
]
FileUtils
.
cd
destination_root
quietly
{
system
"bundle install"
}
# FIXME: Active Storage will provoke a test error without ActiveRecord (fix by allowing to skip active storage)
assert_match
(
/1 runs, 0 assertions, 0 failures, 1 errors/
,
`bundle exec rake test 2>&1`
)
assert_match
(
/1 runs, 1 assertions, 0 failures, 0 errors/
,
`bundle exec rake test 2>&1`
)
end
def
test_ensure_that_migration_tasks_work_with_mountable_option
...
...
railties/test/generators/plugin_test_runner_test.rb
浏览文件 @
63f0c048
...
...
@@ -7,7 +7,7 @@ class PluginTestRunnerTest < ActiveSupport::TestCase
def
setup
@destination_root
=
Dir
.
mktmpdir
(
"bukkits"
)
Dir
.
chdir
(
@destination_root
)
{
`bundle exec rails plugin new bukkits --skip-bundle`
}
Dir
.
chdir
(
@destination_root
)
{
`bundle exec rails plugin new bukkits --skip-bundle
--skip-active-storage
`
}
plugin_file
"test/dummy/db/schema.rb"
,
""
end
...
...
railties/test/generators/scaffold_controller_generator_test.rb
浏览文件 @
63f0c048
...
...
@@ -207,6 +207,7 @@ def test_controller_tests_pass_by_default_inside_mountable_engine
Dir
.
chdir
(
engine_path
)
do
quietly
{
`bin/rails g controller dashboard foo`
}
quietly
{
`bin/rails db:migrate RAILS_ENV=test`
}
assert_match
(
/2 runs, 2 assertions, 0 failures, 0 errors/
,
`bin/rails test 2>&1`
)
end
end
...
...
@@ -218,6 +219,7 @@ def test_controller_tests_pass_by_default_inside_full_engine
Dir
.
chdir
(
engine_path
)
do
quietly
{
`bin/rails g controller dashboard foo`
}
quietly
{
`bin/rails db:migrate RAILS_ENV=test`
}
assert_match
(
/2 runs, 2 assertions, 0 failures, 0 errors/
,
`bin/rails test 2>&1`
)
end
end
...
...
railties/test/generators/shared_generator_tests.rb
浏览文件 @
63f0c048
...
...
@@ -63,7 +63,7 @@ def test_name_raises_an_error_if_name_already_used_constant
end
def
test_shebang_is_added_to_rails_file
run_generator
[
destination_root
,
"--ruby"
,
"foo/bar/baz"
,
"--full"
]
run_generator
[
destination_root
,
"--ruby"
,
"foo/bar/baz"
,
"--full"
,
"--skip-active-storage"
]
assert_file
"bin/rails"
,
/#!foo\/bar\/baz/
end
...
...
@@ -129,13 +129,26 @@ def test_skip_keeps
end
def
test_default_frameworks_are_required_when_others_are_removed
run_generator
[
destination_root
,
"--skip-active-record"
,
"--skip-action-mailer"
,
"--skip-action-cable"
,
"--skip-sprockets"
]
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']rails["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']active_model\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']active_job\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']action_controller\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']action_view\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/require\s+["']active_storage\/engine["']/
run_generator
[
destination_root
,
"--skip-active-record"
,
"--skip-active-storage"
,
"--skip-action-mailer"
,
"--skip-action-cable"
,
"--skip-sprockets"
]
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']rails["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']active_model\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']active_job\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^# require\s+["']active_record\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^# require\s+["']active_storage\/engine["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']action_controller\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^# require\s+["']action_mailer\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']action_view\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^# require\s+["']action_cable\/engine["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^# require\s+["']sprockets\/railtie["']/
assert_file
"
#{
application_path
}
/config/application.rb"
,
/^require\s+["']rails\/test_unit\/railtie["']/
end
def
test_generator_without_skips
...
...
@@ -189,6 +202,97 @@ def test_generator_if_skip_active_record_is_given
end
end
def
test_generator_for_active_storage
run_generator
assert_file
"
#{
application_path
}
/app/assets/javascripts/application.js"
do
|
content
|
assert_match
(
/^\/\/= require activestorage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/development.rb"
do
|
content
|
assert_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/production.rb"
do
|
content
|
assert_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/test.rb"
do
|
content
|
assert_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/storage.yml"
assert_directory
"
#{
application_path
}
/db/migrate"
assert_directory
"
#{
application_path
}
/storage"
assert_directory
"
#{
application_path
}
/tmp/storage"
assert_file
".gitignore"
do
|
content
|
assert_match
(
/\/storage\//
,
content
)
end
end
def
test_generator_if_skip_active_storage_is_given
run_generator
[
destination_root
,
"--skip-active-storage"
]
assert_file
"
#{
application_path
}
/config/application.rb"
,
/#\s+require\s+["']active_storage\/engine["']/
assert_file
"
#{
application_path
}
/app/assets/javascripts/application.js"
do
|
content
|
assert_no_match
(
/^\/\/= require activestorage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_no_file
"
#{
application_path
}
/config/storage.yml"
assert_no_directory
"
#{
application_path
}
/db/migrate"
assert_no_directory
"
#{
application_path
}
/storage"
assert_no_directory
"
#{
application_path
}
/tmp/storage"
assert_file
".gitignore"
do
|
content
|
assert_no_match
(
/\/storage\//
,
content
)
end
end
def
test_generator_does_not_generate_active_storage_contents_if_skip_active_record_is_given
run_generator
[
destination_root
,
"--skip-active-record"
]
assert_file
"
#{
application_path
}
/config/application.rb"
,
/#\s+require\s+["']active_storage\/engine["']/
assert_file
"
#{
application_path
}
/app/assets/javascripts/application.js"
do
|
content
|
assert_no_match
(
/^\/\/= require activestorage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/development.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/production.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_file
"
#{
application_path
}
/config/environments/test.rb"
do
|
content
|
assert_no_match
(
/config\.active_storage/
,
content
)
end
assert_no_file
"
#{
application_path
}
/config/storage.yml"
assert_no_directory
"
#{
application_path
}
/db/migrate"
assert_no_directory
"
#{
application_path
}
/storage"
assert_no_directory
"
#{
application_path
}
/tmp/storage"
assert_file
".gitignore"
do
|
content
|
assert_no_match
(
/\/storage\//
,
content
)
end
end
def
test_generator_if_skip_action_mailer_is_given
run_generator
[
destination_root
,
"--skip-action-mailer"
]
assert_file
"
#{
application_path
}
/config/application.rb"
,
/#\s+require\s+["']action_mailer\/railtie["']/
...
...
railties/test/generators/test_runner_in_engine_test.rb
浏览文件 @
63f0c048
...
...
@@ -7,7 +7,7 @@ class TestRunnerInEngineTest < ActiveSupport::TestCase
def
setup
@destination_root
=
Dir
.
mktmpdir
(
"bukkits"
)
Dir
.
chdir
(
@destination_root
)
{
`bundle exec rails plugin new bukkits --full --skip-bundle`
}
Dir
.
chdir
(
@destination_root
)
{
`bundle exec rails plugin new bukkits --full --skip-bundle
--skip-active-storage
`
}
plugin_file
"test/dummy/db/schema.rb"
,
""
end
...
...
railties/test/isolation/abstract_unit.rb
浏览文件 @
63f0c048
...
...
@@ -153,6 +153,7 @@ def build_app(options = {})
def
teardown_app
ENV
[
"RAILS_ENV"
]
=
@prev_rails_env
if
@prev_rails_env
FileUtils
.
rm_rf
(
tmp_path
)
end
# Make a very basic app, without creating the whole directory structure.
...
...
railties/test/railties/engine_test.rb
浏览文件 @
63f0c048
...
...
@@ -32,6 +32,11 @@ def boot_rails
require
"
#{
app_path
}
/config/environment"
end
def
migrations
migration_root
=
File
.
expand_path
(
ActiveRecord
::
Migrator
.
migrations_paths
.
first
,
app_path
)
ActiveRecord
::
Migrator
.
migrations
(
migration_root
)
end
test
"serving sprocket's assets"
do
@plugin
.
write
"app/assets/javascripts/engine.js.erb"
,
"<%= :alert %>();"
add_to_env_config
"development"
,
"config.assets.digest = false"
...
...
@@ -82,31 +87,30 @@ def up
end
RUBY
add_to_config
"ActiveRecord::Base.timestamped_migrations = false"
boot_rails
Dir
.
chdir
(
app_path
)
do
output
=
`bundle exec rake bukkits:install:migrations`
assert
File
.
exist?
(
"
#{
app_path
}
/db/migrate/2_create_users.bukkits.rb"
)
assert
File
.
exist?
(
"
#{
app_path
}
/db/migrate/3_add_last_name_to_users.bukkits.rb"
)
assert_match
(
/Copied migration 2_create_users\.bukkits\.rb from bukkits/
,
output
)
assert_match
(
/Copied migration
3_add_last_name_to
_users\.bukkits\.rb from bukkits/
,
output
)
assert_match
(
/
NOTE: Migration 3_create_sessions\.rb from bukkits has been skipped
/
,
output
)
assert_
equal
3
,
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
[
"CreateUsers"
,
"AddLastNameToUsers"
,
"CreateSessions"
].
each
do
|
migration_name
|
assert
migrations
.
detect
{
|
migration
|
migration
.
name
==
migration_name
}
end
assert_match
(
/Copied migration
\d+_create
_users\.bukkits\.rb from bukkits/
,
output
)
assert_match
(
/
Copied migration \d+_add_last_name_to_users\.bukkits\.rb from bukkits
/
,
output
)
assert_
match
(
/NOTE: Migration \d+_create_sessions\.rb from bukkits has been skipped/
,
output
)
output
=
`bundle exec rake railties:install:migrations`
.
split
(
"
\n
"
)
migrations_count
=
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
assert_
no_match
(
/2_create_users/
,
output
.
join
(
"
\n
"
))
assert_
equal
migrations
.
length
,
migrations_count
bukkits_migration_order
=
output
.
index
(
output
.
detect
{
|
o
|
/NOTE: Migration 3_create_sessions\.rb from bukkits has been skipped/
=~
o
})
assert_not_nil
bukkits_migration_order
,
"Expected migration to be skipped"
migrations_count
=
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
`bundle exec rake railties:install:migrations`
output
=
`bundle exec rake railties:install:migrations`
.
split
(
"
\n
"
)
assert_equal
migrations_count
,
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
assert_no_match
(
/\d+_create_users/
,
output
.
join
(
"
\n
"
))
bukkits_migration_order
=
output
.
index
(
output
.
detect
{
|
o
|
/NOTE: Migration \d+_create_sessions\.rb from bukkits has been skipped/
=~
o
})
assert_not_nil
bukkits_migration_order
,
"Expected migration to be skipped"
end
end
...
...
@@ -173,8 +177,8 @@ class CreateKeys < ActiveRecord::Migration::Current; end
Dir
.
chdir
(
app_path
)
do
output
=
`bundle exec rake railties:install:migrations`
.
split
(
"
\n
"
)
assert_match
(
/Copied migration \d+_create_users\.core_engine\.rb from core_engine/
,
output
.
second
)
assert_match
(
/Copied migration \d+_create_keys\.api_engine\.rb from api_engine/
,
output
.
last
)
assert_match
(
/Copied migration \d+_create_users\.core_engine\.rb from core_engine/
,
output
.
first
)
assert_match
(
/Copied migration \d+_create_keys\.api_engine\.rb from api_engine/
,
output
.
second
)
end
end
...
...
@@ -203,9 +207,12 @@ class AddFirstNameToUsers < ActiveRecord::Migration::Current
Dir
.
chdir
(
@plugin
.
path
)
do
output
=
`bundle exec rake app:bukkits:install:migrations`
assert
File
.
exist?
(
"
#{
app_path
}
/db/migrate/0_add_first_name_to_users.bukkits.rb"
)
assert_match
(
/Copied migration 0_add_first_name_to_users\.bukkits\.rb from bukkits/
,
output
)
assert_equal
1
,
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
migration_with_engine_path
=
migrations
.
detect
{
|
migration
|
migration
.
name
==
"AddFirstNameToUsers"
}
assert
migration_with_engine_path
assert_match
(
/\/db\/migrate\/\d+_add_first_name_to_users\.bukkits\.rb/
,
migration_with_engine_path
.
filename
)
assert_match
(
/Copied migration \d+_add_first_name_to_users\.bukkits\.rb from bukkits/
,
output
)
assert_equal
migrations
.
length
,
Dir
[
"
#{
app_path
}
/db/migrate/*.rb"
].
length
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录