modernizes hash syntax in railties

This commit is contained in:
Xavier Noria 2016-08-06 19:38:55 +02:00
parent 5c315a8fa6
commit 477568ee33
8 changed files with 29 additions and 29 deletions

View File

@ -1,11 +1,11 @@
require "rake/testtask" require "rake/testtask"
task :default => :test task default: :test
task :package task :package
desc "Run all unit tests" desc "Run all unit tests"
task :test => "test:isolated" task test: "test:isolated"
namespace :test do namespace :test do
task :isolated do task :isolated do

View File

@ -5,29 +5,29 @@ module Rails
class Task < RDoc::Task class Task < RDoc::Task
RDOC_FILES = { RDOC_FILES = {
"activesupport" => { "activesupport" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/active_support/**/*.rb lib/active_support/**/*.rb
), ),
:exclude => "lib/active_support/vendor/*" exclude: "lib/active_support/vendor/*"
}, },
"activerecord" => { "activerecord" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/active_record/**/*.rb lib/active_record/**/*.rb
) )
}, },
"activemodel" => { "activemodel" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/active_model/**/*.rb lib/active_model/**/*.rb
) )
}, },
"actionpack" => { "actionpack" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/abstract_controller/**/*.rb lib/abstract_controller/**/*.rb
lib/action_controller/**/*.rb lib/action_controller/**/*.rb
@ -36,40 +36,40 @@ module Rails
}, },
"actionview" => { "actionview" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/action_view/**/*.rb lib/action_view/**/*.rb
), ),
:exclude => "lib/action_view/vendor/*" exclude: "lib/action_view/vendor/*"
}, },
"actionmailer" => { "actionmailer" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/action_mailer/**/*.rb lib/action_mailer/**/*.rb
) )
}, },
"activejob" => { "activejob" => {
:include => %w( include: %w(
README.md README.md
lib/active_job/**/*.rb lib/active_job/**/*.rb
) )
}, },
"actioncable" => { "actioncable" => {
:include => %w( include: %w(
README.md README.md
lib/action_cable/**/*.rb lib/action_cable/**/*.rb
) )
}, },
"railties" => { "railties" => {
:include => %w( include: %w(
README.rdoc README.rdoc
lib/**/*.rb lib/**/*.rb
), ),
:exclude => "lib/rails/generators/rails/**/templates/**/*.rb" exclude: "lib/rails/generators/rails/**/templates/**/*.rb"
} }
} }

View File

@ -2,7 +2,7 @@ task "load_app" do
namespace :app do namespace :app do
load APP_RAKEFILE load APP_RAKEFILE
end end
task :environment => "app:environment" task environment: "app:environment"
if !defined?(ENGINE_ROOT) || !ENGINE_ROOT if !defined?(ENGINE_ROOT) || !ENGINE_ROOT
ENGINE_ROOT = find_engine_path(APP_RAKEFILE) ENGINE_ROOT = find_engine_path(APP_RAKEFILE)

View File

