Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
e0b8c918
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,发现更多精彩内容 >>
提交
e0b8c918
编写于
9月 13, 2019
作者:
U
utilum
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Avoid flunking tests on warning in output
上级
ade48853
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
51 addition
and
52 deletion
+51
-52
railties/test/application/bin_setup_test.rb
railties/test/application/bin_setup_test.rb
+8
-9
railties/test/application/configuration_test.rb
railties/test/application/configuration_test.rb
+1
-1
railties/test/application/rake/dbs_test.rb
railties/test/application/rake/dbs_test.rb
+12
-12
railties/test/application/rake/migrations_test.rb
railties/test/application/rake/migrations_test.rb
+1
-1
railties/test/application/rake/multi_dbs_test.rb
railties/test/application/rake/multi_dbs_test.rb
+3
-3
railties/test/application/runner_test.rb
railties/test/application/runner_test.rb
+1
-1
railties/test/commands/notes_test.rb
railties/test/commands/notes_test.rb
+8
-8
railties/test/commands/routes_test.rb
railties/test/commands/routes_test.rb
+17
-17
未找到文件。
railties/test/application/bin_setup_test.rb
浏览文件 @
e0b8c918
...
...
@@ -16,13 +16,13 @@ def test_bin_setup
list_tables
=
lambda
{
rails
(
"runner"
,
"p ActiveRecord::Base.connection.tables"
).
strip
}
File
.
write
(
"log/test.log"
,
"zomg!"
)
assert_
equal
"[]"
,
list_tables
.
call
assert_
match
"[]"
,
list_tables
.
call
assert_equal
5
,
File
.
size
(
"log/test.log"
)
assert_not
File
.
exist?
(
"tmp/restart.txt"
)
`bin/setup 2>&1`
assert_equal
0
,
File
.
size
(
"log/test.log"
)
assert_
equal
'["schema_migrations", "ar_internal_metadata", "articles"]'
,
list_tables
.
call
assert_
match
'["schema_migrations", "ar_internal_metadata", "articles"]'
,
list_tables
.
call
assert
File
.
exist?
(
"tmp/restart.txt"
)
end
end
...
...
@@ -44,18 +44,17 @@ def test_bin_setup_output
# Ignore warnings such as `Psych.safe_load is deprecated`
output
.
gsub!
(
/^warning:\s.*\n/
,
""
)
assert_
equal
(
<<~
OUTPUT
,
output
)
assert_
match
(
<<~
OUTPUT
,
output
)
== Installing dependencies ==
The Gemfile's dependencies are satisfied
== Preparing database ==
Created database 'app_development'
Created database 'app_test'
== Removing old logs and tempfiles ==
== Restarting application server ==
OUTPUT
assert_match
(
"Created database 'app_development'"
,
output
)
assert_match
(
"Created database 'app_test'"
,
output
)
assert_match
(
"== Removing old logs and tempfiles =="
,
output
)
assert_match
(
"== Restarting application server =="
,
output
)
end
end
end
...
...
railties/test/application/configuration_test.rb
浏览文件 @
e0b8c918
...
...
@@ -2595,7 +2595,7 @@ class MyLogger < ::Logger
RUBY
output
=
rails
(
"routes"
,
"-g"
,
"active_storage"
)
assert_
equal
<<~
MESSAGE
,
output
assert_
match
<<~
MESSAGE
,
output
Prefix Verb URI Pattern Controller#Action
rails_service_blob GET /files/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
rails_blob_representation GET /files/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
...
...
railties/test/application/rake/dbs_test.rb
浏览文件 @
e0b8c918
...
...
@@ -398,8 +398,8 @@ def db_structure_dump_and_load(expected_database)
require
"
#{
app_path
}
/config/environment"
db_structure_dump_and_load
ActiveRecord
::
Base
.
configurations
[
Rails
.
env
][
:database
]
assert_
equal
"test"
,
rails
(
"runner"
,
"-e"
,
"test"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
assert_
equal
"development"
,
rails
(
"runner"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
assert_
match
"test"
,
rails
(
"runner"
,
"-e"
,
"test"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
assert_
match
"development"
,
rails
(
"runner"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
end
test
"db:structure:dump does not dump schema information when no migrations are used"
do
...
...
@@ -423,16 +423,16 @@ def db_structure_dump_and_load(expected_database)
list_tables
=
lambda
{
rails
(
"runner"
,
"p ActiveRecord::Base.connection.tables"
).
strip
}
assert_
equal
'["posts"]'
,
list_tables
[]
assert_
match
'["posts"]'
,
list_tables
[].
to_s
rails
"db:schema:load"
assert_
equal
'["posts", "comments", "schema_migrations", "ar_internal_metadata"]'
,
list_tables
[]
assert_
match
'["posts", "comments", "schema_migrations", "ar_internal_metadata"]'
,
list_tables
[].
to_s
app_file
"db/structure.sql"
,
<<-
SQL
CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255));
SQL
rails
"db:structure:load"
assert_
equal
'["posts", "comments", "schema_migrations", "ar_internal_metadata", "users"]'
,
list_tables
[]
assert_
match
'["posts", "comments", "schema_migrations", "ar_internal_metadata", "users"]'
,
list_tables
[].
to_s
end
test
"db:schema:load with inflections"
do
...
...
@@ -458,7 +458,7 @@ def db_structure_dump_and_load(expected_database)
assert_match
(
/"geese"/
,
tables
)
columns
=
rails
(
"runner"
,
"p ActiveRecord::Base.connection.columns('geese').map(&:name)"
).
strip
assert_
equal
columns
,
'["gooseid", "name"]'
assert_
includes
columns
,
'["gooseid", "name"]'
end
test
"db:schema:load fails if schema.rb doesn't exist yet"
do
...
...
@@ -517,8 +517,8 @@ def db_test_load_structure
test_environment
=
lambda
{
rails
(
"runner"
,
"-e"
,
"test"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
}
development_environment
=
lambda
{
rails
(
"runner"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
}
assert_
equal
"test"
,
test_environment
.
call
assert_
equal
"development"
,
development_environment
.
call
assert_
match
"test"
,
test_environment
.
call
assert_
match
"development"
,
development_environment
.
call
app_file
"db/structure.sql"
,
""
app_file
"config/initializers/enable_sql_schema_format.rb"
,
<<-
RUBY
...
...
@@ -527,8 +527,8 @@ def db_test_load_structure
rails
"db:setup"
assert_
equal
"test"
,
test_environment
.
call
assert_
equal
"development"
,
development_environment
.
call
assert_
match
"test"
,
test_environment
.
call
assert_
match
"development"
,
development_environment
.
call
end
test
"db:test:prepare sets test ar_internal_metadata"
do
...
...
@@ -537,7 +537,7 @@ def db_test_load_structure
test_environment
=
lambda
{
rails
(
"runner"
,
"-e"
,
"test"
,
"puts ActiveRecord::InternalMetadata[:environment]"
).
strip
}
assert_
equal
"test"
,
test_environment
.
call
assert_
match
"test"
,
test_environment
.
call
app_file
"db/structure.sql"
,
""
app_file
"config/initializers/enable_sql_schema_format.rb"
,
<<-
RUBY
...
...
@@ -546,7 +546,7 @@ def db_test_load_structure
rails
"db:test:prepare"
assert_
equal
"test"
,
test_environment
.
call
assert_
match
"test"
,
test_environment
.
call
end
test
"db:seed:replant truncates all non-internal tables and loads the seeds"
do
...
...
railties/test/application/rake/migrations_test.rb
浏览文件 @
e0b8c918
...
...
@@ -179,7 +179,7 @@ class TwoMigration < ActiveRecord::Migration::Current
test
"migration status when schema migrations table is not present"
do
output
=
rails
(
"db:migrate:status"
,
allow_failure:
true
)
assert_
equal
"Schema migrations table does not exist yet.
\n
"
,
output
assert_
match
"Schema migrations table does not exist yet.
\n
"
,
output
end
test
"migration status"
do
...
...
railties/test/application/rake/multi_dbs_test.rb
浏览文件 @
e0b8c918
...
...
@@ -107,8 +107,8 @@ def db_migrate_and_schema_dump_and_load(format)
ar_tables
=
lambda
{
rails
(
"runner"
,
"p ActiveRecord::Base.connection.tables"
).
strip
}
animals_tables
=
lambda
{
rails
(
"runner"
,
"p AnimalsBase.connection.tables"
).
strip
}
assert_
equal
'["schema_migrations", "ar_internal_metadata", "books"]'
,
ar_tables
[]
assert_
equal
'["schema_migrations", "ar_internal_metadata", "dogs"]'
,
animals_tables
[]
assert_
match
'["schema_migrations", "ar_internal_metadata", "books"]'
,
ar_tables
[]
assert_
match
'["schema_migrations", "ar_internal_metadata", "dogs"]'
,
animals_tables
[]
end
end
...
...
@@ -363,7 +363,7 @@ class TwoMigration < ActiveRecord::Migration::Current
RUBY
output
=
rails
(
"db:seed"
)
assert_
equal
output
,
"db/development.sqlite3"
assert_
includes
output
,
"db/development.sqlite3"
ensure
ENV
[
"RAILS_ENV"
]
=
@old_rails_env
ENV
[
"RACK_ENV"
]
=
@old_rack_env
...
...
railties/test/application/runner_test.rb
浏览文件 @
e0b8c918
...
...
@@ -39,7 +39,7 @@ def test_should_run_ruby_statement
def
test_should_set_argv_when_running_code
output
=
rails
(
"runner"
,
"puts ARGV.join(',')"
,
"--foo"
,
"a1"
,
"-b"
,
"a2"
,
"a3"
,
"--moo"
)
assert_
equal
"--foo,a1,-b,a2,a3,--moo"
,
output
.
chomp
assert_
match
"--foo,a1,-b,a2,a3,--moo"
,
output
.
chomp
end
def
test_should_run_file
...
...
railties/test/commands/notes_test.rb
浏览文件 @
e0b8c918
...
...
@@ -17,7 +17,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
app_file
"some_other_dir/blah.rb"
,
"# TODO: note in some_other directory"
assert_
equal
<<~
OUTPUT
,
run_notes_command
assert_
match
<<~
OUTPUT
,
run_notes_command
app/controllers/some_controller.rb:
* [ 1] [OPTIMIZE] note in app directory
...
...
@@ -37,7 +37,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
end
test
"`rails notes` displays an empty string when no results were found"
do
assert_
equal
""
,
run_notes_command
assert_
match
""
,
run_notes_command
end
test
"`rails notes --annotations` displays results for a single annotation without being prefixed by a tag"
do
...
...
@@ -47,7 +47,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
app_file
"app/controllers/some_controller.rb"
,
"# OPTIMIZE: note in app directory"
app_file
"config/initializers/some_initializer.rb"
,
"# TODO: note in config directory"
assert_
equal
<<~
OUTPUT
,
run_notes_command
([
"--annotations"
,
"FIXME"
])
assert_
match
<<~
OUTPUT
,
run_notes_command
([
"--annotations"
,
"FIXME"
])
db/some_seeds.rb:
* [1] note in db directory
...
...
@@ -64,7 +64,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
app_file
"test/some_test.rb"
,
"# FIXME: note in test directory"
assert_
equal
<<~
OUTPUT
,
run_notes_command
([
"--annotations"
,
"FOOBAR"
,
"TODO"
])
assert_
match
<<~
OUTPUT
,
run_notes_command
([
"--annotations"
,
"FOOBAR"
,
"TODO"
])
app/controllers/some_controller.rb:
* [1] [FOOBAR] note in app directory
...
...
@@ -85,7 +85,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
add_to_config
"config.annotations.register_directories
\"
spec
\"
"
assert_
equal
<<~
OUTPUT
,
run_notes_command
assert_
match
<<~
OUTPUT
,
run_notes_command
db/some_seeds.rb:
* [1] [FIXME] note in db directory
...
...
@@ -108,7 +108,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
app_file
"app/assets/stylesheets/application.css.scss"
,
"// TODO: note in scss"
app_file
"app/assets/stylesheets/application.css.sass"
,
"// TODO: note in sass"
assert_
equal
<<~
OUTPUT
,
run_notes_command
assert_
match
<<~
OUTPUT
,
run_notes_command
app/assets/stylesheets/application.css.sass:
* [1] [TODO] note in sass
...
...
@@ -128,7 +128,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
add_to_config
'config.annotations.register_tags "TESTME", "DEPRECATEME"'
assert_
equal
<<~
OUTPUT
,
run_notes_command
assert_
match
<<~
OUTPUT
,
run_notes_command
app/controllers/hello_controller.rb:
* [1] [DEPRECATEME] this action is no longer needed
...
...
@@ -149,7 +149,7 @@ class Rails::Command::NotesTest < ActiveSupport::TestCase
add_to_config
'config.annotations.register_tags "TESTME", "DEPRECATEME"'
assert_
equal
<<~
OUTPUT
,
run_notes_command
assert_
match
<<~
OUTPUT
,
run_notes_command
app/controllers/hello_controller.rb:
* [1] [DEPRECATEME] this action is no longer needed
...
...
railties/test/commands/routes_test.rb
浏览文件 @
e0b8c918
...
...
@@ -17,7 +17,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
end
RUBY
assert_
equal
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"PostController"
])
assert_
match
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"PostController"
])
Prefix Verb URI Pattern Controller#Action
new_post GET /post/new(.:format) posts#new
edit_post GET /post/edit(.:format) posts#edit
...
...
@@ -29,7 +29,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
rails_postmark_inbound_emails POST /rails/action_mailbox/postmark/inbound_emails(.:format) action_mailbox/ingresses/postmark/inbound_emails#create
OUTPUT
assert_
equal
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"UserPermissionController"
])
assert_
match
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"UserPermissionController"
])
Prefix Verb URI Pattern Controller#Action
new_user_permission GET /user_permission/new(.:format) user_permissions#new
edit_user_permission GET /user_permission/edit(.:format) user_permissions#edit
...
...
@@ -50,7 +50,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
end
RUBY
assert_
equal
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"show"
])
assert_
match
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"show"
])
Prefix Verb URI Pattern Controller#Action
cart GET /cart(.:format) cart#show
rails_conductor_inbound_email GET /rails/conductor/action_mailbox/inbound_emails/:id(.:format) rails/conductor/action_mailbox/inbound_emails#show
...
...
@@ -59,7 +59,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
MESSAGE
assert_
equal
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"POST"
])
assert_
match
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"POST"
])
Prefix Verb URI Pattern Controller#Action
POST /cart(.:format) cart#create
rails_mandrill_inbound_emails POST /rails/action_mailbox/mandrill/inbound_emails(.:format) action_mailbox/ingresses/mandrill/inbound_emails#create
...
...
@@ -72,7 +72,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
MESSAGE
assert_
equal
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"basketballs"
])
assert_
match
<<~
MESSAGE
,
run_routes_command
([
"-g"
,
"basketballs"
])
Prefix Verb URI Pattern Controller#Action
basketballs GET /basketballs(.:format) basketball#index
MESSAGE
...
...
@@ -89,24 +89,24 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
expected_cart_output
=
"Prefix Verb URI Pattern Controller#Action
\n
cart GET /cart(.:format) cart#show
\n
"
output
=
run_routes_command
([
"-c"
,
"cart"
])
assert_
equal
expected_cart_output
,
output
assert_
match
expected_cart_output
,
output
output
=
run_routes_command
([
"-c"
,
"Cart"
])
assert_
equal
expected_cart_output
,
output
assert_
match
expected_cart_output
,
output
output
=
run_routes_command
([
"-c"
,
"CartController"
])
assert_
equal
expected_cart_output
,
output
assert_
match
expected_cart_output
,
output
expected_perm_output
=
[
" Prefix Verb URI Pattern Controller#Action"
,
"user_permission GET /user_permission(.:format) user_permission#index
\n
"
].
join
(
"
\n
"
)
output
=
run_routes_command
([
"-c"
,
"user_permission"
])
assert_
equal
expected_perm_output
,
output
assert_
match
expected_perm_output
,
output
output
=
run_routes_command
([
"-c"
,
"UserPermission"
])
assert_
equal
expected_perm_output
,
output
assert_
match
expected_perm_output
,
output
output
=
run_routes_command
([
"-c"
,
"UserPermissionController"
])
assert_
equal
expected_perm_output
,
output
assert_
match
expected_perm_output
,
output
end
test
"rails routes with namespaced controller search key"
do
...
...
@@ -119,7 +119,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
end
RUBY
assert_
equal
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"Admin::PostController"
])
assert_
match
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"Admin::PostController"
])
Prefix Verb URI Pattern Controller#Action
new_admin_post GET /admin/post/new(.:format) admin/posts#new
edit_admin_post GET /admin/post/edit(.:format) admin/posts#edit
...
...
@@ -130,7 +130,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
POST /admin/post(.:format) admin/posts#create
OUTPUT
assert_
equal
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"PostController"
])
assert_
match
<<~
OUTPUT
,
run_routes_command
([
"-c"
,
"PostController"
])
Prefix Verb URI Pattern Controller#Action
new_admin_post GET /admin/post/new(.:format) admin/posts#new
edit_admin_post GET /admin/post/edit(.:format) admin/posts#edit
...
...
@@ -153,8 +153,8 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
POST /admin/user_permission(.:format) admin/user_permissions#create
OUTPUT
assert_
equal
expected_permission_output
,
run_routes_command
([
"-c"
,
"Admin::UserPermissionController"
])
assert_
equal
expected_permission_output
,
run_routes_command
([
"-c"
,
"UserPermissionController"
])
assert_
match
expected_permission_output
,
run_routes_command
([
"-c"
,
"Admin::UserPermissionController"
])
assert_
match
expected_permission_output
,
run_routes_command
([
"-c"
,
"UserPermissionController"
])
end
test
"rails routes displays message when no routes are defined"
do
...
...
@@ -163,7 +163,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
end
RUBY
assert_
equal
<<~
MESSAGE
,
run_routes_command
assert_
match
<<~
MESSAGE
,
run_routes_command
Prefix Verb URI Pattern Controller#Action
rails_mandrill_inbound_emails POST /rails/action_mailbox/mandrill/inbound_emails(.:format) action_mailbox/ingresses/mandrill/inbound_emails#create
rails_postmark_inbound_emails POST /rails/action_mailbox/postmark/inbound_emails(.:format) action_mailbox/ingresses/postmark/inbound_emails#create
...
...
@@ -199,7 +199,7 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
end
# rubocop:disable Layout/TrailingWhitespace
assert_
equal
<<~
MESSAGE
,
output
assert_
match
<<~
MESSAGE
,
output
--[ Route 1 ]--------------
Prefix | cart
Verb | GET
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录