@ -21,10 +21,10 @@ namespace :test do
# If used with Active Record, this task runs before the database schema is synchronized. # If used with Active Record, this task runs before the database schema is synchronized.
end end
task :run => %w[test] task run: %w[test]
desc "Run tests quickly, but also reset db" desc "Run tests quickly, but also reset db"
task :db => %w[db:test:prepare test] task db: %w[db:test:prepare test]
["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name| ["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|
task name => "test:prepare" do task name => "test:prepare" do
@ -33,17 +33,17 @@ namespace :test do
end end
end end
task :generators => "test:prepare" do task generators: "test:prepare" do
$: << "test" $: << "test"
Minitest.rake_run(["test/lib/generators"]) Minitest.rake_run(["test/lib/generators"])
end end
task :units => "test:prepare" do task units: "test:prepare" do
$: << "test" $: << "test"
Minitest.rake_run(["test/models", "test/helpers", "test/unit"]) Minitest.rake_run(["test/models", "test/helpers", "test/unit"])
end end
task :functionals => "test:prepare" do task functionals: "test:prepare" do
$: << "test" $: << "test"
Minitest.rake_run(["test/controllers", "test/mailers", "test/functional"]) Minitest.rake_run(["test/controllers", "test/mailers", "test/functional"])
end end

View File

@ -233,7 +233,7 @@ fr:
end end
test "config.i18n.fallbacks.map = { :ca => :'es-ES' } initializes fallbacks with a mapping ca => es-ES" do test "config.i18n.fallbacks.map = { :ca => :'es-ES' } initializes fallbacks with a mapping ca => es-ES" do
I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } I18n::Railtie.config.i18n.fallbacks.map = { ca: :'es-ES' }
load_app load_app
assert_fallbacks ca: [:ca, :"es-ES", :es, :en] assert_fallbacks ca: [:ca, :"es-ES", :es, :en]
end end
@ -245,13 +245,13 @@ fr:
end end
test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping ca => es-ES" do test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping ca => es-ES" do
I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } I18n::Railtie.config.i18n.fallbacks.map = { ca: :'es-ES' }
load_app load_app
assert_fallbacks ca: [:ca, :"es-ES", :es, :en] assert_fallbacks ca: [:ca, :"es-ES", :es, :en]
end end
test "[shortcut] config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] initializes fallbacks with the given arguments" do test "[shortcut] config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] initializes fallbacks with the given arguments" do
I18n::Railtie.config.i18n.fallbacks = [:'en-US', { :ca => :'es-ES' }] I18n::Railtie.config.i18n.fallbacks = [:'en-US', { ca: :'es-ES' }]
load_app load_app
assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en] assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en]
end end

View File

@ -116,7 +116,7 @@ module ApplicationTests
ERB ERB
get "/foo", :utf8 => "" get "/foo", utf8: ""
assert_match(/boooom/, last_response.body) assert_match(/boooom/, last_response.body)
assert_match(/測試テスト시험/, last_response.body) assert_match(/測試テスト시험/, last_response.body)
end end

View File

@ -448,7 +448,7 @@ module ApplicationTests
get "/en/foo" get "/en/foo"
assert_equal "foo", last_response.body assert_equal "foo", last_response.body
assert_equal "/en/foo", Rails.application.routes.url_helpers.foo_path(:locale => "en") assert_equal "/en/foo", Rails.application.routes.url_helpers.foo_path(locale: "en")
app_file "config/routes.rb", <<-RUBY app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do Rails.application.routes.draw do
@ -463,7 +463,7 @@ module ApplicationTests
get "/en/bar" get "/en/bar"
assert_equal "bar", last_response.body assert_equal "bar", last_response.body
assert_equal "/en/bar", Rails.application.routes.url_helpers.foo_path(:locale => "en") assert_equal "/en/bar", Rails.application.routes.url_helpers.foo_path(locale: "en")
end end
test "resource routing with irregular inflection" do test "resource routing with irregular inflection" do

View File

@ -269,7 +269,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
def test_scaffold_with_namespace_on_revoke def test_scaffold_with_namespace_on_revoke
run_generator [ "admin/role", "name:string", "description:string" ] run_generator [ "admin/role", "name:string", "description:string" ]
run_generator [ "admin/role" ], :behavior => :revoke run_generator [ "admin/role" ], behavior: :revoke
# Model # Model
assert_file "app/models/admin.rb" # ( should not be remove ) assert_file "app/models/admin.rb" # ( should not be remove )
@ -310,7 +310,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
end end
File.open(route_path, "wb") { |file| file.write(content) } File.open(route_path, "wb") { |file| file.write(content) }
run_generator ["product_line"], :behavior => :revoke run_generator ["product_line"], behavior: :revoke
assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/ assert_file "config/routes.rb", /\.routes\.draw do\s*\|map\|\s*$/
end end
@ -328,7 +328,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase
File.open(route_path, "wb") { |file| file.write(content) } File.open(route_path, "wb") { |file| file.write(content) }
assert_file "config/routes.rb", /\.routes\.draw do\n resources :product_lines\nend\n\z/ assert_file "config/routes.rb", /\.routes\.draw do\n resources :product_lines\nend\n\z/
run_generator ["product_line"], :behavior => :revoke run_generator ["product_line"], behavior: :revoke
assert_file "config/routes.rb", /\.routes\.draw do\nend\n\z/ assert_file "config/routes.rb", /\.routes\.draw do\nend\n\z/
end end