From 58d69a536cfa067f9b1e963e20162ff4c26dc32c Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Wed, 10 Oct 2012 11:02:32 -0400 Subject: Offer instructions for pg gem when installed via Homebrew --- .../generators/rails/app/templates/config/databases/postgresql.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml index 07223a71c9..22c9194fad 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml @@ -2,7 +2,9 @@ # # Install the pg driver: # gem install pg -# On Mac OS X with macports: +# On OS X with Homebrew: +# gem install pg -- --with-pg-config=/usr/local/bin/pg_config +# On OS X with MacPorts: # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config # On Windows: # gem install pg -- cgit v1.2.3 From e40f515a75a67f49ca70a6ea8f0a7d5d7ae1bfea Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 11 Oct 2012 01:48:37 +0530 Subject: Fixing build failures Build failed with an error "invalid multibyte char (US-ASCII)" in these files. Apparently, some UTF-8 char disguised as whitespace causes this. Thanks @rafaelfranca --- railties/lib/rails/generators/erb.rb | 4 ++-- .../lib/rails/generators/erb/controller/controller_generator.rb | 6 +++--- railties/lib/rails/generators/erb/mailer/mailer_generator.rb | 6 +++--- railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb | 6 +++--- railties/lib/rails/generators/js/assets/assets_generator.rb | 4 ++-- railties/lib/rails/generators/rails/helper/helper_generator.rb | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/erb.rb b/railties/lib/rails/generators/erb.rb index aa824499ac..73e986ee7f 100644 --- a/railties/lib/rails/generators/erb.rb +++ b/railties/lib/rails/generators/erb.rb @@ -1,7 +1,7 @@ require 'rails/generators/named_base' -module Erb # :nodoc: - module Generators # :nodoc: +module Erb # :nodoc: + module Generators # :nodoc: class Base < Rails::Generators::NamedBase #:nodoc: protected diff --git a/railties/lib/rails/generators/erb/controller/controller_generator.rb b/railties/lib/rails/generators/erb/controller/controller_generator.rb index e14cb09ff7..89e6361f93 100644 --- a/railties/lib/rails/generators/erb/controller/controller_generator.rb +++ b/railties/lib/rails/generators/erb/controller/controller_generator.rb @@ -1,8 +1,8 @@ require 'rails/generators/erb' -module Erb # :nodoc: - module Generators # :nodoc: - class ControllerGenerator < Base # :nodoc: +module Erb # :nodoc: + module Generators # :nodoc: + class ControllerGenerator < Base # :nodoc: argument :actions, :type => :array, :default => [], :banner => "action action" def copy_view_files diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 89de2a4be5..7bcac30dde 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -1,8 +1,8 @@ require 'rails/generators/erb/controller/controller_generator' -module Erb # :nodoc: - module Generators # :nodoc: - class MailerGenerator < ControllerGenerator # :nodoc: +module Erb # :nodoc: + module Generators # :nodoc: + class MailerGenerator < ControllerGenerator # :nodoc: protected def format diff --git a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb index 19fc53aeee..54ed648df4 100644 --- a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb @@ -1,9 +1,9 @@ require 'rails/generators/erb' require 'rails/generators/resource_helpers' -module Erb # :nodoc: - module Generators # :nodoc: - class ScaffoldGenerator < Base # :nodoc: +module Erb # :nodoc: + module Generators # :nodoc: + class ScaffoldGenerator < Base # :nodoc: include Rails::Generators::ResourceHelpers argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" diff --git a/railties/lib/rails/generators/js/assets/assets_generator.rb b/railties/lib/rails/generators/js/assets/assets_generator.rb index 82f40de009..1e925b2cd2 100644 --- a/railties/lib/rails/generators/js/assets/assets_generator.rb +++ b/railties/lib/rails/generators/js/assets/assets_generator.rb @@ -1,8 +1,8 @@ require "rails/generators/named_base" module Js # :nodoc: - module Generators # :nodoc: - class AssetsGenerator < Rails::Generators::NamedBase # :nodoc: + module Generators # :nodoc: + class AssetsGenerator < Rails::Generators::NamedBase # :nodoc: source_root File.expand_path("../templates", __FILE__) def copy_javascript diff --git a/railties/lib/rails/generators/rails/helper/helper_generator.rb b/railties/lib/rails/generators/rails/helper/helper_generator.rb index 0975ab3903..a1f83ac3e4 100644 --- a/railties/lib/rails/generators/rails/helper/helper_generator.rb +++ b/railties/lib/rails/generators/rails/helper/helper_generator.rb @@ -1,6 +1,6 @@ module Rails module Generators - class HelperGenerator < NamedBase # :nodoc: + class HelperGenerator < NamedBase # :nodoc: check_class_collision :suffix => "Helper" def create_helper_files -- cgit v1.2.3 From fdc4c841c45c7f33c8fac23a6923dd6952b2d753 Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Thu, 11 Oct 2012 11:48:13 +0530 Subject: No need to test for rack-cache present in Gemfile as it's removed here 1fc795468525d8622cdca474a54c8310a514aa46 --- railties/test/generators/app_generator_test.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 91575a38b6..6b6a6b6099 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -302,11 +302,6 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_file "Gemfile", /# gem 'debugger'/ end - def test_inclusion_of_rack_cache - run_generator - assert_file "Gemfile", /gem 'rack-cache'/ - end - def test_template_from_dir_pwd FileUtils.cd(Rails.root) assert_match(/It works from file!/, run_generator([destination_root, "-m", "lib/template.rb"])) -- cgit v1.2.3 From 79db8db415ffb86ab23e4d319c1035d926160d2d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Oct 2012 07:49:35 -0700 Subject: Immediately run queued jobs in tests. Otherwise you have to explicitly drain the queue to actually deliver your emails. --- .../generators/rails/app/templates/config/environments/test.rb.tt | 4 ++-- railties/test/application/queue_test.rb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index 202fc98adf..fe2820f64e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -34,6 +34,6 @@ # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # Use the testing queue. - config.queue = ActiveSupport::TestQueue + # Use the synchronous queue to run jobs immediately. + config.queue = ActiveSupport::SynchronousQueue end diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index e67c6cc371..5e7b938cbb 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -17,10 +17,10 @@ module ApplicationTests @app_const ||= Class.new(Rails::Application) end - test "the queue is a TestQueue in test mode" do + test "the queue is a SynchronousQueue in test mode" do app("test") - assert_kind_of ActiveSupport::TestQueue, Rails.application.queue[:default] - assert_kind_of ActiveSupport::TestQueue, Rails.queue[:default] + assert_kind_of ActiveSupport::SynchronousQueue, Rails.application.queue[:default] + assert_kind_of ActiveSupport::SynchronousQueue, Rails.queue[:default] end test "the queue is a SynchronousQueue in development mode" do -- cgit v1.2.3 From 06129c0e3fb0f20df6c0aa1509b151c51e71d180 Mon Sep 17 00:00:00 2001 From: "Brent J. Nordquist" Date: Mon, 8 Oct 2012 06:41:31 -0500 Subject: Add .rake to `rake notes` and `rake notes:custom` --- railties/CHANGELOG.md | 2 ++ railties/lib/rails/source_annotation_extractor.rb | 14 +++++++------- railties/test/application/rake/notes_test.rb | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index c9fa541db8..2ecdfdcb22 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 4.0.0 (unreleased) ## +* Add `.rake` to list of file extensions included by `rake notes` and `rake notes:custom`. *Brent J. Nordquist* + * New test locations `test/models`, `test/helpers`, `test/controllers`, and `test/mailers`. Corresponding rake tasks added as well. *Mike Moore* diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 31e34023c0..3474b02af4 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -32,9 +32,9 @@ class SourceAnnotationExtractor end # Prints all annotations with tag +tag+ under the root directories +app+, +config+, +lib+, - # +script+, and +test+ (recursively). Only filenames with extension - # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, and - # +.coffee+ are taken into account. The +options+ hash is passed to each + # +script+, and +test+ (recursively). Filenames with extension + # +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, +.scss+, +.js+, + # +.coffee+, and +.rake+ are taken into account. The +options+ hash is passed to each # annotation's +to_s+. # # This class method is the single entry point for the rake tasks. @@ -56,9 +56,9 @@ class SourceAnnotationExtractor end # Returns a hash that maps filenames under +dir+ (recursively) to arrays - # with their annotations. Only files with annotations are included, and only - # those with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, - # +.scss+, +.js+, and +.coffee+ + # with their annotations. Only files with annotations are included. Files + # with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, + # +.scss+, +.js+, +.coffee+, and +.rake+ # are taken into account. def find_in(dir) results = {} @@ -68,7 +68,7 @@ class SourceAnnotationExtractor if File.directory?(item) results.update(find_in(item)) - elsif item =~ /\.(builder|rb|coffee)$/ + elsif item =~ /\.(builder|rb|coffee|rake)$/ results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/)) elsif item =~ /\.(css|scss|js)$/ results.update(extract_annotations_from(item, /\/\/\s*(#{tag}):?\s*(.*)$/)) diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb index 27de75b63b..7a227098ba 100644 --- a/railties/test/application/rake/notes_test.rb +++ b/railties/test/application/rake/notes_test.rb @@ -25,6 +25,7 @@ module ApplicationTests app_file "app/assets/stylesheets/application.css", "// TODO: note in css" app_file "app/assets/stylesheets/application.css.scss", "// TODO: note in scss" app_file "app/controllers/application_controller.rb", 1000.times.map { "" }.join("\n") << "# TODO: note in ruby" + app_file "lib/tasks/task.rake", "# TODO: note in rake" boot_rails require 'rake' @@ -45,8 +46,9 @@ module ApplicationTests assert_match(/note in js/, output) assert_match(/note in css/, output) assert_match(/note in scss/, output) + assert_match(/note in rake/, output) - assert_equal 8, lines.size + assert_equal 9, lines.size lines.each do |line| assert_equal 4, line[0].size -- cgit v1.2.3 From 08f57bfb8f46e9f521b7d324fc47fe00d93f42bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 12 Oct 2012 14:42:26 -0300 Subject: Move the TestQueue tests to the proper file --- railties/test/application/queue_test.rb | 47 --------------------------------- 1 file changed, 47 deletions(-) (limited to 'railties') diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index 5e7b938cbb..58173afc69 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -69,45 +69,6 @@ module ApplicationTests refute job.ran_in_different_thread?, "Expected job to run in the same thread" end - class IdentifiableJob - def initialize(id) - @id = id - end - - def ==(other) - other.same_id?(@id) - end - - def same_id?(other_id) - other_id == @id - end - - def run - end - end - - test "in test mode, the queue can be observed" do - app("test") - - jobs = (1..10).map do |id| - IdentifiableJob.new(id) - end - - jobs.each do |job| - Rails.queue.push job - end - - assert_equal jobs, Rails.queue.jobs - end - - test "in test mode, adding an unmarshallable job will raise an exception" do - app("test") - anonymous_class_instance = Struct.new(:run).new - assert_raises TypeError do - Rails.queue.push anonymous_class_instance - end - end - test "attempting to marshal a queue will raise an exception" do app("test") assert_raises TypeError do @@ -115,14 +76,6 @@ module ApplicationTests end end - test "attempting to add a reference to itself to the queue will raise an exception" do - app("test") - job = {reference: Rails.queue} - assert_raises TypeError do - Rails.queue.push job - end - end - def setup_custom_queue add_to_env_config "production", <<-RUBY require "my_queue" -- cgit v1.2.3 From a284b145dab008b097eb1046fd86aa9e6469fc25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 12 Oct 2012 14:43:01 -0300 Subject: ActiveSupport::SynchronousQueue doesn't have the drain method. Now we are using teh SynchronousQueue in the test environment instead of the TestQueue --- railties/test/application/queue_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index 58173afc69..7d8f665024 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -58,12 +58,12 @@ module ApplicationTests refute job.ran_in_different_thread?, "Expected job to run in the same thread" end - test "in test mode, explicitly draining the queue will process it in the same thread" do + test "in test mode, an enqueued job will be processed in the same thread" do app("test") - Rails.queue.push ThreadTrackingJob.new - job = Rails.queue.jobs.last - Rails.queue.drain + job = ThreadTrackingJob.new + Rails.queue.push job + sleep 0.1 assert job.ran?, "Expected job to be run" refute job.ran_in_different_thread?, "Expected job to run in the same thread" -- cgit v1.2.3 From 20385ec6b16f1bb8158a3d087d1298a8f23a19e4 Mon Sep 17 00:00:00 2001 From: schneems Date: Tue, 9 Oct 2012 11:24:36 -1000 Subject: Prompt to run rake when accidentally typed rails Developers from all levels will accidentally run rake tasks using the `rails` keyword when they meant to use `rake`. Often times beginners struggle with the difference between the tools. The most common example would be `$ rails db:migrate` Rather than telling the developer simply that they did not use a valid rails command, we can see if it was a valid rake command first. If it is a valid rake command we can auto execute it giving the user a period of time to cancel if that isn't what they intended. Here is what `rake db:migrate` would look like if you cancel the command: ```sh $ rails db:migrate Assuming you meant: $ rake db:migrate press any key to cancel in 3 seconds > command terminated ... ``` Here is what it looks like if you don't cancel the command: ```sh $ rails db:migrate Assuming you meant: $ rake db:migrate press any key to cancel in 3 seconds > Running: $ rake db:migrate == Foo: migrating ============================================================ == Foo: migrated (0.0000s) =================================================== ``` --- railties/lib/rails/commands.rb | 55 ++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 9c5dc8f188..b0fae13192 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -9,6 +9,30 @@ aliases = { "r" => "runner" } +help_message = <<-EOT +Usage: rails COMMAND [ARGS] + +The most common rails commands are: + generate Generate new code (short-cut alias: "g") + console Start the Rails console (short-cut alias: "c") + server Start the Rails server (short-cut alias: "s") + dbconsole Start a console for the database specified in config/database.yml + (short-cut alias: "db") + new Create a new Rails application. "rails new my_app" creates a + new application called MyApp in "./my_app" + +In addition to those, there are: + application Generate the Rails application code + destroy Undo code generated with "generate" (short-cut alias: "d") + benchmarker See how fast a piece of code runs + profiler Get profile information from a piece of code + plugin new Generates skeleton for developing a Rails plugin + runner Run a piece of code in the application environment (short-cut alias: "r") + +All commands can be run with -h (or --help) for more information. +EOT + + command = ARGV.shift command = aliases[command] || command @@ -81,29 +105,14 @@ when '--version', '-v' ARGV.unshift '--version' require 'rails/commands/application' -else - puts "Error: Command not recognized" unless %w(-h --help).include?(command) - puts <<-EOT -Usage: rails COMMAND [ARGS] - -The most common rails commands are: - generate Generate new code (short-cut alias: "g") - console Start the Rails console (short-cut alias: "c") - server Start the Rails server (short-cut alias: "s") - dbconsole Start a console for the database specified in config/database.yml - (short-cut alias: "db") - new Create a new Rails application. "rails new my_app" creates a - new application called MyApp in "./my_app" +when '-h', '--help' + puts help_message -In addition to those, there are: - application Generate the Rails application code - destroy Undo code generated with "generate" (short-cut alias: "d") - benchmarker See how fast a piece of code runs - profiler Get profile information from a piece of code - plugin new Generates skeleton for developing a Rails plugin - runner Run a piece of code in the application environment (short-cut alias: "r") - -All commands can be run with -h (or --help) for more information. - EOT +else + puts "Error: Command '#{command}' not recognized" + if %x{rake #{command} --dry-run 2>&1 } && $?.success? + puts "Did you mean: `$ rake #{command}` ?\n\n" + end + puts help_message exit(1) end -- cgit v1.2.3 From 775829869e23666e114edbe8d6d3ff08d5d71025 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Oct 2012 18:01:04 -0700 Subject: Remove the queue container. Premature consolidation. Set up and maintain queues in the classes that use them instead. --- railties/lib/rails/application.rb | 6 +----- railties/test/application/initializers/frameworks_test.rb | 5 ++--- railties/test/application/queue_test.rb | 12 ++++++------ 3 files changed, 9 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index b30e6ff615..0a717c76b3 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -198,11 +198,7 @@ module Rails end def queue #:nodoc: - @queue ||= ActiveSupport::QueueContainer.new(build_queue) - end - - def build_queue #:nodoc: - config.queue.new + @queue ||= config.queue || ActiveSupport::Queue.new end def to_app #:nodoc: diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb index 81f6096be8..528bec58ef 100644 --- a/railties/test/application/initializers/frameworks_test.rb +++ b/railties/test/application/initializers/frameworks_test.rb @@ -52,14 +52,13 @@ module ApplicationTests test "uses the default queue for ActionMailer" do require "#{app_path}/config/environment" - assert_kind_of ActiveSupport::QueueContainer, ActionMailer::Base.queue + assert_kind_of ActiveSupport::Queue, ActionMailer::Base.queue end test "allows me to configure queue for ActionMailer" do app_file "config/environments/development.rb", <<-RUBY AppTemplate::Application.configure do - Rails.queue[:mailer] = ActiveSupport::TestQueue.new - config.action_mailer.queue = Rails.queue[:mailer] + config.action_mailer.queue = ActiveSupport::TestQueue.new end RUBY diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index 7d8f665024..080678f2d5 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -19,14 +19,14 @@ module ApplicationTests test "the queue is a SynchronousQueue in test mode" do app("test") - assert_kind_of ActiveSupport::SynchronousQueue, Rails.application.queue[:default] - assert_kind_of ActiveSupport::SynchronousQueue, Rails.queue[:default] + assert_kind_of ActiveSupport::SynchronousQueue, Rails.application.queue + assert_kind_of ActiveSupport::SynchronousQueue, Rails.queue end test "the queue is a SynchronousQueue in development mode" do app("development") - assert_kind_of ActiveSupport::SynchronousQueue, Rails.application.queue[:default] - assert_kind_of ActiveSupport::SynchronousQueue, Rails.queue[:default] + assert_kind_of ActiveSupport::SynchronousQueue, Rails.application.queue + assert_kind_of ActiveSupport::SynchronousQueue, Rails.queue end class ThreadTrackingJob @@ -79,7 +79,7 @@ module ApplicationTests def setup_custom_queue add_to_env_config "production", <<-RUBY require "my_queue" - config.queue = MyQueue + config.queue = MyQueue.new RUBY app_file "lib/my_queue.rb", <<-RUBY @@ -96,7 +96,7 @@ module ApplicationTests test "a custom queue implementation can be provided" do setup_custom_queue - assert_kind_of MyQueue, Rails.queue[:default] + assert_kind_of MyQueue, Rails.queue job = Struct.new(:id, :ran) do def run -- cgit v1.2.3 From 1dc2ea8f3dfc1cce1958bd661c641ed345adf910 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Oct 2012 20:44:32 -0700 Subject: Tighten up asset precompile tests --- railties/test/application/asset_debugging_test.rb | 5 ++--- railties/test/application/assets_test.rb | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index ebafc7d670..a7b3ae1e9a 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -36,9 +36,8 @@ module ApplicationTests test "assets are concatenated when debug is off and compile is off either if debug_assets param is provided" do # config.assets.debug and config.assets.compile are false for production environment ENV["RAILS_ENV"] = "production" - capture(:stdout) do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } - end + output = Dir.chdir(app_path){ `bundle exec rake assets:precompile --trace 2>&1` } + assert $?.success?, output require "#{app_path}/config/environment" class ::PostsController < ActionController::Base ; end diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index be97855e1a..8a76b2f614 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -18,7 +18,7 @@ module ApplicationTests def precompile!(env = nil) quietly do - precompile_task = "bundle exec rake assets:precompile #{env} 2>&1" + precompile_task = "bundle exec rake assets:precompile #{env} --trace 2>&1" output = Dir.chdir(app_path) { %x[ #{precompile_task} ] } assert $?.success?, output output -- cgit v1.2.3 From c8fe0d58bcc7deb49711606566c854bf0ed7f107 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 Oct 2012 20:45:54 -0700 Subject: Backpedal from class-oriented config.queue. Set an actual queue instance. --- railties/CHANGELOG.md | 4 ++-- railties/lib/rails/application/configuration.rb | 2 +- railties/lib/rails/application/finisher.rb | 4 ++-- .../rails/app/templates/config/environments/production.rb.tt | 2 +- .../generators/rails/app/templates/config/environments/test.rb.tt | 2 +- railties/test/application/configuration_test.rb | 8 -------- railties/test/application/queue_test.rb | 6 +++--- 7 files changed, 10 insertions(+), 18 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 2ecdfdcb22..ba9b24c6c6 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -81,9 +81,9 @@ * Load all environments available in `config.paths["config/environments"]`. *Piotr Sarnacki* -* Add `config.queue_consumer` to allow the default consumer to be configurable. *Carlos Antonio da Silva* +* Add `config.queue_consumer` to change the job queue consumer from the default `ActiveSupport::ThreadedQueueConsumer`. *Carlos Antonio da Silva* -* Add Rails.queue as an interface with a default implementation that consumes jobs in a separate thread. *Yehuda Katz* +* Add `Rails.queue` for processing jobs in the background. *Yehuda Katz* * Remove Rack::SSL in favour of ActionDispatch::SSL. *Rafael Mendonça França* diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index a7a35c2685..2bcdb3d502 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -43,7 +43,7 @@ module Rails @exceptions_app = nil @autoflush_log = true @log_formatter = ActiveSupport::Logger::SimpleFormatter.new - @queue = ActiveSupport::SynchronousQueue + @queue = ActiveSupport::SynchronousQueue.new @queue_consumer = ActiveSupport::ThreadedQueueConsumer @eager_load = nil diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index d2a402aa51..26fca503a0 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -97,8 +97,8 @@ module Rails end initializer :activate_queue_consumer do |app| - if config.queue == ActiveSupport::Queue - app.queue_consumer = config.queue_consumer.start(app.queue, {logger: Rails.logger}) + if config.queue.class == ActiveSupport::Queue + app.queue_consumer = config.queue_consumer.start at_exit { app.queue_consumer.shutdown } end end diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index 74457b0efd..8aaaba628c 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -88,5 +88,5 @@ # Default the production mode queue to an synchronous queue. You will probably # want to replace this with an out-of-process queueing solution. - # config.queue = ActiveSupport::SynchronousQueue + # config.queue = ActiveSupport::SynchronousQueue.new end diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index fe2820f64e..a5ef0cd9cd 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -35,5 +35,5 @@ config.active_support.deprecation = :stderr # Use the synchronous queue to run jobs immediately. - config.queue = ActiveSupport::SynchronousQueue + config.queue = ActiveSupport::SynchronousQueue.new end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 07d47dc67b..3691c5e3d5 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -56,14 +56,6 @@ module ApplicationTests assert_match "ActiveRecord::PendingMigrationError", last_response.body end - test "multiple queue construction is possible" do - require 'rails' - require "#{app_path}/config/environment" - mail_queue = Rails.application.build_queue - image_processing_queue = Rails.application.build_queue - assert_not_equal mail_queue, image_processing_queue - end - test "Rails.groups returns available groups" do require "rails" diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index 080678f2d5..b4c9a31185 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -113,12 +113,12 @@ module ApplicationTests test "a custom consumer implementation can be provided" do add_to_env_config "production", <<-RUBY require "my_queue_consumer" - config.queue = ActiveSupport::Queue - config.queue_consumer = MyQueueConsumer + config.queue = ActiveSupport::Queue.new + config.queue_consumer = MyQueueConsumer.new RUBY app_file "lib/my_queue_consumer.rb", <<-RUBY - class MyQueueConsumer < ActiveSupport::ThreadedQueueConsumer + class MyQueueConsumer attr_reader :started def start -- cgit v1.2.3 From 1fd89260566eae1b8d3531bf83233eb18c27ab3d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 13 Oct 2012 09:54:34 -0700 Subject: Test that a Rails.queue consumer is automatically started in production --- railties/lib/rails/application/configuration.rb | 2 +- railties/lib/rails/application/finisher.rb | 3 ++- railties/test/application/queue_test.rb | 12 +++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 2bcdb3d502..9b89d7094c 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -44,7 +44,7 @@ module Rails @autoflush_log = true @log_formatter = ActiveSupport::Logger::SimpleFormatter.new @queue = ActiveSupport::SynchronousQueue.new - @queue_consumer = ActiveSupport::ThreadedQueueConsumer + @queue_consumer = nil @eager_load = nil @assets = ActiveSupport::OrderedOptions.new diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 26fca503a0..4a15a36ba9 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -98,7 +98,8 @@ module Rails initializer :activate_queue_consumer do |app| if config.queue.class == ActiveSupport::Queue - app.queue_consumer = config.queue_consumer.start + app.queue_consumer = config.queue_consumer || config.queue.consumer + app.queue_consumer.start at_exit { app.queue_consumer.shutdown } end end diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index b4c9a31185..b0b3cf18e9 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -69,6 +69,17 @@ module ApplicationTests refute job.ran_in_different_thread?, "Expected job to run in the same thread" end + test "in production, automatically spawn a queue consumer in a background thread" do + add_to_env_config "production", <<-RUBY + config.queue = ActiveSupport::Queue.new + RUBY + + app("production") + + assert_nil Rails.application.config.queue_consumer + assert_kind_of ActiveSupport::ThreadedQueueConsumer, Rails.application.queue_consumer + end + test "attempting to marshal a queue will raise an exception" do app("test") assert_raises TypeError do @@ -123,7 +134,6 @@ module ApplicationTests def start @started = true - self end end RUBY -- cgit v1.2.3 From 5ad7f8ab418f0c760dbb584f7c78d94ce32e9ee3 Mon Sep 17 00:00:00 2001 From: Robin Dupret Date: Sun, 14 Oct 2012 12:03:39 +0200 Subject: Use Ruby 1.9 Hash syntax in railties --- railties/lib/rails.rb | 2 +- railties/lib/rails/application.rb | 10 ++-- railties/lib/rails/application/bootstrap.rb | 14 +++--- railties/lib/rails/application/configuration.rb | 6 +-- railties/lib/rails/application/finisher.rb | 4 +- railties/lib/rails/application/routes_reloader.rb | 2 +- railties/lib/rails/commands/destroy.rb | 2 +- railties/lib/rails/commands/generate.rb | 2 +- railties/lib/rails/commands/runner.rb | 2 +- railties/lib/rails/commands/server.rb | 14 +++--- railties/lib/rails/commands/update.rb | 2 +- railties/lib/rails/engine.rb | 16 +++--- railties/lib/rails/engine/configuration.rb | 30 +++++------ railties/lib/rails/generators.rb | 58 +++++++++++----------- railties/lib/rails/generators/actions.rb | 44 ++++++++-------- railties/lib/rails/generators/base.rb | 16 +++--- .../erb/controller/controller_generator.rb | 2 +- .../generators/erb/scaffold/scaffold_generator.rb | 2 +- .../lib/rails/generators/generated_attribute.rb | 8 +-- railties/lib/rails/generators/named_base.rb | 8 +-- .../rails/generators/rails/app/app_generator.rb | 8 +-- .../generators/rails/assets/assets_generator.rb | 8 +-- .../rails/controller/controller_generator.rb | 4 +- .../rails/generator/generator_generator.rb | 6 +-- .../generators/rails/helper/helper_generator.rb | 2 +- .../integration_test/integration_test_generator.rb | 2 +- .../rails/migration/migration_generator.rb | 4 +- .../generators/rails/model/model_generator.rb | 4 +- .../rails/observer/observer_generator.rb | 2 +- .../performance_test/performance_test_generator.rb | 2 +- .../rails/plugin_new/plugin_new_generator.rb | 32 ++++++------ .../views/layouts/%name%/application.html.erb.tt | 2 +- .../rails/resource/resource_generator.rb | 8 +-- .../rails/scaffold/scaffold_generator.rb | 6 +-- .../scaffold_controller_generator.rb | 12 ++--- .../rails/generators/rails/task/task_generator.rb | 2 +- .../rails/generators/rails/task/templates/task.rb | 2 +- railties/lib/rails/generators/resource_helpers.rb | 2 +- railties/lib/rails/generators/test_case.rb | 4 +- .../test_unit/controller/controller_generator.rb | 4 +- .../test_unit/helper/helper_generator.rb | 2 +- .../test_unit/integration/integration_generator.rb | 2 +- .../test_unit/mailer/mailer_generator.rb | 4 +- .../generators/test_unit/model/model_generator.rb | 6 +-- .../test_unit/observer/observer_generator.rb | 2 +- .../test_unit/performance/performance_generator.rb | 2 +- .../performance/templates/performance_test.rb | 4 +- .../test_unit/plugin/plugin_generator.rb | 2 +- .../test_unit/scaffold/scaffold_generator.rb | 4 +- railties/lib/rails/info_controller.rb | 2 +- railties/lib/rails/paths.rb | 6 +-- railties/lib/rails/railtie.rb | 2 +- railties/lib/rails/railtie/configurable.rb | 2 +- railties/lib/rails/railtie/configuration.rb | 8 +-- railties/lib/rails/tasks/annotations.rake | 2 +- railties/lib/rails/tasks/framework.rake | 10 ++-- railties/lib/rails/tasks/middleware.rake | 2 +- railties/lib/rails/tasks/misc.rake | 4 +- railties/lib/rails/tasks/routes.rake | 2 +- railties/lib/rails/tasks/tmp.rake | 4 +- railties/lib/rails/test_unit/railtie.rb | 4 +- railties/lib/rails/test_unit/testing.rake | 28 +++++------ railties/test/application/asset_debugging_test.rb | 4 +- railties/test/application/assets_test.rb | 6 +-- railties/test/application/configuration_test.rb | 30 +++++------ railties/test/application/generators_test.rb | 30 +++++------ .../test/application/initializers/i18n_test.rb | 14 +++--- .../application/initializers/notifications_test.rb | 2 +- railties/test/application/loading_test.rb | 28 +++++------ railties/test/application/middleware/cache_test.rb | 24 ++++----- .../test/application/middleware/session_test.rb | 2 +- railties/test/application/middleware_test.rb | 8 +-- railties/test/application/rake_test.rb | 10 ++-- railties/test/application/routing_test.rb | 28 +++++------ railties/test/application/url_generation_test.rb | 6 +-- railties/test/commands/console_test.rb | 8 +-- .../fixtures/lib/plugin_builders/spec_builder.rb | 2 +- railties/test/generators/actions_test.rb | 36 +++++++------- railties/test/generators/app_generator_test.rb | 6 +-- railties/test/generators/model_generator_test.rb | 6 +-- .../test/generators/namespaced_generators_test.rb | 6 +-- railties/test/generators/orm_test.rb | 4 +- .../test/generators/plugin_new_generator_test.rb | 2 +- .../test/generators/resource_generator_test.rb | 2 +- .../test/generators/scaffold_generator_test.rb | 2 +- railties/test/generators/shared_generator_tests.rb | 14 +++--- railties/test/generators_test.rb | 8 +-- railties/test/initializable_test.rb | 18 +++---- railties/test/isolation/abstract_unit.rb | 8 +-- railties/test/paths_test.rb | 28 +++++------ railties/test/rails_info_controller_test.rb | 6 +-- railties/test/railties/engine_test.rb | 42 ++++++++-------- railties/test/railties/generators_test.rb | 2 +- railties/test/railties/mounted_engine_test.rb | 38 +++++++------- 94 files changed, 447 insertions(+), 447 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index d7e22cc839..dd51a6fb01 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -106,7 +106,7 @@ module Rails # * The environment variable RAILS_GROUPS; # * The optional envs given as argument and the hash with group dependencies; # - # groups :assets => [:development, :test] + # groups assets: [:development, :test] # # # Returns # # => [:default, :development, :assets] for Rails.env == "development" diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 0a717c76b3..eff5bbbdd6 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -71,7 +71,7 @@ module Rails attr_reader :reloaders attr_writer :queue - delegate :default_url_options, :default_url_options=, :to => :routes + delegate :default_url_options, :default_url_options=, to: :routes def initialize super @@ -106,7 +106,7 @@ module Rails def key_generator # number of iterations selected based on consultation with the google security # team. Details at https://github.com/rails/rails/pull/6952#issuecomment-7661220 - @key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, :iterations=>1000) + @key_generator ||= ActiveSupport::KeyGenerator.new(config.secret_token, iterations: 1000) end # Stores some of the Rails initial environment parameters which @@ -296,9 +296,9 @@ module Rails if rack_cache == true rack_cache = { - :metastore => "rails:/", - :entitystore => "rails:/", - :verbose => false + metastore: "rails:/", + entitystore: "rails:/", + verbose: false } end diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index a1bc95550b..62d57c0cc6 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -7,13 +7,13 @@ module Rails module Bootstrap include Initializable - initializer :load_environment_hook, :group => :all do end + initializer :load_environment_hook, group: :all do end - initializer :load_active_support, :group => :all do + initializer :load_active_support, group: :all do require "active_support/all" unless config.active_support.bare end - initializer :set_eager_load, :group => :all do + initializer :set_eager_load, group: :all do if config.eager_load.nil? warn <<-INFO config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly: @@ -28,7 +28,7 @@ INFO end # Initialize the logger early in the stack in case we need to log some deprecation. - initializer :initialize_logger, :group => :all do + initializer :initialize_logger, group: :all do Rails.logger ||= config.logger || begin path = config.paths["log"].first unless File.exist? File.dirname path @@ -56,7 +56,7 @@ INFO end # Initialize cache early in the stack so railties can make use of it. - initializer :initialize_cache, :group => :all do + initializer :initialize_cache, group: :all do unless Rails.cache Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store) @@ -67,11 +67,11 @@ INFO end # Sets the dependency loading mechanism. - initializer :initialize_dependency_mechanism, :group => :all do + initializer :initialize_dependency_mechanism, group: :all do ActiveSupport::Dependencies.mechanism = config.cache_classes ? :require : :load end - initializer :bootstrap_hook, :group => :all do |app| + initializer :bootstrap_hook, group: :all do |app| ActiveSupport.run_load_hooks(:before_initialize, app) end end diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 9b89d7094c..c3e75a643b 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -79,10 +79,10 @@ module Rails def paths @paths ||= begin paths = super - paths.add "config/database", :with => "config/database.yml" - paths.add "config/environment", :with => "config/environment.rb" + paths.add "config/database", with: "config/database.yml" + paths.add "config/environment", with: "config/environment.rb" paths.add "lib/templates" - paths.add "log", :with => "log/#{Rails.env}.log" + paths.add "log", with: "log/#{Rails.env}.log" paths.add "public" paths.add "public/javascripts" paths.add "public/stylesheets" diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 4a15a36ba9..c520f7af9d 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -72,7 +72,7 @@ module Rails # Set app reload just after the finisher hook to ensure # paths added in the hook are still loaded. - initializer :set_clear_dependencies_hook, :group => :all do + initializer :set_clear_dependencies_hook, group: :all do callback = lambda do ActiveSupport::DescendantsTracker.clear ActiveSupport::Dependencies.clear @@ -83,7 +83,7 @@ module Rails self.reloaders << reloader # We need to set a to_prepare callback regardless of the reloader result, i.e. # models should be reloaded if any of the reloaders (i18n, routes) were updated. - ActionDispatch::Reloader.to_prepare(:prepend => true){ reloader.execute } + ActionDispatch::Reloader.to_prepare(prepend: true){ reloader.execute } else ActionDispatch::Reloader.to_cleanup(&callback) end diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 6f9a200aa9..737977adf9 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -4,7 +4,7 @@ module Rails class Application class RoutesReloader attr_reader :route_sets, :paths - delegate :execute_if_updated, :execute, :updated?, :to => :updater + delegate :execute_if_updated, :execute, :updated?, to: :updater def initialize @paths = [] diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 9023c61bf2..5479da86a0 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -6,4 +6,4 @@ if [nil, "-h", "--help"].include?(ARGV.first) end name = ARGV.shift -Rails::Generators.invoke name, ARGV, :behavior => :revoke, :destination_root => Rails.root +Rails::Generators.invoke name, ARGV, behavior: :revoke, destination_root: Rails.root diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 9f13cb0513..351c59c645 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -8,4 +8,4 @@ end name = ARGV.shift root = defined?(ENGINE_ROOT) ? ENGINE_ROOT : Rails.root -Rails::Generators.invoke name, ARGV, :behavior => :invoke, :destination_root => root +Rails::Generators.invoke name, ARGV, behavior: :invoke, destination_root: root diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index a672258aa6..0cc672e01c 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -1,7 +1,7 @@ require 'optparse' require 'rbconfig' -options = { :environment => (ENV['RAILS_ENV'] || "development").dup } +options = { environment: (ENV['RAILS_ENV'] || "development").dup } code_or_file = nil if ARGV.first.nil? diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index a684129353..80fdc06cd2 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -105,13 +105,13 @@ module Rails def default_options super.merge({ - :Port => 3000, - :DoNotReverseLookup => true, - :environment => (ENV['RAILS_ENV'] || "development").dup, - :daemonize => false, - :debugger => false, - :pid => File.expand_path("tmp/pids/server.pid"), - :config => File.expand_path("config.ru") + Port: 3000, + DoNotReverseLookup: true, + environment: (ENV['RAILS_ENV'] || "development").dup, + daemonize: false, + debugger: false, + pid: File.expand_path("tmp/pids/server.pid"), + config: File.expand_path("config.ru") }) end end diff --git a/railties/lib/rails/commands/update.rb b/railties/lib/rails/commands/update.rb index 85a81cddf0..59fae5c337 100644 --- a/railties/lib/rails/commands/update.rb +++ b/railties/lib/rails/commands/update.rb @@ -6,4 +6,4 @@ if ARGV.size == 0 end name = ARGV.shift -Rails::Generators.invoke name, ARGV, :behavior => :skip +Rails::Generators.invoke name, ARGV, behavior: :skip diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 7afb599910..2c2bb1c714 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -251,7 +251,7 @@ module Rails # # # config/routes.rb # MyApplication::Application.routes.draw do - # mount MyEngine::Engine => "/my_engine", :as => "my_engine" + # mount MyEngine::Engine => "/my_engine", as: "my_engine" # get "/foo" => "foo#index" # end # @@ -368,7 +368,7 @@ module Rails def isolate_namespace(mod) engine_name(generate_railtie_name(mod)) - self.routes.default_scope = { :module => ActiveSupport::Inflector.underscore(mod.name) } + self.routes.default_scope = { module: ActiveSupport::Inflector.underscore(mod.name) } self.isolated = true unless mod.respond_to?(:railtie_namespace) @@ -407,8 +407,8 @@ module Rails end end - delegate :middleware, :root, :paths, :to => :config - delegate :engine_name, :isolated?, :to => "self.class" + delegate :middleware, :root, :paths, to: :config + delegate :engine_name, :isolated?, to: "self.class" def initialize @_all_autoload_paths = nil @@ -536,7 +536,7 @@ module Rails end # Add configured load paths to ruby load paths and remove duplicates. - initializer :set_load_path, :before => :bootstrap_hook do + initializer :set_load_path, before: :bootstrap_hook do _all_load_paths.reverse_each do |path| $LOAD_PATH.unshift(path) if File.directory?(path) end @@ -548,7 +548,7 @@ module Rails # # This needs to be an initializer, since it needs to run once # per engine and get the engine as a block parameter - initializer :set_autoload_paths, :before => :bootstrap_hook do |app| + initializer :set_autoload_paths, before: :bootstrap_hook do |app| ActiveSupport::Dependencies.autoload_paths.unshift(*_all_autoload_paths) ActiveSupport::Dependencies.autoload_once_paths.unshift(*_all_autoload_once_paths) @@ -581,13 +581,13 @@ module Rails end end - initializer :load_environment_config, :before => :load_environment_hook, :group => :all do + initializer :load_environment_config, before: :load_environment_hook, group: :all do paths["config/environments"].existent.each do |environment| require environment end end - initializer :append_assets_path, :group => :all do |app| + initializer :append_assets_path, group: :all do |app| app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 6b18b1e249..22e885a3a6 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -20,7 +20,7 @@ module Rails # Holds generators configuration: # # config.generators do |g| - # g.orm :data_mapper, :migration => true + # g.orm :data_mapper, migration: true # g.template_engine :haml # g.test_framework :rspec # end @@ -38,26 +38,26 @@ module Rails def paths @paths ||= begin paths = Rails::Paths::Root.new(@root) - paths.add "app", :eager_load => true, :glob => "*" - paths.add "app/assets", :glob => "*" - paths.add "app/controllers", :eager_load => true - paths.add "app/helpers", :eager_load => true - paths.add "app/models", :eager_load => true - paths.add "app/mailers", :eager_load => true + paths.add "app", eager_load: true, glob: "*" + paths.add "app/assets", glob: "*" + paths.add "app/controllers", eager_load: true + paths.add "app/helpers", eager_load: true + paths.add "app/models", eager_load: true + paths.add "app/mailers", eager_load: true paths.add "app/views" - paths.add "lib", :load_path => true - paths.add "lib/assets", :glob => "*" - paths.add "lib/tasks", :glob => "**/*.rake" + paths.add "lib", load_path: true + paths.add "lib/assets", glob: "*" + paths.add "lib/tasks", glob: "**/*.rake" paths.add "config" - paths.add "config/environments", :glob => "#{Rails.env}.rb" - paths.add "config/initializers", :glob => "**/*.rb" - paths.add "config/locales", :glob => "*.{rb,yml}" + paths.add "config/environments", glob: "#{Rails.env}.rb" + paths.add "config/initializers", glob: "**/*.rb" + paths.add "config/locales", glob: "*.{rb,yml}" paths.add "config/routes.rb" paths.add "db" paths.add "db/migrate" paths.add "db/seeds.rb" - paths.add "vendor", :load_path => true - paths.add "vendor/assets", :glob => "*" + paths.add "vendor", load_path: true + paths.add "vendor/assets", glob: "*" paths end end diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index a8c0626a41..367f9288b8 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -23,41 +23,41 @@ module Rails mattr_accessor :namespace DEFAULT_ALIASES = { - :rails => { - :actions => '-a', - :orm => '-o', - :javascripts => '-j', - :javascript_engine => '-je', - :resource_controller => '-c', - :scaffold_controller => '-c', - :stylesheets => '-y', - :stylesheet_engine => '-se', - :template_engine => '-e', - :test_framework => '-t' + rails: { + actions: '-a', + orm: '-o', + javascripts: '-j', + javascript_engine: '-je', + resource_controller: '-c', + scaffold_controller: '-c', + stylesheets: '-y', + stylesheet_engine: '-se', + template_engine: '-e', + test_framework: '-t' }, - :test_unit => { - :fixture_replacement => '-r', + test_unit: { + fixture_replacement: '-r', } } DEFAULT_OPTIONS = { - :rails => { - :assets => true, - :force_plural => false, - :helper => true, - :integration_tool => nil, - :javascripts => true, - :javascript_engine => :js, - :orm => false, - :performance_tool => nil, - :resource_controller => :controller, - :resource_route => true, - :scaffold_controller => :scaffold_controller, - :stylesheets => true, - :stylesheet_engine => :css, - :test_framework => false, - :template_engine => :erb + rails: { + assets: true, + force_plural: false, + helper: true, + integration_tool: nil, + javascripts: true, + javascript_engine: :js, + orm: false, + performance_tool: nil, + resource_controller: :controller, + resource_route: true, + scaffold_controller: :scaffold_controller, + stylesheets: true, + stylesheet_engine: :css, + test_framework: false, + template_engine: :erb } } diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index c41acc7841..5c4e81431c 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -7,9 +7,9 @@ module Rails # Adds an entry into Gemfile for the supplied gem. # - # gem "rspec", :group => :test - # gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/" - # gem "rails", "3.0", :git => "git://github.com/rails/rails" + # gem "rspec", group: :test + # gem "technoweenie-restful-authentication", lib: "restful-authentication", source: "http://gems.github.com/" + # gem "rails", "3.0", git: "git://github.com/rails/rails" def gem(*args) options = args.extract_options! name, version = args @@ -33,7 +33,7 @@ module Rails str = "gem #{parts.join(", ")}" str = " " + str if @in_group str = "\n" + str - append_file "Gemfile", str, :verbose => false + append_file "Gemfile", str, verbose: false end end @@ -47,13 +47,13 @@ module Rails log :gemfile, "group #{name}" in_root do - append_file "Gemfile", "\ngroup #{name} do", :force => true + append_file "Gemfile", "\ngroup #{name} do", force: true @in_group = true instance_eval(&block) @in_group = false - append_file "Gemfile", "\nend\n", :force => true + append_file "Gemfile", "\nend\n", force: true end end @@ -64,7 +64,7 @@ module Rails log :source, source in_root do - prepend_file "Gemfile", "source #{source.inspect}\n", :verbose => false + prepend_file "Gemfile", "source #{source.inspect}\n", verbose: false end end @@ -77,7 +77,7 @@ module Rails # "config.autoload_paths += %W(#{config.root}/extras)" # end # - # environment(nil, :env => "development") do + # environment(nil, env: "development") do # "config.active_record.observers = :cacher" # end def environment(data=nil, options={}, &block) @@ -87,10 +87,10 @@ module Rails in_root do if options[:env].nil? - inject_into_file 'config/application.rb', "\n #{data}", :after => sentinel, :verbose => false + inject_into_file 'config/application.rb', "\n #{data}", after: sentinel, verbose: false else Array(options[:env]).each do |env| - inject_into_file "config/environments/#{env}.rb", "\n #{data}", :after => env_file_sentinel, :verbose => false + inject_into_file "config/environments/#{env}.rb", "\n #{data}", after: env_file_sentinel, verbose: false end end end @@ -100,8 +100,8 @@ module Rails # Run a command in git. # # git :init - # git :add => "this.file that.rb" - # git :add => "onefile.rb", :rm => "badfile.cxx" + # git add: "this.file that.rb" + # git add: "onefile.rb", rm: "badfile.cxx" def git(commands={}) if commands.is_a?(Symbol) run "git #{commands}" @@ -123,7 +123,7 @@ module Rails # vendor("foreign.rb", "# Foreign code is fun") def vendor(filename, data=nil, &block) log :vendor, filename - create_file("vendor/#{filename}", data, :verbose => false, &block) + create_file("vendor/#{filename}", data, verbose: false, &block) end # Create a new file in the lib/ directory. Code can be specified @@ -136,7 +136,7 @@ module Rails # lib("foreign.rb", "# Foreign code is fun") def lib(filename, data=nil, &block) log :lib, filename - create_file("lib/#{filename}", data, :verbose => false, &block) + create_file("lib/#{filename}", data, verbose: false, &block) end # Create a new Rakefile with the provided code (either in a block or a string). @@ -156,7 +156,7 @@ module Rails # rakefile('seed.rake', 'puts "Planting seeds"') def rakefile(filename, data=nil, &block) log :rakefile, filename - create_file("lib/tasks/#{filename}", data, :verbose => false, &block) + create_file("lib/tasks/#{filename}", data, verbose: false, &block) end # Create a new initializer with the provided code (either in a block or a string). @@ -174,7 +174,7 @@ module Rails # initializer("api.rb", "API_KEY = '123456'") def initializer(filename, data=nil, &block) log :initializer, filename - create_file("config/initializers/#{filename}", data, :verbose => false, &block) + create_file("config/initializers/#{filename}", data, verbose: false, &block) end # Generate something using a generator from Rails or a plugin. @@ -186,19 +186,19 @@ module Rails log :generate, what argument = args.map {|arg| arg.to_s }.flatten.join(" ") - in_root { run_ruby_script("script/rails generate #{what} #{argument}", :verbose => false) } + in_root { run_ruby_script("script/rails generate #{what} #{argument}", verbose: false) } end # Runs the supplied rake task # # rake("db:migrate") - # rake("db:migrate", :env => "production") - # rake("gems:install", :sudo => true) + # rake("db:migrate", env: "production") + # rake("gems:install", sudo: true) def rake(command, options={}) log :rake, command env = options[:env] || ENV["RAILS_ENV"] || 'development' sudo = options[:sudo] && RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ ? 'sudo ' : '' - in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", :verbose => false) } + in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", verbose: false) } end # Just run the capify command in root @@ -206,7 +206,7 @@ module Rails # capify! def capify! log :capify, "" - in_root { run("#{extify(:capify)} .", :verbose => false) } + in_root { run("#{extify(:capify)} .", verbose: false) } end # Make an entry in Rails routing file config/routes.rb @@ -217,7 +217,7 @@ module Rails sentinel = /\.routes\.draw do\s*$/ in_root do - inject_into_file 'config/routes.rb', "\n #{routing_code}", { :after => sentinel, :verbose => false } + inject_into_file 'config/routes.rb', "\n #{routing_code}", { after: sentinel, verbose: false } end end diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 5ca1bfc20f..7e938fab47 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -61,7 +61,7 @@ module Rails # # module Rails::Generators # class ControllerGenerator < Base - # hook_for :test_framework, :aliases => "-t" + # hook_for :test_framework, aliases: "-t" # end # end # @@ -102,7 +102,7 @@ module Rails # :as option: # # class AwesomeGenerator < Rails::Generators::Base - # hook_for :test_framework, :as => :controller + # hook_for :test_framework, as: :controller # end # # And now it will lookup at: @@ -113,7 +113,7 @@ module Rails # need to provide the :base value: # # class AwesomeGenerator < Rails::Generators::Base - # hook_for :test_framework, :in => :rails, :as => :controller + # hook_for :test_framework, in: :rails, as: :controller # end # # And the lookup is exactly the same as previously: @@ -137,7 +137,7 @@ module Rails # developers might want to have webrat available on controller generator. # This can be achieved as: # - # Rails::Generators::ControllerGenerator.hook_for :webrat, :type => :boolean + # Rails::Generators::ControllerGenerator.hook_for :webrat, type: :boolean # # Then, if you want webrat to be invoked, just supply: # @@ -171,9 +171,9 @@ module Rails defaults = if options[:type] == :boolean { } elsif [true, false].include?(default_value_for_option(name, options)) - { :banner => "" } + { banner: "" } else - { :desc => "#{name.to_s.humanize} to be invoked", :banner => "NAME" } + { desc: "#{name.to_s.humanize} to be invoked", banner: "NAME" } end unless class_options.key?(name) @@ -343,8 +343,8 @@ module Rails # Small macro to add ruby as an option to the generator with proper # default value plus an instance helper method called shebang. def self.add_shebang_option! - class_option :ruby, :type => :string, :aliases => "-r", :default => Thor::Util.ruby_command, - :desc => "Path to the Ruby binary of your choice", :banner => "PATH" + class_option :ruby, type: :string, aliases: "-r", default: Thor::Util.ruby_command, + desc: "Path to the Ruby binary of your choice", banner: "PATH" no_tasks { define_method :shebang do diff --git a/railties/lib/rails/generators/erb/controller/controller_generator.rb b/railties/lib/rails/generators/erb/controller/controller_generator.rb index 89e6361f93..5f06734ab8 100644 --- a/railties/lib/rails/generators/erb/controller/controller_generator.rb +++ b/railties/lib/rails/generators/erb/controller/controller_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/erb' module Erb # :nodoc: module Generators # :nodoc: class ControllerGenerator < Base # :nodoc: - argument :actions, :type => :array, :default => [], :banner => "action action" + argument :actions, type: :array, default: [], banner: "action action" def copy_view_files base_path = File.join("app/views", class_path, file_name) diff --git a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb index 54ed648df4..bacbc2d280 100644 --- a/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb @@ -6,7 +6,7 @@ module Erb # :nodoc: class ScaffoldGenerator < Base # :nodoc: include Rails::Generators::ResourceHelpers - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" + argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_root_folder empty_directory File.join("app/views", controller_file_path) diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index 231813f774..d8a4f15b4b 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -23,7 +23,7 @@ module Rails type = type.to_sym if type if type && reference?(type) - references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { :unique => true } : true + references_index = UNIQ_INDEX_OPTIONS.include?(has_index) ? { unique: true } : true attr_options[:index] = references_index end @@ -41,11 +41,11 @@ module Rails def parse_type_and_options(type) case type when /(string|text|binary|integer)\{(\d+)\}/ - return $1, :limit => $2.to_i + return $1, limit: $2.to_i when /decimal\{(\d+)[,.-](\d+)\}/ - return :decimal, :precision => $1.to_i, :scale => $2.to_i + return :decimal, precision: $1.to_i, scale: $2.to_i when /(references|belongs_to)\{polymorphic\}/ - return $1, :polymorphic => true + return $1, polymorphic: true else return type, {} end diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index b61a5fc69d..84f8f76838 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -5,9 +5,9 @@ require 'rails/generators/generated_attribute' module Rails module Generators class NamedBase < Base - argument :name, :type => :string - class_option :skip_namespace, :type => :boolean, :default => false, - :desc => "Skip namespace (affects only isolated applications)" + argument :name, type: :string + class_option :skip_namespace, type: :boolean, default: false, + desc: "Skip namespace (affects only isolated applications)" def initialize(args, *options) #:nodoc: @inside_template = nil @@ -169,7 +169,7 @@ module Rails # # ==== Examples # - # check_class_collision :suffix => "Observer" + # check_class_collision suffix: "Observer" # # If the generator is invoked with class name Admin, it will check for # the presence of "AdminObserver". diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 67e7c4d54f..18637451ac 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -96,7 +96,7 @@ module Rails end def public_directory - directory "public", "public", :recursive => false + directory "public", "public", recursive: false if options[:skip_index_html] remove_file "public/index.html" remove_file 'app/assets/images/rails.png' @@ -108,7 +108,7 @@ module Rails directory "script" do |content| "#{shebang}\n" + content end - chmod "script", 0755, :verbose => false + chmod "script", 0755, verbose: false end def test @@ -152,8 +152,8 @@ module Rails add_shared_options_for "application" # Add bin/rails options - class_option :version, :type => :boolean, :aliases => "-v", :group => :rails, - :desc => "Show Rails version number and quit" + class_option :version, type: :boolean, aliases: "-v", group: :rails, + desc: "Show Rails version number and quit" def initialize(*args) raise Error, "Options should be given after the application name. For details run: rails --help" if args[0].blank? diff --git a/railties/lib/rails/generators/rails/assets/assets_generator.rb b/railties/lib/rails/generators/rails/assets/assets_generator.rb index e4f07bba2e..6f4b86e708 100644 --- a/railties/lib/rails/generators/rails/assets/assets_generator.rb +++ b/railties/lib/rails/generators/rails/assets/assets_generator.rb @@ -1,11 +1,11 @@ module Rails module Generators class AssetsGenerator < NamedBase # :nodoc: - class_option :javascripts, :type => :boolean, :desc => "Generate JavaScripts" - class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets" + class_option :javascripts, type: :boolean, desc: "Generate JavaScripts" + class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets" - class_option :javascript_engine, :desc => "Engine for JavaScripts" - class_option :stylesheet_engine, :desc => "Engine for Stylesheets" + class_option :javascript_engine, desc: "Engine for JavaScripts" + class_option :stylesheet_engine, desc: "Engine for Stylesheets" protected diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index 1482fc28d4..bae54623c6 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -1,8 +1,8 @@ module Rails module Generators class ControllerGenerator < NamedBase # :nodoc: - argument :actions, :type => :array, :default => [], :banner => "action action" - check_class_collision :suffix => "Controller" + argument :actions, type: :array, default: [], banner: "action action" + check_class_collision suffix: "Controller" def create_controller_files template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb") diff --git a/railties/lib/rails/generators/rails/generator/generator_generator.rb b/railties/lib/rails/generators/rails/generator/generator_generator.rb index 8a0fdbf2fb..9a7a516b5b 100644 --- a/railties/lib/rails/generators/rails/generator/generator_generator.rb +++ b/railties/lib/rails/generators/rails/generator/generator_generator.rb @@ -1,10 +1,10 @@ module Rails module Generators class GeneratorGenerator < NamedBase # :nodoc: - check_class_collision :suffix => "Generator" + check_class_collision suffix: "Generator" - class_option :namespace, :type => :boolean, :default => true, - :desc => "Namespace generator under lib/generators/name" + class_option :namespace, type: :boolean, default: true, + desc: "Namespace generator under lib/generators/name" def create_generator_files directory '.', generator_dir diff --git a/railties/lib/rails/generators/rails/helper/helper_generator.rb b/railties/lib/rails/generators/rails/helper/helper_generator.rb index a1f83ac3e4..5ff38e4111 100644 --- a/railties/lib/rails/generators/rails/helper/helper_generator.rb +++ b/railties/lib/rails/generators/rails/helper/helper_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class HelperGenerator < NamedBase # :nodoc: - check_class_collision :suffix => "Helper" + check_class_collision suffix: "Helper" def create_helper_files template 'helper.rb', File.join('app/helpers', class_path, "#{file_name}_helper.rb") diff --git a/railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb b/railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb index 9258ae1ee8..70770ddcb8 100644 --- a/railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb +++ b/railties/lib/rails/generators/rails/integration_test/integration_test_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class IntegrationTestGenerator < NamedBase # :nodoc: - hook_for :integration_tool, :as => :integration + hook_for :integration_tool, as: :integration end end end diff --git a/railties/lib/rails/generators/rails/migration/migration_generator.rb b/railties/lib/rails/generators/rails/migration/migration_generator.rb index 2e1b6a27d8..965c42db36 100644 --- a/railties/lib/rails/generators/rails/migration/migration_generator.rb +++ b/railties/lib/rails/generators/rails/migration/migration_generator.rb @@ -1,8 +1,8 @@ module Rails module Generators class MigrationGenerator < NamedBase # :nodoc: - argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]" - hook_for :orm, :required => true + argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]" + hook_for :orm, required: true end end end diff --git a/railties/lib/rails/generators/rails/model/model_generator.rb b/railties/lib/rails/generators/rails/model/model_generator.rb index af1617fadf..ea3d69d7c9 100644 --- a/railties/lib/rails/generators/rails/model/model_generator.rb +++ b/railties/lib/rails/generators/rails/model/model_generator.rb @@ -1,8 +1,8 @@ module Rails module Generators class ModelGenerator < NamedBase # :nodoc: - argument :attributes, :type => :array, :default => [], :banner => "field[:type][:index] field[:type][:index]" - hook_for :orm, :required => true + argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]" + hook_for :orm, required: true end end end diff --git a/railties/lib/rails/generators/rails/observer/observer_generator.rb b/railties/lib/rails/generators/rails/observer/observer_generator.rb index a11085eb0f..7a4d701ac6 100644 --- a/railties/lib/rails/generators/rails/observer/observer_generator.rb +++ b/railties/lib/rails/generators/rails/observer/observer_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class ObserverGenerator < NamedBase # :nodoc: - hook_for :orm, :required => true + hook_for :orm, required: true end end end diff --git a/railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb b/railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb index 83771c3dd7..56cd562f3d 100644 --- a/railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb +++ b/railties/lib/rails/generators/rails/performance_test/performance_test_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class PerformanceTestGenerator < NamedBase # :nodoc: - hook_for :performance_tool, :as => :performance + hook_for :performance_tool, as: :performance end end end diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 42e0246f76..4a0bcc35a4 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -68,7 +68,7 @@ module Rails append_file "Rakefile", <<-EOF #{rakefile_test_tasks} -task :default => :test +task default: :test EOF if full? template "test/integration/navigation_test.rb" @@ -89,10 +89,10 @@ task :default => :test end def test_dummy_config - template "rails/boot.rb", "#{dummy_path}/config/boot.rb", :force => true - template "rails/application.rb", "#{dummy_path}/config/application.rb", :force => true + template "rails/boot.rb", "#{dummy_path}/config/boot.rb", force: true + template "rails/application.rb", "#{dummy_path}/config/application.rb", force: true if mountable? - template "rails/routes.rb", "#{dummy_path}/config/routes.rb", :force => true + template "rails/routes.rb", "#{dummy_path}/config/routes.rb", force: true end end @@ -135,10 +135,10 @@ task :default => :test def script(force = false) return unless full? - directory "script", :force => force do |content| + directory "script", force: force do |content| "#{shebang}\n" + content end - chmod "script", 0755, :verbose => false + chmod "script", 0755, verbose: false end def gemfile_entry @@ -158,20 +158,20 @@ task :default => :test alias_method :plugin_path, :app_path - class_option :dummy_path, :type => :string, :default => "test/dummy", - :desc => "Create dummy application at given path" + class_option :dummy_path, type: :string, default: "test/dummy", + desc: "Create dummy application at given path" - class_option :full, :type => :boolean, :default => false, - :desc => "Generate a rails engine with bundled Rails application for testing" + class_option :full, type: :boolean, default: false, + desc: "Generate a rails engine with bundled Rails application for testing" - class_option :mountable, :type => :boolean, :default => false, - :desc => "Generate mountable isolated application" + class_option :mountable, type: :boolean, default: false, + desc: "Generate mountable isolated application" - class_option :skip_gemspec, :type => :boolean, :default => false, - :desc => "Skip gemspec file" + class_option :skip_gemspec, type: :boolean, default: false, + desc: "Skip gemspec file" - class_option :skip_gemfile_entry, :type => :boolean, :default => false, - :desc => "If creating plugin in application's directory " + + class_option :skip_gemfile_entry, type: :boolean, default: false, + desc: "If creating plugin in application's directory " + "skip adding entry to Gemfile" def initialize(*args) diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt b/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt index bd983fb90f..1d380420b4 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt +++ b/railties/lib/rails/generators/rails/plugin_new/templates/app/views/layouts/%name%/application.html.erb.tt @@ -2,7 +2,7 @@ <%= camelized %> - <%%= stylesheet_link_tag "<%= name %>/application", :media => "all" %> + <%%= stylesheet_link_tag "<%= name %>/application", media: "all" %> <%%= javascript_include_tag "<%= name %>/application" %> <%%= csrf_meta_tags %> diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb index d3ba597dbd..8014feb75f 100644 --- a/railties/lib/rails/generators/rails/resource/resource_generator.rb +++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb @@ -7,14 +7,14 @@ module Rails class ResourceGenerator < ModelGenerator # :nodoc: include ResourceHelpers - hook_for :resource_controller, :required => true do |controller| + hook_for :resource_controller, required: true do |controller| invoke controller, [ controller_name, options[:actions] ] end - class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [], - :desc => "Actions for the resource controller" + class_option :actions, type: :array, banner: "ACTION ACTION", default: [], + desc: "Actions for the resource controller" - hook_for :resource_route, :required => true + hook_for :resource_route, required: true end end end diff --git a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb index c33c99e989..b4f466fbd8 100644 --- a/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold/scaffold_generator.rb @@ -6,10 +6,10 @@ module Rails remove_hook_for :resource_controller remove_class_option :actions - class_option :stylesheets, :type => :boolean, :desc => "Generate Stylesheets" - class_option :stylesheet_engine, :desc => "Engine for Stylesheets" + class_option :stylesheets, type: :boolean, desc: "Generate Stylesheets" + class_option :stylesheet_engine, desc: "Engine for Stylesheets" - hook_for :scaffold_controller, :required => true + hook_for :scaffold_controller, required: true hook_for :assets do |assets| invoke assets, [controller_name] diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb index df069ca937..4f36b612ae 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -5,21 +5,21 @@ module Rails class ScaffoldControllerGenerator < NamedBase # :nodoc: include ResourceHelpers - check_class_collision :suffix => "Controller" + check_class_collision suffix: "Controller" - class_option :orm, :banner => "NAME", :type => :string, :required => true, - :desc => "ORM to generate the controller for" + class_option :orm, banner: "NAME", type: :string, required: true, + desc: "ORM to generate the controller for" - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" + argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_controller_files template "controller.rb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb") end - hook_for :template_engine, :test_framework, :as => :scaffold + hook_for :template_engine, :test_framework, as: :scaffold # Invoke the helper using the controller name (pluralized) - hook_for :helper, :as => :scaffold do |invoked| + hook_for :helper, as: :scaffold do |invoked| invoke invoked, [ controller_name ] end end diff --git a/railties/lib/rails/generators/rails/task/task_generator.rb b/railties/lib/rails/generators/rails/task/task_generator.rb index cf3d1182ea..754824ca0c 100644 --- a/railties/lib/rails/generators/rails/task/task_generator.rb +++ b/railties/lib/rails/generators/rails/task/task_generator.rb @@ -1,7 +1,7 @@ module Rails module Generators class TaskGenerator < NamedBase # :nodoc: - argument :actions, :type => :array, :default => [], :banner => "action action" + argument :actions, type: :array, default: [], banner: "action action" def create_task_files template 'task.rb', File.join('lib/tasks', "#{file_name}.rake") diff --git a/railties/lib/rails/generators/rails/task/templates/task.rb b/railties/lib/rails/generators/rails/task/templates/task.rb index b7407bd6dc..1e3ed5f158 100644 --- a/railties/lib/rails/generators/rails/task/templates/task.rb +++ b/railties/lib/rails/generators/rails/task/templates/task.rb @@ -1,7 +1,7 @@ namespace :<%= file_name %> do <% actions.each do |action| -%> desc "TODO" - task :<%= action %> => :environment do + task <%= action %>: :environment do end <% end -%> diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 3df25219ab..7fd5c00768 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -8,7 +8,7 @@ module Rails mattr_accessor :skip_warn def self.included(base) #:nodoc: - base.class_option :force_plural, :type => :boolean, :desc => "Forces the use of a plural ModelName" + base.class_option :force_plural, type: :boolean, desc: "Forces the use of a plural ModelName" end # Set controller variables on initialization. diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index 30ae805348..24308dcf6c 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -200,12 +200,12 @@ module Rails # You can provide a configuration hash as second argument. This method returns the output # printed by the generator. def run_generator(args=self.default_arguments, config={}) - capture(:stdout) { self.generator_class.start(args, config.reverse_merge(:destination_root => destination_root)) } + capture(:stdout) { self.generator_class.start(args, config.reverse_merge(destination_root: destination_root)) } end # Instantiate the generator. def generator(args=self.default_arguments, options={}, config={}) - @generator ||= self.generator_class.new(args, options, config.reverse_merge(:destination_root => destination_root)) + @generator ||= self.generator_class.new(args, options, config.reverse_merge(destination_root: destination_root)) end # Create a Rails::Generators::GeneratedAttribute by supplying the diff --git a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb index c53930f994..b5aa581769 100644 --- a/railties/lib/rails/generators/test_unit/controller/controller_generator.rb +++ b/railties/lib/rails/generators/test_unit/controller/controller_generator.rb @@ -3,8 +3,8 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class ControllerGenerator < Base # :nodoc: - argument :actions, :type => :array, :default => [], :banner => "action action" - check_class_collision :suffix => "ControllerTest" + argument :actions, type: :array, default: [], banner: "action action" + check_class_collision suffix: "ControllerTest" def create_test_files template 'functional_test.rb', diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb index bcd370098e..0db76f9eaf 100644 --- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb +++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class HelperGenerator < Base # :nodoc: - check_class_collision :suffix => "HelperTest" + check_class_collision suffix: "HelperTest" def create_helper_files template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb") diff --git a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb index 427d128275..e004835bd5 100644 --- a/railties/lib/rails/generators/test_unit/integration/integration_generator.rb +++ b/railties/lib/rails/generators/test_unit/integration/integration_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class IntegrationGenerator < Base # :nodoc: - check_class_collision :suffix => "Test" + check_class_collision suffix: "Test" def create_test_files template 'integration_test.rb', File.join('test/integration', class_path, "#{file_name}_test.rb") diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb index 570a733227..3334b189bf 100644 --- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb @@ -3,8 +3,8 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class MailerGenerator < Base # :nodoc: - argument :actions, :type => :array, :default => [], :banner => "method method" - check_class_collision :suffix => "Test" + argument :actions, type: :array, default: [], banner: "method method" + check_class_collision suffix: "Test" def create_test_files template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb") diff --git a/railties/lib/rails/generators/test_unit/model/model_generator.rb b/railties/lib/rails/generators/test_unit/model/model_generator.rb index 9b73f3561f..2801749ffe 100644 --- a/railties/lib/rails/generators/test_unit/model/model_generator.rb +++ b/railties/lib/rails/generators/test_unit/model/model_generator.rb @@ -3,10 +3,10 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class ModelGenerator < Base # :nodoc: - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" - class_option :fixture, :type => :boolean + argument :attributes, type: :array, default: [], banner: "field:type field:type" + class_option :fixture, type: :boolean - check_class_collision :suffix => "Test" + check_class_collision suffix: "Test" def create_test_file template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_test.rb") diff --git a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb index 8bfb749743..64fe694a8b 100644 --- a/railties/lib/rails/generators/test_unit/observer/observer_generator.rb +++ b/railties/lib/rails/generators/test_unit/observer/observer_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class ObserverGenerator < Base # :nodoc: - check_class_collision :suffix => "ObserverTest" + check_class_collision suffix: "ObserverTest" def create_test_files template 'unit_test.rb', File.join('test/models', class_path, "#{file_name}_observer_test.rb") diff --git a/railties/lib/rails/generators/test_unit/performance/performance_generator.rb b/railties/lib/rails/generators/test_unit/performance/performance_generator.rb index 9a80d1ea54..5552edeee4 100644 --- a/railties/lib/rails/generators/test_unit/performance/performance_generator.rb +++ b/railties/lib/rails/generators/test_unit/performance/performance_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class PerformanceGenerator < Base # :nodoc: - check_class_collision :suffix => "Test" + check_class_collision suffix: "Test" def create_test_files template 'performance_test.rb', File.join('test/performance', class_path, "#{file_name}_test.rb") diff --git a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb index 2f25dcf832..2bcb482d68 100644 --- a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb +++ b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb @@ -3,8 +3,8 @@ require 'rails/performance_test_help' class <%= class_name %>Test < ActionDispatch::PerformanceTest # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory], - # :output => 'tmp/performance', :formats => [:flat] } + # self.profile_options = { runs: 5, metrics: [:wall_time, :memory], + # output: 'tmp/performance', formats: [:flat] } test "homepage" do get '/' diff --git a/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb b/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb index 41e8873783..b5d4f38444 100644 --- a/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/test_unit/plugin/plugin_generator.rb @@ -3,7 +3,7 @@ require 'rails/generators/test_unit' module TestUnit # :nodoc: module Generators # :nodoc: class PluginGenerator < Base # :nodoc: - check_class_collision :suffix => "Test" + check_class_collision suffix: "Test" def create_test_files directory '.', 'test' diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb index 0462c15224..3b4fec2e83 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb @@ -6,9 +6,9 @@ module TestUnit # :nodoc: class ScaffoldGenerator < Base # :nodoc: include Rails::Generators::ResourceHelpers - check_class_collision :suffix => "ControllerTest" + check_class_collision suffix: "ControllerTest" - argument :attributes, :type => :array, :default => [], :banner => "field:type field:type" + argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_test_files template "functional_test.rb", diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb index 512803aeac..e94c6a2030 100644 --- a/railties/lib/rails/info_controller.rb +++ b/railties/lib/rails/info_controller.rb @@ -23,7 +23,7 @@ class Rails::InfoController < ActionController::Base def require_local! unless local_request? - render :text => '

For security purposes, this information is only available to local requests.

', :status => :forbidden + render text: '

For security purposes, this information is only available to local requests.

', status: :forbidden end end diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 9826aecb54..8af4130e87 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -5,7 +5,7 @@ module Rails # paths by a Hash like API. It requires you to give a physical path on initialization. # # root = Root.new "/rails" - # root.add "app/controllers", :eager_load => true + # root.add "app/controllers", eager_load: true # # The command above creates a new root object and add "app/controllers" as a path. # This means we can get a Rails::Paths::Path object back like below: @@ -26,7 +26,7 @@ module Rails # contains the path with the same path value given to +add+. In some situations, # you may not want this behavior, so you can give :with as option. # - # root.add "config/routes", :with => "config/routes.rb" + # root.add "config/routes", with: "config/routes.rb" # root["config/routes"].inspect # => ["config/routes.rb"] # # The +add+ method accepts the following options as arguments: @@ -52,7 +52,7 @@ module Rails def []=(path, value) glob = self[path] ? self[path].glob : nil - add(path, :with => value, :glob => glob) + add(path, with: value, glob: glob) end def add(path, options={}) diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index fba685c769..5b454e7f20 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -172,7 +172,7 @@ module Rails end end - delegate :railtie_name, :to => "self.class" + delegate :railtie_name, to: "self.class" def config @config ||= Railtie::Configuration.new diff --git a/railties/lib/rails/railtie/configurable.rb b/railties/lib/rails/railtie/configurable.rb index 53796c74cf..1572af0b2a 100644 --- a/railties/lib/rails/railtie/configurable.rb +++ b/railties/lib/rails/railtie/configurable.rb @@ -6,7 +6,7 @@ module Rails extend ActiveSupport::Concern module ClassMethods - delegate :config, :to => :instance + delegate :config, to: :instance def inherited(base) raise "You cannot inherit from a #{self.superclass.name} child" diff --git a/railties/lib/rails/railtie/configuration.rb b/railties/lib/rails/railtie/configuration.rb index 9dc8843887..0cbbf04da2 100644 --- a/railties/lib/rails/railtie/configuration.rb +++ b/railties/lib/rails/railtie/configuration.rb @@ -50,23 +50,23 @@ module Rails # First configurable block to run. Called before any initializers are run. def before_configuration(&block) - ActiveSupport.on_load(:before_configuration, :yield => true, &block) + ActiveSupport.on_load(:before_configuration, yield: true, &block) end # Third configurable block to run. Does not run if +config.cache_classes+ # set to false. def before_eager_load(&block) - ActiveSupport.on_load(:before_eager_load, :yield => true, &block) + ActiveSupport.on_load(:before_eager_load, yield: true, &block) end # Second configurable block to run. Called before frameworks initialize. def before_initialize(&block) - ActiveSupport.on_load(:before_initialize, :yield => true, &block) + ActiveSupport.on_load(:before_initialize, yield: true, &block) end # Last configurable block to run. Called after frameworks initialize. def after_initialize(&block) - ActiveSupport.on_load(:after_initialize, :yield => true, &block) + ActiveSupport.on_load(:after_initialize, yield: true, &block) end # Array of callbacks defined by #to_prepare. diff --git a/railties/lib/rails/tasks/annotations.rake b/railties/lib/rails/tasks/annotations.rake index 9067b03d00..386ecf44be 100644 --- a/railties/lib/rails/tasks/annotations.rake +++ b/railties/lib/rails/tasks/annotations.rake @@ -2,7 +2,7 @@ require 'rails/source_annotation_extractor' desc "Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)" task :notes do - SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", :tag => true + SourceAnnotationExtractor.enumerate "OPTIMIZE|FIXME|TODO", tag: true end namespace :notes do diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake index f9cff5b627..50499304cb 100644 --- a/railties/lib/rails/tasks/framework.rake +++ b/railties/lib/rails/tasks/framework.rake @@ -1,6 +1,6 @@ namespace :rails do desc "Update configs and some other initially generated files (or use just update:configs, update:scripts, or update:application_controller)" - task :update => [ "update:configs", "update:scripts", "update:application_controller" ] + task update: [ "update:configs", "update:scripts", "update:application_controller" ] desc "Applies the template supplied by LOCATION=(/path/to/template) or URL" task :template do @@ -9,8 +9,8 @@ namespace :rails do template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} require 'rails/generators' require 'rails/generators/rails/app/app_generator' - generator = Rails::Generators::AppGenerator.new [Rails.root], {}, :destination_root => Rails.root - generator.apply template, :verbose => false + generator = Rails::Generators::AppGenerator.new [Rails.root], {}, destination_root: Rails.root + generator.apply template, verbose: false end namespace :templates do @@ -44,8 +44,8 @@ namespace :rails do @app_generator ||= begin require 'rails/generators' require 'rails/generators/rails/app/app_generator' - gen = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, - :destination_root => Rails.root + gen = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, + destination_root: Rails.root File.exists?(Rails.root.join("config", "application.rb")) ? gen.send(:app_const) : gen.send(:valid_app_const?) gen diff --git a/railties/lib/rails/tasks/middleware.rake b/railties/lib/rails/tasks/middleware.rake index cd35ffb19a..31e961b483 100644 --- a/railties/lib/rails/tasks/middleware.rake +++ b/railties/lib/rails/tasks/middleware.rake @@ -1,5 +1,5 @@ desc 'Prints out your Rack middleware stack' -task :middleware => :environment do +task middleware: :environment do Rails.configuration.middleware.each do |middleware| puts "use #{middleware.inspect}" end diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake index 0a9b9ff4ff..4195106961 100644 --- a/railties/lib/rails/tasks/misc.rake +++ b/railties/lib/rails/tasks/misc.rake @@ -5,7 +5,7 @@ task :secret do end desc 'List versions of all Rails frameworks and the environment' -task :about => :environment do +task about: :environment do puts Rails::Info end @@ -26,7 +26,7 @@ namespace :time do require 'active_support' require 'active_support/time' jan_offset = Time.now.beginning_of_year.utc_offset - jul_offset = Time.now.beginning_of_year.change(:month => 7).utc_offset + jul_offset = Time.now.beginning_of_year.change(month: 7).utc_offset offset = jan_offset < jul_offset ? jan_offset : jul_offset build_time_zone_list(:all, offset) end diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index 95f47566ef..676b475640 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -1,5 +1,5 @@ desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.' -task :routes => :environment do +task routes: :environment do all_routes = Rails.application.routes.routes require 'action_dispatch/routing/inspector' inspector = ActionDispatch::Routing::RoutesInspector.new diff --git a/railties/lib/rails/tasks/tmp.rake b/railties/lib/rails/tasks/tmp.rake index 0bb64ced95..116988665f 100644 --- a/railties/lib/rails/tasks/tmp.rake +++ b/railties/lib/rails/tasks/tmp.rake @@ -1,6 +1,6 @@ namespace :tmp do desc "Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)" - task :clear => [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"] + task clear: [ "tmp:sessions:clear", "tmp:cache:clear", "tmp:sockets:clear"] tmp_dirs = [ 'tmp/sessions', 'tmp/cache', @@ -13,7 +13,7 @@ namespace :tmp do tmp_dirs.each { |d| directory d } desc "Creates tmp directories for sessions, cache, sockets, and pids" - task :create => tmp_dirs + task create: tmp_dirs namespace :sessions do # desc "Clears all files in tmp/sessions" diff --git a/railties/lib/rails/test_unit/railtie.rb b/railties/lib/rails/test_unit/railtie.rb index 2b6170ebfb..ed89ce4128 100644 --- a/railties/lib/rails/test_unit/railtie.rb +++ b/railties/lib/rails/test_unit/railtie.rb @@ -1,8 +1,8 @@ module Rails class TestUnitRailtie < Rails::Railtie config.app_generators do |c| - c.test_framework :test_unit, :fixture => true, - :fixture_replacement => nil + c.test_framework :test_unit, fixture: true, + fixture_replacement: nil c.integration_tool :test_unit c.performance_tool :test_unit diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 63cb955d44..cd59fbe599 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -43,7 +43,7 @@ module Kernel end end -task :default => :test +task default: :test desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile)' task :test do @@ -61,7 +61,7 @@ namespace :test do Rake::Task[task].invoke nil rescue => e - { :task => task, :exception => e } + { task: task, exception: e } end end.compact @@ -71,7 +71,7 @@ namespace :test do end end - Rake::TestTask.new(:recent => "test:prepare") do |t| + Rake::TestTask.new(recent: "test:prepare") do |t| since = TEST_CHANGES_SINCE touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } + recent_tests('app/models/**/*.rb', 'test/models', since) + @@ -84,7 +84,7 @@ namespace :test do end Rake::Task['test:recent'].comment = "Test recent changes" - Rake::TestTask.new(:uncommitted => "test:prepare") do |t| + Rake::TestTask.new(uncommitted: "test:prepare") do |t| def t.file_list if File.directory?(".svn") changed_since_checkin = silence_stderr { `svn status` }.split.map { |path| path.chomp[7 .. -1] } @@ -108,52 +108,52 @@ namespace :test do end Rake::Task['test:uncommitted'].comment = "Test changes since last checkin (only Subversion and Git)" - Rake::TestTask.new(:single => "test:prepare") do |t| + Rake::TestTask.new(single: "test:prepare") do |t| t.libs << "test" end - Rails::SubTestTask.new(:models => "test:prepare") do |t| + Rails::SubTestTask.new(models: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/models/**/*_test.rb' end - Rails::SubTestTask.new(:helpers => "test:prepare") do |t| + Rails::SubTestTask.new(helpers: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/helpers/**/*_test.rb' end - Rails::SubTestTask.new(:units => "test:prepare") do |t| + Rails::SubTestTask.new(units: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/{models,helpers,unit}/**/*_test.rb' end - Rails::SubTestTask.new(:controllers => "test:prepare") do |t| + Rails::SubTestTask.new(controllers: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/controllers/**/*_test.rb' end - Rails::SubTestTask.new(:mailers => "test:prepare") do |t| + Rails::SubTestTask.new(mailers: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/mailers/**/*_test.rb' end - Rails::SubTestTask.new(:functionals => "test:prepare") do |t| + Rails::SubTestTask.new(functionals: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/{controllers,mailers,functional}/**/*_test.rb' end - Rails::SubTestTask.new(:integration => "test:prepare") do |t| + Rails::SubTestTask.new(integration: "test:prepare") do |t| t.libs << "test" t.pattern = 'test/integration/**/*_test.rb' end - Rails::SubTestTask.new(:benchmark => 'test:prepare') do |t| + Rails::SubTestTask.new(benchmark: 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' t.options = '-- --benchmark' end - Rails::SubTestTask.new(:profile => 'test:prepare') do |t| + Rails::SubTestTask.new(profile: 'test:prepare') do |t| t.libs << 'test' t.pattern = 'test/performance/**/*_test.rb' end diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb index a7b3ae1e9a..1eddfac664 100644 --- a/railties/test/application/asset_debugging_test.rb +++ b/railties/test/application/asset_debugging_test.rb @@ -7,7 +7,7 @@ module ApplicationTests include Rack::Test::Methods def setup - build_app(:initializers => true) + build_app(initializers: true) app_file "app/assets/javascripts/application.js", "//= require_tree ." app_file "app/assets/javascripts/xmlhr.js", "function f1() { alert(); }" @@ -15,7 +15,7 @@ module ApplicationTests app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get '/posts', :to => "posts#index" + get '/posts', to: "posts#index" end RUBY diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 8a76b2f614..2506d19e6d 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -8,7 +8,7 @@ module ApplicationTests include Rack::Test::Methods def setup - build_app(:initializers => true) + build_app(initializers: true) boot_rails end @@ -44,7 +44,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '*path', :to => lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] } + get '*path', to: lambda { |env| [200, { "Content-Type" => "text/html" }, "Not an asset"] } end RUBY @@ -353,7 +353,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index flash[:cool_story] = true - render :text => "ok" + render text: "ok" end end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 3691c5e3d5..7a120410ba 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -239,7 +239,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index cookies.signed[:some_key] = "some_value" - render :text => env["action_dispatch.secret_token"] + render text: env["action_dispatch.secret_token"] end end @@ -252,7 +252,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= csrf_meta_tags %>" + render inline: "<%= csrf_meta_tags %>" end end @@ -272,11 +272,11 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ApplicationController def show - render :inline => "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>" + render inline: "<%= begin; form_for(Post.new) {}; rescue => e; e.to_s; end %>" end def update - render :text => "update" + render text: "update" end end RUBY @@ -291,7 +291,7 @@ module ApplicationTests token = "cf50faa3fe97702ca1ae" PostsController.any_instance.stubs(:form_authenticity_token).returns(token) - params = {:authenticity_token => token} + params = {authenticity_token: token} get "/posts/1" assert_match(/patch/, last_response.body) @@ -316,7 +316,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= csrf_meta_tags %>" + render inline: "<%= csrf_meta_tags %>" end end @@ -440,7 +440,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :inline => "<%= image_path('foo.jpg') %>" + render inline: "<%= image_path('foo.jpg') %>" end end @@ -493,7 +493,7 @@ module ApplicationTests class ::OmgController < ActionController::Base def index - render :text => env["action_dispatch.show_exceptions"] + render text: env["action_dispatch.show_exceptions"] end end @@ -503,7 +503,7 @@ module ApplicationTests test "config.action_controller.wrap_parameters is set in ActionController::Base" do app_file 'config/initializers/wrap_parameters.rb', <<-RUBY - ActionController::Base.wrap_parameters :format => [:json] + ActionController::Base.wrap_parameters format: [:json] RUBY app_file 'app/models/post.rb', <<-RUBY @@ -523,7 +523,7 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ApplicationController def create - render :text => params[:post].inspect + render text: params[:post].inspect end end RUBY @@ -544,7 +544,7 @@ module ApplicationTests app_file 'app/controllers/posts_controller.rb', <<-RUBY class PostsController < ActionController::Base def create - render :text => params[:post].permitted? ? "permitted" : "forbidden" + render text: params[:post].permitted? ? "permitted" : "forbidden" end end RUBY @@ -558,7 +558,7 @@ module ApplicationTests require "#{app_path}/config/environment" - post "/posts", {:post => {"title" =>"zomg"}} + post "/posts", {post: {"title" =>"zomg"}} assert_equal 'permitted', last_response.body end @@ -570,8 +570,8 @@ module ApplicationTests class ::OmgController < ActionController::Base def index respond_to do |format| - format.html { render :text => "HTML" } - format.xml { render :text => "XML" } + format.html { render text: "HTML" } + format.xml { render text: "XML" } end end end @@ -579,7 +579,7 @@ module ApplicationTests get "/", {}, "HTTP_ACCEPT" => "application/xml" assert_equal 'HTML', last_response.body - get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml" + get "/", { format: :xml }, "HTTP_ACCEPT" => "application/xml" assert_equal 'XML', last_response.body end diff --git a/railties/test/application/generators_test.rb b/railties/test/application/generators_test.rb index b80244f1d2..bc0af499c1 100644 --- a/railties/test/application/generators_test.rb +++ b/railties/test/application/generators_test.rb @@ -48,22 +48,22 @@ module ApplicationTests c.generators.orm = :data_mapper c.generators.test_framework = :rspec c.generators.helper = false - expected = { :rails => { :orm => :data_mapper, :test_framework => :rspec, :helper => false } } + expected = { rails: { orm: :data_mapper, test_framework: :rspec, helper: false } } assert_equal(expected, c.generators.options) end end test "generators set rails aliases" do with_config do |c| - c.generators.aliases = { :rails => { :test_framework => "-w" } } - expected = { :rails => { :test_framework => "-w" } } + c.generators.aliases = { rails: { test_framework: "-w" } } + expected = { rails: { test_framework: "-w" } } assert_equal expected, c.generators.aliases end end test "generators aliases, options, templates and fallbacks on initialization" do add_to_config <<-RUBY - config.generators.rails :aliases => { :test_framework => "-w" } + config.generators.rails aliases: { test_framework: "-w" } config.generators.orm :data_mapper config.generators.test_framework :rspec config.generators.fallbacks[:shoulda] = :test_unit @@ -76,7 +76,7 @@ module ApplicationTests assert_equal :rspec, Rails::Generators.options[:rails][:test_framework] assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework] - assert_equal Hash[:shoulda => :test_unit], Rails::Generators.fallbacks + assert_equal Hash[shoulda: :test_unit], Rails::Generators.fallbacks assert_equal ["some/where"], Rails::Generators.templates_path end @@ -95,31 +95,31 @@ module ApplicationTests test "generators with hashes for options and aliases" do with_bare_config do |c| c.generators do |g| - g.orm :data_mapper, :migration => false - g.plugin :aliases => { :generator => "-g" }, - :generator => true + g.orm :data_mapper, migration: false + g.plugin aliases: { generator: "-g" }, + generator: true end expected = { - :rails => { :orm => :data_mapper }, - :plugin => { :generator => true }, - :data_mapper => { :migration => false } + rails: { orm: :data_mapper }, + plugin: { generator: true }, + data_mapper: { migration: false } } assert_equal expected, c.generators.options - assert_equal({ :plugin => { :generator => "-g" } }, c.generators.aliases) + assert_equal({ plugin: { generator: "-g" } }, c.generators.aliases) end end test "generators with string and hash for options should generate symbol keys" do with_bare_config do |c| c.generators do |g| - g.orm 'data_mapper', :migration => false + g.orm 'data_mapper', migration: false end expected = { - :rails => { :orm => :data_mapper }, - :data_mapper => { :migration => false } + rails: { orm: :data_mapper }, + data_mapper: { migration: false } } assert_equal expected, c.generators.options diff --git a/railties/test/application/initializers/i18n_test.rb b/railties/test/application/initializers/i18n_test.rb index 02d20bc150..489b7ddb92 100644 --- a/railties/test/application/initializers/i18n_test.rb +++ b/railties/test/application/initializers/i18n_test.rb @@ -143,7 +143,7 @@ en: I18n::Railtie.config.i18n.fallbacks = true load_app assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks) - assert_fallbacks :de => [:de, :en] + assert_fallbacks de: [:de, :en] end test "config.i18n.fallbacks = true initializes I18n.fallbacks with default settings even when backend changes" do @@ -151,37 +151,37 @@ en: I18n::Railtie.config.i18n.backend = Class.new(I18n::Backend::Simple).new load_app assert I18n.backend.class.included_modules.include?(I18n::Backend::Fallbacks) - assert_fallbacks :de => [:de, :en] + assert_fallbacks de: [:de, :en] end test "config.i18n.fallbacks.defaults = [:'en-US'] initializes fallbacks with en-US as a fallback default" do I18n::Railtie.config.i18n.fallbacks.defaults = [:'en-US'] load_app - assert_fallbacks :de => [:de, :'en-US', :en] + assert_fallbacks de: [:de, :'en-US', :en] end 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' } load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :en] end test "[shortcut] config.i18n.fallbacks = [:'en-US'] initializes fallbacks with en-US as a fallback default" do I18n::Railtie.config.i18n.fallbacks = [:'en-US'] load_app - assert_fallbacks :de => [:de, :'en-US', :en] + assert_fallbacks de: [:de, :'en-US', :en] end test "[shortcut] config.i18n.fallbacks = [{ :ca => :'es-ES' }] initializes fallbacks with a mapping de-AT => de-DE" do I18n::Railtie.config.i18n.fallbacks.map = { :ca => :'es-ES' } load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :en] end 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' }] load_app - assert_fallbacks :ca => [:ca, :"es-ES", :es, :'en-US', :en] + assert_fallbacks ca: [:ca, :"es-ES", :es, :'en-US', :en] end end end diff --git a/railties/test/application/initializers/notifications_test.rb b/railties/test/application/initializers/notifications_test.rb index d866a63fe0..baae6fd928 100644 --- a/railties/test/application/initializers/notifications_test.rb +++ b/railties/test/application/initializers/notifications_test.rb @@ -33,7 +33,7 @@ module ApplicationTests ActiveRecord::Base.logger = logger # Mimic Active Record notifications - instrument "sql.active_record", :name => "SQL", :sql => "SHOW tables" + instrument "sql.active_record", name: "SQL", sql: "SHOW tables" wait assert_equal 1, logger.logged(:debug).size diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb index fcbc3c048c..ad7172c514 100644 --- a/railties/test/application/loading_test.rb +++ b/railties/test/application/loading_test.rb @@ -19,14 +19,14 @@ class LoadingTest < ActiveSupport::TestCase test "constants in app are autoloaded" do app_file "app/models/post.rb", <<-MODEL class Post < ActiveRecord::Base - validates_acceptance_of :title, :accept => "omg" + validates_acceptance_of :title, accept: "omg" end MODEL require "#{rails_root}/config/environment" setup_ar! - p = Post.create(:title => 'omg') + p = Post.create(title: 'omg') assert_equal 1, Post.count assert_equal 'omg', p.title p = Post.first @@ -36,7 +36,7 @@ class LoadingTest < ActiveSupport::TestCase test "models without table do not panic on scope definitions when loaded" do app_file "app/models/user.rb", <<-MODEL class User < ActiveRecord::Base - default_scope where(:published => true) + default_scope where(published: true) end MODEL @@ -76,8 +76,8 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/load', :to => lambda { |env| [200, {}, Post.all] } - get '/unload', :to => lambda { |env| [200, {}, []] } + get '/load', to: lambda { |env| [200, {}, Post.all] } + get '/unload', to: lambda { |env| [200, {}, []] } end RUBY @@ -106,7 +106,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } + get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } end RUBY @@ -145,7 +145,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } + get '/c', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [User.counter.to_s]] } end RUBY @@ -181,7 +181,7 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY $counter = 0 AppTemplate::Application.routes.draw do - get '/c', :to => lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] } + get '/c', to: lambda { |env| User; [200, {"Content-Type" => "text/plain"}, [$counter.to_s]] } end RUBY @@ -212,8 +212,8 @@ class LoadingTest < ActiveSupport::TestCase app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get '/title', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] } - get '/body', :to => lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] } + get '/title', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.title]] } + get '/body', to: lambda { |env| [200, {"Content-Type" => "text/plain"}, [Post.new.body]] } end RUBY @@ -229,7 +229,7 @@ class LoadingTest < ActiveSupport::TestCase class CreatePosts < ActiveRecord::Migration def change create_table :posts do |t| - t.string :title, :default => "TITLE" + t.string :title, default: "TITLE" end end end @@ -244,7 +244,7 @@ class LoadingTest < ActiveSupport::TestCase app_file "db/migrate/2_add_body_to_posts.rb", <<-MIGRATION class AddBodyToPosts < ActiveRecord::Migration def change - add_column :posts, :body, :text, :default => "BODY" + add_column :posts, :body, :text, default: "BODY" end end MIGRATION @@ -297,9 +297,9 @@ class LoadingTest < ActiveSupport::TestCase protected def setup_ar! - ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:") + ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") ActiveRecord::Migration.verbose = false - ActiveRecord::Schema.define(:version => 1) do + ActiveRecord::Schema.define(version: 1) do create_table :posts do |t| t.string :title end diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index fffe79f9cc..9b6c76e7aa 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -19,17 +19,17 @@ module ApplicationTests controller :expires, <<-RUBY class ExpiresController < ApplicationController def expires_header - expires_in 10, :public => !params[:private] - render :text => SecureRandom.hex(16) + expires_in 10, public: !params[:private] + render text: SecureRandom.hex(16) end def expires_etag - render_conditionally(:etag => "1") + render_conditionally(etag: "1") end def expires_last_modified $last_modified ||= Time.now.utc - render_conditionally(:last_modified => $last_modified) + render_conditionally(last_modified: $last_modified) end def keeps_if_modified_since @@ -37,8 +37,8 @@ module ApplicationTests end private def render_conditionally(headers) - if stale?(headers.merge(:public => !params[:private])) - render :text => SecureRandom.hex(16) + if stale?(headers.merge(public: !params[:private])) + render text: SecureRandom.hex(16) end end end @@ -96,13 +96,13 @@ module ApplicationTests def test_cache_works_with_expires_private simple_controller - get "/expires/expires_header", :private => true + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "private, max-age=10", last_response.headers["Cache-Control"] body = last_response.body - get "/expires/expires_header", :private => true + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end @@ -125,14 +125,14 @@ module ApplicationTests def test_cache_works_with_etags_private simple_controller - get "/expires/expires_etag", :private => true + get "/expires/expires_etag", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] body = last_response.body etag = last_response.headers["ETag"] - get "/expires/expires_etag", {:private => true}, "If-None-Match" => etag + get "/expires/expires_etag", {private: true}, "If-None-Match" => etag assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end @@ -155,14 +155,14 @@ module ApplicationTests def test_cache_works_with_last_modified_private simple_controller - get "/expires/expires_last_modified", :private => true + get "/expires/expires_last_modified", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] body = last_response.body last = last_response.headers["Last-Modified"] - get "/expires/expires_last_modified", {:private => true}, "If-Modified-Since" => last + get "/expires/expires_last_modified", {private: true}, "If-Modified-Since" => last assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_not_equal body, last_response.body end diff --git a/railties/test/application/middleware/session_test.rb b/railties/test/application/middleware/session_test.rb index 06dec81d40..5ce41caf61 100644 --- a/railties/test/application/middleware/session_test.rb +++ b/railties/test/application/middleware/session_test.rb @@ -36,7 +36,7 @@ module ApplicationTests flash[:notice] = "notice" end - render :nothing => true + render nothing: true end end diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index b2443e6503..c03d35e926 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -81,10 +81,10 @@ module ApplicationTests test "ActionDispatch::SSL is configured with options when given" do add_to_config "config.force_ssl = true" - add_to_config "config.ssl_options = { :host => 'example.com' }" + add_to_config "config.ssl_options = { host: 'example.com' }" boot! - assert_equal AppTemplate::Application.middleware.first.args, [{:host => 'example.com'}] + assert_equal AppTemplate::Application.middleware.first.args, [{host: 'example.com'}] end test "removing Active Record omits its middleware" do @@ -169,9 +169,9 @@ module ApplicationTests class ::OmgController < ActionController::Base def index if params[:nothing] - render :text => "" + render text: "" else - render :text => "OMG" + render text: "OMG" end end end diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 2e7426150c..c5a68a5152 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -46,7 +46,7 @@ module ApplicationTests end rake_tasks do - task :do_nothing => :environment do + task do_nothing: :environment do end end RUBY @@ -60,7 +60,7 @@ module ApplicationTests config.eager_load = true rake_tasks do - task :do_nothing => :environment do + task do_nothing: :environment do Hello.new.world end end @@ -109,7 +109,7 @@ module ApplicationTests def test_rake_routes_calls_the_route_inspector app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get '/cart', :to => 'cart#show' + get '/cart', to: 'cart#show' end RUBY assert_equal "cart GET /cart(.:format) cart#show\n", Dir.chdir(app_path){ `rake routes` } @@ -118,7 +118,7 @@ module ApplicationTests def test_logger_is_flushed_when_exiting_production_rake_tasks add_to_config <<-RUBY rake_tasks do - task :log_something => :environment do + task log_something: :environment do Rails.logger.error("Sample log message") end end @@ -233,7 +233,7 @@ module ApplicationTests app_file "lib/tasks/count_user.rake", <<-RUBY namespace :user do - task :count => :environment do + task count: :environment do puts User.count end end diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index 396b1849d8..ffcdeac7f0 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -50,7 +50,7 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def index - render :inline => "<%= foo_or_bar? %>" + render inline: "<%= foo_or_bar? %>" end end RUBY @@ -76,7 +76,7 @@ module ApplicationTests test "mount rack app" do app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - mount lambda { |env| [200, {}, [env["PATH_INFO"]]] }, :at => "/blog" + mount lambda { |env| [200, {}, [env["PATH_INFO"]]] }, at: "/blog" # The line below is required because mount sometimes # fails when a resource route is added. resource :user @@ -91,7 +91,7 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY @@ -99,7 +99,7 @@ module ApplicationTests controller :bar, <<-RUBY class BarController < ActionController::Base def index - render :text => "bar" + render text: "bar" end end RUBY @@ -121,7 +121,7 @@ module ApplicationTests controller 'foo', <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY @@ -130,7 +130,7 @@ module ApplicationTests module Admin class FooController < ApplicationController def index - render :text => "admin::foo" + render text: "admin::foo" end end end @@ -138,8 +138,8 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'admin/foo', :to => 'admin/foo#index' - get 'foo', :to => 'foo#index' + get 'admin/foo', to: 'admin/foo#index' + get 'foo', to: 'foo#index' end RUBY @@ -183,18 +183,18 @@ module ApplicationTests controller :foo, <<-RUBY class FooController < ApplicationController def bar - render :text => "bar" + render text: "bar" end def baz - render :text => "baz" + render text: "baz" end end RUBY app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => 'foo#bar' + get 'foo', to: 'foo#bar' end RUBY @@ -205,7 +205,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => 'foo#baz' + get 'foo', to: 'foo#baz' end RUBY @@ -226,7 +226,7 @@ module ApplicationTests app_file 'config/routes.rb', <<-RUBY AppTemplate::Application.routes.draw do - get 'foo', :to => ::InitializeRackApp + get 'foo', to: ::InitializeRackApp end RUBY @@ -257,7 +257,7 @@ module ApplicationTests controller 'yazilar', <<-RUBY class YazilarController < ApplicationController def index - render :text => 'yazilar#index' + render text: 'yazilar#index' end end RUBY diff --git a/railties/test/application/url_generation_test.rb b/railties/test/application/url_generation_test.rb index f7e60749a7..4ecb94b65e 100644 --- a/railties/test/application/url_generation_test.rb +++ b/railties/test/application/url_generation_test.rb @@ -15,7 +15,7 @@ module ApplicationTests class MyApp < Rails::Application config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" + config.session_store :cookie_store, key: "_myapp_session" config.active_support.deprecation = :log end @@ -26,12 +26,12 @@ module ApplicationTests class ::OmgController < ::ApplicationController def index - render :text => omg_path + render text: omg_path end end MyApp.routes.draw do - get "/" => "omg#index", :as => :omg + get "/" => "omg#index", as: :omg end require 'rack/test' diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb index 69e89d87ae..e047d4882d 100644 --- a/railties/test/commands/console_test.rb +++ b/railties/test/commands/console_test.rb @@ -58,8 +58,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase end def test_console_defaults_to_IRB - config = mock("config", :console => nil) - app = mock("app", :config => config) + config = mock("config", console: nil) + app = mock("app", config: config) app.expects(:load_console).returns(nil) assert_equal IRB, Rails::Console.new(app).console @@ -115,8 +115,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase def app @app ||= begin - config = mock("config", :console => FakeConsole) - app = mock("app", :config => config) + config = mock("config", console: FakeConsole) + app = mock("app", config: config) app.stubs(:sandbox=).returns(nil) app.expects(:load_console) app diff --git a/railties/test/fixtures/lib/plugin_builders/spec_builder.rb b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb index aa18c7ddaa..2721429599 100644 --- a/railties/test/fixtures/lib/plugin_builders/spec_builder.rb +++ b/railties/test/fixtures/lib/plugin_builders/spec_builder.rb @@ -4,7 +4,7 @@ class PluginBuilder < Rails::PluginBuilder append_file "Rakefile", <<-EOF # spec tasks in rakefile -task :default => :spec +task default: :spec EOF end diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index bc086c5986..8af92479c3 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -99,7 +99,7 @@ class ActionsTest < Rails::Generators::TestCase def test_environment_should_include_data_in_environment_initializer_block_with_env_option run_generator autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]' - action :environment, autoload_paths, :env => 'development' + action :environment, autoload_paths, env: 'development' assert_file "config/environments/development.rb", /Application\.configure do\n #{Regexp.escape(autoload_paths)}/ end @@ -124,7 +124,7 @@ class ActionsTest < Rails::Generators::TestCase def test_git_with_hash_should_run_each_command_using_git_scm generator.expects(:run).times(2) - action :git, :rm => 'README', :add => '.' + action :git, rm: 'README', add: '.' end def test_vendor_should_write_data_to_file_in_vendor @@ -138,8 +138,8 @@ class ActionsTest < Rails::Generators::TestCase end def test_rakefile_should_write_date_to_file_in_lib_tasks - action :rakefile, 'myapp.rake', 'task :run => [:environment]' - assert_file 'lib/tasks/myapp.rake', 'task :run => [:environment]' + action :rakefile, 'myapp.rake', 'task run: [:environment]' + assert_file 'lib/tasks/myapp.rake', 'task run: [:environment]' end def test_initializer_should_write_date_to_file_in_config_initializers @@ -148,12 +148,12 @@ class ActionsTest < Rails::Generators::TestCase end def test_generate_should_run_script_generate_with_argument_and_options - generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', :verbose => false) + generator.expects(:run_ruby_script).once.with('script/rails generate model MyModel', verbose: false) action :generate, 'model', 'MyModel' end def test_rake_should_run_rake_command_with_default_env - generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", :verbose => false) + generator.expects(:run).once.with("rake log:clear RAILS_ENV=development", verbose: false) old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil action :rake, 'log:clear' ensure @@ -161,12 +161,12 @@ class ActionsTest < Rails::Generators::TestCase end def test_rake_with_env_option_should_run_rake_command_in_env - generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false) - action :rake, 'log:clear', :env => 'production' + generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false) + action :rake, 'log:clear', env: 'production' end def test_rake_with_rails_env_variable_should_run_rake_command_in_env - generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false) + generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false) old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "production" action :rake, 'log:clear' ensure @@ -174,29 +174,29 @@ class ActionsTest < Rails::Generators::TestCase end def test_env_option_should_win_over_rails_env_variable_when_running_rake - generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', :verbose => false) + generator.expects(:run).once.with('rake log:clear RAILS_ENV=production', verbose: false) old_env, ENV["RAILS_ENV"] = ENV["RAILS_ENV"], "staging" - action :rake, 'log:clear', :env => 'production' + action :rake, 'log:clear', env: 'production' ensure ENV["RAILS_ENV"] = old_env end def test_rake_with_sudo_option_should_run_rake_command_with_sudo - generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", :verbose => false) + generator.expects(:run).once.with("sudo rake log:clear RAILS_ENV=development", verbose: false) old_env, ENV['RAILS_ENV'] = ENV["RAILS_ENV"], nil - action :rake, 'log:clear', :sudo => true + action :rake, 'log:clear', sudo: true ensure ENV["RAILS_ENV"] = old_env end def test_capify_should_run_the_capify_command - generator.expects(:run).once.with('capify .', :verbose => false) + generator.expects(:run).once.with('capify .', verbose: false) action :capify! end def test_route_should_add_data_to_the_routes_block_in_config_routes run_generator - route_command = "route '/login', :controller => 'sessions', :action => 'new'" + route_command = "route '/login', controller: 'sessions', action: 'new'" action :route, route_command assert_file 'config/routes.rb', /#{Regexp.escape(route_command)}/ end @@ -208,7 +208,7 @@ class ActionsTest < Rails::Generators::TestCase end def test_readme_with_quiet - generator(default_arguments, :quiet => true) + generator(default_arguments, quiet: true) run_generator Rails::Generators::AppGenerator.expects(:source_root).times(2).returns(destination_root) assert_no_match(/Welcome to Rails/, action(:readme, "README.rdoc")) @@ -223,12 +223,12 @@ class ActionsTest < Rails::Generators::TestCase end def test_log_with_quiet - generator(default_arguments, :quiet => true) + generator(default_arguments, quiet: true) assert_equal("", action(:log, "YES")) end def test_log_with_status_with_quiet - generator(default_arguments, :quiet => true) + generator(default_arguments, quiet: true) assert_equal("", action(:log, :yes, "YES")) end diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 6b6a6b6099..e5397bf4f3 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -107,8 +107,8 @@ class AppGeneratorTest < Rails::Generators::TestCase FileUtils.mv(app_root, app_moved_root) - generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, - :destination_root => app_moved_root, :shell => @shell + generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, + destination_root: app_moved_root, shell: @shell generator.send(:app_const) quietly { generator.send(:create_config_files) } assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/ @@ -123,7 +123,7 @@ class AppGeneratorTest < Rails::Generators::TestCase Rails.application.class.stubs(:name).returns("Myapp") Rails.application.stubs(:is_a?).returns(Rails::Application) - generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, :destination_root => app_root, :shell => @shell + generator = Rails::Generators::AppGenerator.new ["rails"], { with_dispatchers: true }, destination_root: app_root, shell: @shell generator.send(:app_const) quietly { generator.send(:create_config_files) } assert_file "myapp/config/initializers/session_store.rb", /_myapp_session/ diff --git a/railties/test/generators/model_generator_test.rb b/railties/test/generators/model_generator_test.rb index a90ad5cde0..0c7ff0ebe7 100644 --- a/railties/test/generators/model_generator_test.rb +++ b/railties/test/generators/model_generator_test.rb @@ -242,19 +242,19 @@ class ModelGeneratorTest < Rails::Generators::TestCase def test_migration_is_skipped_on_skip_behavior run_generator - output = run_generator ["Account"], :behavior => :skip + output = run_generator ["Account"], behavior: :skip assert_match %r{skip\s+db/migrate/\d+_create_accounts.rb}, output end def test_migration_error_is_not_shown_on_revoke run_generator - error = capture(:stderr){ run_generator ["Account"], :behavior => :revoke } + error = capture(:stderr){ run_generator ["Account"], behavior: :revoke } assert_no_match(/Another migration is already named create_accounts/, error) end def test_migration_is_removed_on_revoke run_generator - run_generator ["Account"], :behavior => :revoke + run_generator ["Account"], behavior: :revoke assert_no_migration "db/migrate/create_accounts.rb" end diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb index d48712e51f..4b168ae110 100644 --- a/railties/test/generators/namespaced_generators_test.rb +++ b/railties/test/generators/namespaced_generators_test.rb @@ -263,7 +263,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase def test_scaffold_on_revoke run_generator - run_generator ["product_line"], :behavior => :revoke + run_generator ["product_line"], behavior: :revoke # Model assert_no_file "app/models/test_app/product_line.rb" @@ -335,7 +335,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase def test_scaffold_with_namespace_on_revoke run_generator [ "admin/role", "name:string", "description:string" ] - run_generator [ "admin/role" ], :behavior => :revoke + run_generator [ "admin/role" ], behavior: :revoke # Model assert_file "app/models/test_app/admin.rb" # ( should not be remove ) @@ -408,7 +408,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase def test_scaffold_with_nested_namespace_on_revoke run_generator [ "admin/user/special/role", "name:string", "description:string" ] - run_generator [ "admin/user/special/role" ], :behavior => :revoke + run_generator [ "admin/user/special/role" ], behavior: :revoke # Model assert_file "app/models/test_app/admin/user/special.rb" # ( should not be remove ) diff --git a/railties/test/generators/orm_test.rb b/railties/test/generators/orm_test.rb index 9dd3d3e0ec..88ae930554 100644 --- a/railties/test/generators/orm_test.rb +++ b/railties/test/generators/orm_test.rb @@ -20,12 +20,12 @@ class OrmTest < Rails::Generators::TestCase tests Rails::Generators::ScaffoldControllerGenerator def test_orm_class_returns_custom_generator_if_supported_custom_orm_set - g = generator ["Foo"], :orm => "ORMWithGenerators" + g = generator ["Foo"], orm: "ORMWithGenerators" assert_equal ORMWithGenerators::Generators::ActiveModel, g.send(:orm_class) end def test_orm_class_returns_rails_generator_if_unsupported_custom_orm_set - g = generator ["Foo"], :orm => "ORMWithoutGenerators" + g = generator ["Foo"], orm: "ORMWithoutGenerators" assert_equal Rails::Generators::ActiveModel, g.send(:orm_class) end diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index dddbfa64b6..6974db5751 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -379,7 +379,7 @@ class CustomPluginGeneratorTest < Rails::Generators::TestCase run_generator([destination_root, "-b", "#{Rails.root}/lib/plugin_builders/spec_builder.rb"]) assert_file 'spec/spec_helper.rb' assert_file 'spec/dummy' - assert_file 'Rakefile', /task :default => :spec/ + assert_file 'Rakefile', /task default: :spec/ assert_file 'Rakefile', /# spec tasks in rakefile/ end diff --git a/railties/test/generators/resource_generator_test.rb b/railties/test/generators/resource_generator_test.rb index 0ae0841442..3d4e694361 100644 --- a/railties/test/generators/resource_generator_test.rb +++ b/railties/test/generators/resource_generator_test.rb @@ -80,7 +80,7 @@ class ResourceGeneratorTest < Rails::Generators::TestCase def test_route_is_removed_on_revoke run_generator - run_generator ["account"], :behavior => :revoke + run_generator ["account"], behavior: :revoke assert_file "config/routes.rb" do |route| assert_no_match(/resources :accounts$/, route) diff --git a/railties/test/generators/scaffold_generator_test.rb b/railties/test/generators/scaffold_generator_test.rb index dc825c7c99..efe47cdfcb 100644 --- a/railties/test/generators/scaffold_generator_test.rb +++ b/railties/test/generators/scaffold_generator_test.rb @@ -99,7 +99,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase def test_scaffold_on_revoke run_generator - run_generator ["product_line"], :behavior => :revoke + run_generator ["product_line"], behavior: :revoke # Model assert_no_file "app/models/product_line.rb" diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index a4bdfcf438..1e5a4545a1 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -87,7 +87,7 @@ module SharedGeneratorTests template = %{ say "It works!" } template.instance_eval "def read; self; end" # Make the string respond to read - generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) + generator([destination_root], template: path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) end @@ -96,31 +96,31 @@ module SharedGeneratorTests template = %{ say "It works!" } template.instance_eval "def read; self; end" # Make the string respond to read - generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) + generator([destination_root], template: path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template) assert_match(/It works!/, capture(:stdout) { generator.invoke_all }) end def test_dev_option - generator([destination_root], :dev => true).expects(:bundle_command).with('install').once + generator([destination_root], dev: true).expects(:bundle_command).with('install').once quietly { generator.invoke_all } rails_path = File.expand_path('../../..', Rails.root) assert_file 'Gemfile', /^gem\s+["']rails["'],\s+path:\s+["']#{Regexp.escape(rails_path)}["']$/ end def test_edge_option - generator([destination_root], :edge => true).expects(:bundle_command).with('install').once + generator([destination_root], edge: true).expects(:bundle_command).with('install').once quietly { generator.invoke_all } assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$} end def test_skip_gemfile - generator([destination_root], :skip_gemfile => true).expects(:bundle_command).never + generator([destination_root], skip_gemfile: true).expects(:bundle_command).never quietly { generator.invoke_all } assert_no_file 'Gemfile' end def test_skip_bundle - generator([destination_root], :skip_bundle => true).expects(:bundle_command).never + generator([destination_root], skip_bundle: true).expects(:bundle_command).never quietly { generator.invoke_all } # skip_bundle is only about running bundle install, ensure the Gemfile is still @@ -192,7 +192,7 @@ module SharedCustomGeneratorTests template = "class #{builder_class}; end" template.instance_eval "def read; self; end" # Make the string respond to read - generator([destination_root], :builder => url).expects(:open).with(url, 'Accept' => 'application/x-thor-template').returns(template) + generator([destination_root], builder: url).expects(:open).with(url, 'Accept' => 'application/x-thor-template').returns(template) quietly { generator.invoke_all } default_files.each{ |path| assert_no_file(path) } diff --git a/railties/test/generators_test.rb b/railties/test/generators_test.rb index 027d8eb9b7..9953aa929b 100644 --- a/railties/test/generators_test.rb +++ b/railties/test/generators_test.rb @@ -43,8 +43,8 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_invoke_with_config_values - Rails::Generators::ModelGenerator.expects(:start).with(["Account"], :behavior => :skip) - Rails::Generators.invoke :model, ["Account"], :behavior => :skip + Rails::Generators::ModelGenerator.expects(:start).with(["Account"], behavior: :skip) + Rails::Generators.invoke :model, ["Account"], behavior: :skip end def test_find_by_namespace @@ -165,7 +165,7 @@ class GeneratorsTest < Rails::Generators::TestCase end def test_developer_options_are_overwriten_by_user_options - Rails::Generators.options[:with_options] = { :generate => false } + Rails::Generators.options[:with_options] = { generate: false } self.class.class_eval(<<-end_eval, __FILE__, __LINE__ + 1) class WithOptionsGenerator < Rails::Generators::Base @@ -186,7 +186,7 @@ class GeneratorsTest < Rails::Generators::TestCase File.open(template, 'w'){ |f| f.write "empty" } capture(:stdout) do - Rails::Generators.invoke :model, ["user"], :destination_root => destination_root + Rails::Generators.invoke :model, ["user"], destination_root: destination_root end assert_file "app/models/user.rb" do |content| diff --git a/railties/test/initializable_test.rb b/railties/test/initializable_test.rb index c84c7f204c..16e259be5d 100644 --- a/railties/test/initializable_test.rb +++ b/railties/test/initializable_test.rb @@ -43,17 +43,17 @@ module InitializableTests class Child < Parent include Rails::Initializable - initializer :three, :before => :one do + initializer :three, before: :one do $arr << 3 end - initializer :four, :after => :one, :before => :two do + initializer :four, after: :one, before: :two do $arr << 4 end end class Parent - initializer :five, :before => :one do + initializer :five, before: :one do $arr << 5 end end @@ -61,7 +61,7 @@ module InitializableTests class Instance include Rails::Initializable - initializer :one, :group => :assets do + initializer :one, group: :assets do $arr << 1 end @@ -69,7 +69,7 @@ module InitializableTests $arr << 2 end - initializer :three, :group => :all do + initializer :three, group: :all do $arr << 3 end @@ -90,11 +90,11 @@ module InitializableTests class MoreInitializers include Rails::Initializable - initializer :startup, :before => :last do + initializer :startup, before: :last do $arr << 3 end - initializer :terminate, :after => :first, :before => :startup do + initializer :terminate, after: :first, before: :startup do $arr << two end @@ -134,11 +134,11 @@ module InitializableTests class PluginB include Rails::Initializable - initializer "plugin_b.startup", :after => "plugin_a.startup" do + initializer "plugin_b.startup", after: "plugin_a.startup" do $arr << 2 end - initializer "plugin_b.terminate", :before => "plugin_a.terminate" do + initializer "plugin_b.terminate", before: "plugin_a.terminate" do $arr << 3 end end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index 0f36eb67e5..e59488f97d 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -113,14 +113,14 @@ module TestHelpers routes = File.read("#{app_path}/config/routes.rb") if routes =~ /(\n\s*end\s*)\Z/ File.open("#{app_path}/config/routes.rb", 'w') do |f| - f.puts $` + "\nmatch ':controller(/:action(/:id))(.:format)', :via => :all\n" + $1 + f.puts $` + "\nmatch ':controller(/:action(/:id))(.:format)', via: :all\n" + $1 end end add_to_config <<-RUBY config.eager_load = false config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - config.session_store :cookie_store, :key => "_myapp_session" + config.session_store :cookie_store, key: "_myapp_session" config.active_support.deprecation = :log config.action_controller.allow_forgery_protection = false RUBY @@ -139,7 +139,7 @@ module TestHelpers app = Class.new(Rails::Application) app.config.eager_load = false app.config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" - app.config.session_store :cookie_store, :key => "_myapp_session" + app.config.session_store :cookie_store, key: "_myapp_session" app.config.active_support.deprecation = :log yield app if block_given? @@ -157,7 +157,7 @@ module TestHelpers controller :foo, <<-RUBY class FooController < ApplicationController def index - render :text => "foo" + render text: "foo" end end RUBY diff --git a/railties/test/paths_test.rb b/railties/test/paths_test.rb index 76ff3ec3e4..12f18b9dbf 100644 --- a/railties/test/paths_test.rb +++ b/railties/test/paths_test.rb @@ -32,7 +32,7 @@ class PathsTest < ActiveSupport::TestCase end test "creating a root level path with options" do - @root.add "app", :with => "/foo/bar" + @root.add "app", with: "/foo/bar" assert_equal ["/foo/bar"], @root["app"].to_a end @@ -52,18 +52,18 @@ class PathsTest < ActiveSupport::TestCase test "creating a child level path with option" do @root.add "app" - @root.add "app/models", :with => "/foo/bar/baz" + @root.add "app/models", with: "/foo/bar/baz" assert_equal ["/foo/bar/baz"], @root["app/models"].to_a end test "child level paths are relative from the root" do @root.add "app" - @root.add "app/models", :with => "baz" + @root.add "app/models", with: "baz" assert_equal ["/foo/bar/baz"], @root["app/models"].to_a end test "adding multiple physical paths as an array" do - @root.add "app", :with => ["/app", "/app2"] + @root.add "app", with: ["/app", "/app2"] assert_equal ["/app", "/app2"], @root["app"].to_a end @@ -92,7 +92,7 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path that should be autoloaded only once" do - @root.add "app", :with => "/app" + @root.add "app", with: "/app" @root["app"].autoload_once! assert @root["app"].autoload_once? assert @root.autoload_once.include?(@root["app"].expanded.first) @@ -109,13 +109,13 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path without assignment and specify it should be loaded only once" do - @root.add "app", :with => "/app", :autoload_once => true + @root.add "app", with: "/app", autoload_once: true assert @root["app"].autoload_once? assert @root.autoload_once.include?("/app") end test "it is possible to add multiple paths without assignment and specify it should be loaded only once" do - @root.add "app", :with => ["/app", "/app2"], :autoload_once => true + @root.add "app", with: ["/app", "/app2"], autoload_once: true assert @root["app"].autoload_once? assert @root.autoload_once.include?("/app") assert @root.autoload_once.include?("/app2") @@ -153,20 +153,20 @@ class PathsTest < ActiveSupport::TestCase end test "it is possible to add a path without assignment and mark it as eager" do - @root.add "app", :with => "/app", :eager_load => true + @root.add "app", with: "/app", eager_load: true assert @root["app"].eager_load? assert @root.eager_load.include?("/app") end test "it is possible to add multiple paths without assignment and mark them as eager" do - @root.add "app", :with => ["/app", "/app2"], :eager_load => true + @root.add "app", with: ["/app", "/app2"], eager_load: true assert @root["app"].eager_load? assert @root.eager_load.include?("/app") assert @root.eager_load.include?("/app2") end test "it is possible to create a path without assignment and mark it both as eager and load once" do - @root.add "app", :with => "/app", :eager_load => true, :autoload_once => true + @root.add "app", with: "/app", eager_load: true, autoload_once: true assert @root["app"].eager_load? assert @root["app"].autoload_once? assert @root.eager_load.include?("/app") @@ -194,12 +194,12 @@ class PathsTest < ActiveSupport::TestCase end test "it should be possible to override a path's default glob without assignment" do - @root.add "app", :with => "/app", :glob => "*.rb" + @root.add "app", with: "/app", glob: "*.rb" assert_equal "*.rb", @root["app"].glob end test "it should be possible to replace a path and persist the original paths glob" do - @root.add "app", :glob => "*.rb" + @root.add "app", glob: "*.rb" @root["app"] = "app2" assert_equal ["/foo/bar/app2"], @root["app"].to_a assert_equal "*.rb", @root["app"].glob @@ -213,7 +213,7 @@ class PathsTest < ActiveSupport::TestCase end test "a path can be added to the load path on creation" do - @root.add "app", :with => "/app", :load_path => true + @root.add "app", with: "/app", load_path: true assert @root["app"].load_path? assert_equal ["/app"], @root.load_paths end @@ -226,7 +226,7 @@ class PathsTest < ActiveSupport::TestCase end test "a path can be marked as autoload on creation" do - @root.add "app", :with => "/app", :autoload => true + @root.add "app", with: "/app", autoload: true assert @root["app"].autoload? assert_equal ["/app"], @root.autoload_paths end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index cfb32b7d35..08fcddd4bf 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -21,19 +21,19 @@ class InfoControllerTest < ActionController::TestCase end test "info controller does not allow remote requests" do - @controller.stubs(:local_request? => false) + @controller.stubs(local_request?: false) get :properties assert_response :forbidden end test "info controller renders an error message when request was forbidden" do - @controller.stubs(:local_request? => false) + @controller.stubs(local_request?: false) get :properties assert_select 'p' end test "info controller allows requests when all requests are considered local" do - @controller.stubs(:local_request? => true) + @controller.stubs(local_request?: true) get :properties assert_response :success end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index e52b3efdab..71bb34faf5 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -285,8 +285,8 @@ module RailtiesTest @plugin.write "config/routes.rb", <<-RUBY Rails.application.routes.draw do - get 'foo', :to => 'bar#index' - get 'bar', :to => 'bar#index' + get 'foo', to: 'bar#index' + get 'bar', to: 'bar#index' end RUBY @@ -366,7 +366,7 @@ YAML Rails.application.routes.draw do namespace :admin do namespace :foo do - get "bar", :to => "bar#index" + get "bar", to: "bar#index" end end end @@ -375,7 +375,7 @@ YAML @plugin.write "app/controllers/admin/foo/bar_controller.rb", <<-RUBY class Admin::Foo::BarController < ApplicationController def index - render :text => "Rendered from namespace" + render text: "Rendered from namespace" end end RUBY @@ -487,14 +487,14 @@ YAML controller "foo", <<-RUBY class FooController < ActionController::Base def index - render :text => params[:username] + render text: params[:username] end end RUBY @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - root :to => "foo#index" + root to: "foo#index" end RUBY @@ -608,14 +608,14 @@ YAML app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - get "/bar" => "bar#index", :as => "bar" - mount Bukkits::Engine => "/bukkits", :as => "bukkits" + get "/bar" => "bar#index", as: "bar" + mount Bukkits::Engine => "/bukkits", as: "bukkits" end RUBY @plugin.write "config/routes.rb", <<-RUBY Bukkits::Engine.routes.draw do - get "/foo" => "foo#index", :as => "foo" + get "/foo" => "foo#index", as: "foo" get "/foo/show" => "foo#show" get "/from_app" => "foo#from_app" get "/routes_helpers_in_view" => "foo#routes_helpers_in_view" @@ -643,23 +643,23 @@ YAML @plugin.write "app/controllers/bukkits/foo_controller.rb", <<-RUBY class Bukkits::FooController < ActionController::Base def index - render :inline => "<%= help_the_engine %>" + render inline: "<%= help_the_engine %>" end def show - render :text => foo_path + render text: foo_path end def from_app - render :inline => "<%= (self.respond_to?(:bar_path) || self.respond_to?(:something)) %>" + render inline: "<%= (self.respond_to?(:bar_path) || self.respond_to?(:something)) %>" end def routes_helpers_in_view - render :inline => "<%= foo_path %>, <%= main_app.bar_path %>" + render :inline "<%= foo_path %>, <%= main_app.bar_path %>" end def polymorphic_path_without_namespace - render :text => polymorphic_path(Post.new) + render text: polymorphic_path(Post.new) end end RUBY @@ -726,7 +726,7 @@ YAML app_file "config/routes.rb", <<-RUBY AppTemplate::Application.routes.draw do - mount Bukkits::Engine => "/bukkits", :as => "bukkits" + mount Bukkits::Engine => "/bukkits", as: "bukkits" end RUBY @@ -1033,11 +1033,11 @@ YAML controller "main", <<-RUBY class MainController < ActionController::Base def foo - render :inline => '<%= render :partial => "shared/foo" %>' + render inline: '<%= render :partial => "shared/foo" %>' end def bar - render :inline => '<%= render :partial => "shared/bar" %>' + render inline: '<%= render :partial => "shared/bar" %>' end end RUBY @@ -1113,7 +1113,7 @@ YAML controller "main", <<-RUBY class MainController < ActionController::Base def foo - render :inline => '<%= render :partial => "shared/foo" %>' + render inline: '<%= render :partial => "shared/foo" %>' end end RUBY @@ -1167,7 +1167,7 @@ YAML fullpath: \#{request.fullpath} path: \#{request.path} TEXT - render :text => text + render text: text end end end @@ -1205,7 +1205,7 @@ YAML app_file "app/controllers/bar_controller.rb", <<-RUBY class BarController < ApplicationController def index - render :text => bukkits.bukkit_path + render text: bukkits.bukkit_path end end RUBY @@ -1227,7 +1227,7 @@ YAML @plugin.write "app/controllers/bukkits/bukkit_controller.rb", <<-RUBY class Bukkits::BukkitController < ActionController::Base def index - render :text => main_app.bar_path + render text: main_app.bar_path end end RUBY diff --git a/railties/test/railties/generators_test.rb b/railties/test/railties/generators_test.rb index c90b795d59..0abb2b7578 100644 --- a/railties/test/railties/generators_test.rb +++ b/railties/test/railties/generators_test.rb @@ -46,7 +46,7 @@ module RailtiesTests f.write <<-GEMFILE.gsub(/^ {12}/, '') source "http://rubygems.org" - gem 'rails', :path => '#{RAILS_FRAMEWORK_ROOT}' + gem 'rails', path: '#{RAILS_FRAMEWORK_ROOT}' gem 'sqlite3' GEMFILE end diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb index bd13c3aba3..a1c52f01dc 100644 --- a/railties/test/railties/mounted_engine_test.rb +++ b/railties/test/railties/mounted_engine_test.rb @@ -42,14 +42,14 @@ module ApplicationTests @simple_plugin.write "config/routes.rb", <<-RUBY Weblog::Engine.routes.draw do - get '/weblog' => "weblogs#index", :as => 'weblogs' + get '/weblog' => "weblogs#index", as: 'weblogs' end RUBY @simple_plugin.write "app/controllers/weblogs_controller.rb", <<-RUBY class WeblogsController < ActionController::Base def index - render :text => request.url + render text: request.url end end RUBY @@ -86,9 +86,9 @@ module ApplicationTests @plugin.write "config/routes.rb", <<-RUBY Blog::Engine.routes.draw do resources :posts - get '/generate_application_route', :to => 'posts#generate_application_route' - get '/application_route_in_view', :to => 'posts#application_route_in_view' - get '/engine_polymorphic_path', :to => 'posts#engine_polymorphic_path' + get '/generate_application_route', to: 'posts#generate_application_route' + get '/application_route_in_view', to: 'posts#application_route_in_view' + get '/engine_polymorphic_path', to: 'posts#engine_polymorphic_path' end RUBY @@ -96,22 +96,22 @@ module ApplicationTests module Blog class PostsController < ActionController::Base def index - render :text => blog.post_path(1) + render text: blog.post_path(1) end def generate_application_route - path = main_app.url_for(:controller => "/main", - :action => "index", - :only_path => true) - render :text => path + path = main_app.url_for(controller: "/main", + action: "index", + only_path: true) + render text: path end def application_route_in_view - render :inline => "<%= main_app.root_path %>" + render inline: "<%= main_app.root_path %>" end def engine_polymorphic_path - render :text => polymorphic_path(Post.new) + render text: polymorphic_path(Post.new) end end end @@ -120,31 +120,31 @@ module ApplicationTests app_file "app/controllers/application_generating_controller.rb", <<-RUBY class ApplicationGeneratingController < ActionController::Base def engine_route - render :text => blog.posts_path + render text: blog.posts_path end def engine_route_in_view - render :inline => "<%= blog.posts_path %>" + render inline: "<%= blog.posts_path %>" end def weblog_engine_route - render :text => weblog.weblogs_path + render text: weblog.weblogs_path end def weblog_engine_route_in_view - render :inline => "<%= weblog.weblogs_path %>" + render inline: "<%= weblog.weblogs_path %>" end def url_for_engine_route - render :text => blog.url_for(:controller => "blog/posts", :action => "index", :user => "john", :only_path => true) + render text: blog.url_for(controller: "blog/posts", action: "index", user: "john", only_path: true) end def polymorphic_route - render :text => polymorphic_url([blog, Blog::Post.new]) + render text: polymorphic_url([blog, Blog::Post.new]) end def application_polymorphic_path - render :text => polymorphic_path(Blog::Post.new) + render text: polymorphic_path(Blog::Post.new) end end RUBY -- cgit v1.2.3 From 4e8cf43ff9e642ba5ef0dd0f54e5eb2409e160ca Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 14 Oct 2012 10:20:07 -0700 Subject: Fix typo in #7941 --- railties/test/railties/engine_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 71bb34faf5..fcbe7b6cda 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -655,7 +655,7 @@ YAML end def routes_helpers_in_view - render :inline "<%= foo_path %>, <%= main_app.bar_path %>" + render inline: "<%= foo_path %>, <%= main_app.bar_path %>" end def polymorphic_path_without_namespace -- cgit v1.2.3 From 7dba1599d9092a8362956a3fab23b2c60eedea63 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Oct 2012 09:51:20 -0500 Subject: Remove old asset_path from rails config --- railties/lib/rails/application/configuration.rb | 6 +----- railties/test/application/configuration_test.rb | 20 -------------------- 2 files changed, 1 insertion(+), 25 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index a7a35c2685..6b9cbd8cd1 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -6,7 +6,7 @@ require 'rails/engine/configuration' module Rails class Application class Configuration < ::Rails::Engine::Configuration - attr_accessor :asset_host, :asset_path, :assets, :autoflush_log, + attr_accessor :asset_host, :assets, :autoflush_log, :cache_classes, :cache_store, :consider_all_requests_local, :console, :eager_load, :exceptions_app, :file_watcher, :filter_parameters, :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags, @@ -64,10 +64,6 @@ module Rails @assets.logger = nil end - def compiled_asset_path - "/" - end - def encoding=(value) @encoding = value silence_warnings do diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 07d47dc67b..3ca0889cf5 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -162,11 +162,6 @@ module ApplicationTests assert AppTemplate::Application, AppTemplate::Application.config.eager_load_namespaces end - test "asset_path defaults to nil for application" do - require "#{app_path}/config/environment" - assert_equal nil, AppTemplate::Application.config.asset_path - end - test "the application can be eager loaded even when there are no frameworks" do FileUtils.rm_rf("#{app_path}/config/environments") add_to_config <<-RUBY @@ -441,21 +436,6 @@ module ApplicationTests end end - test "config.asset_path is not passed through env" do - make_basic_app do |app| - app.config.asset_path = "/omg%s" - end - - class ::OmgController < ActionController::Base - def index - render :inline => "<%= image_path('foo.jpg') %>" - end - end - - get "/" - assert_equal "/omg/images/foo.jpg", last_response.body - end - test "config.action_view.cache_template_loading with cache_classes default" do add_to_config "config.cache_classes = true" require "#{app_path}/config/environment" -- cgit v1.2.3 From 8d7fc73e98e3e70d8ded7f5936f7b69ae3de56b2 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Oct 2012 10:22:22 -0500 Subject: Use sprockets-rails branch for now --- railties/lib/rails/generators/app_base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index e761e26b04..0b922d29a4 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -195,7 +195,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails' + gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'new-asset-url-api' gem 'sass-rails', github: 'rails/sass-rails' gem 'coffee-rails', github: 'rails/coffee-rails' @@ -209,7 +209,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails' + gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'new-asset-url-api' gem 'sass-rails', '~> 4.0.0.beta' gem 'coffee-rails', '~> 4.0.0.beta' -- cgit v1.2.3 From eafc2b0580ab7cbea12224746c9047f0cca11e2c Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Oct 2012 11:46:05 -0500 Subject: Use sprockets-rails master --- railties/lib/rails/generators/app_base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 0b922d29a4..e761e26b04 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -195,7 +195,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'new-asset-url-api' + gem 'sprockets-rails', github: 'rails/sprockets-rails' gem 'sass-rails', github: 'rails/sass-rails' gem 'coffee-rails', github: 'rails/coffee-rails' @@ -209,7 +209,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails', branch: 'new-asset-url-api' + gem 'sprockets-rails', github: 'rails/sprockets-rails' gem 'sass-rails', '~> 4.0.0.beta' gem 'coffee-rails', '~> 4.0.0.beta' -- cgit v1.2.3 From b8c7e31a573315b5b718ccf45f3197d6250ac4a2 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 15 Oct 2012 18:22:12 -0500 Subject: Switch to new sprockets-rails plugin --- railties/lib/rails/generators/app_base.rb | 4 +- .../config/environments/development.rb.tt | 3 - .../templates/config/environments/production.rb.tt | 5 +- railties/test/application/assets_test.rb | 178 ++++++--------------- railties/test/generators/app_generator_test.rb | 3 +- 5 files changed, 59 insertions(+), 134 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index e761e26b04..5373eeed00 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -195,7 +195,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails' + gem 'sprockets-rails', github: 'josh/sprockets-rails' gem 'sass-rails', github: 'rails/sass-rails' gem 'coffee-rails', github: 'rails/coffee-rails' @@ -209,7 +209,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'rails/sprockets-rails' + gem 'sprockets-rails', github: 'josh/sprockets-rails' gem 'sass-rails', '~> 4.0.0.beta' gem 'coffee-rails', '~> 4.0.0.beta' diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index 6b5b3a0b1f..bd0a0d44b8 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -32,9 +32,6 @@ <%- end -%> <%- unless options.skip_sprockets? -%> - # Do not compress assets. - config.assets.compress = false - # Debug mode disables concatenation and preprocessing of assets. config.assets.debug = true <%- end -%> diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index 8aaaba628c..14422e275e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -24,7 +24,8 @@ <%- unless options.skip_sprockets? -%> # Compress JavaScripts and CSS. - config.assets.compress = true + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass # Don't fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false @@ -61,7 +62,7 @@ <%- end -%> # 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. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable threaded mode. diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 2506d19e6d..1311194ea6 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- require 'isolation/abstract_unit' require 'rack/test' +require 'active_support/json' module ApplicationTests class AssetsTest < ActiveSupport::TestCase @@ -27,12 +28,12 @@ module ApplicationTests def clean_assets! quietly do - assert Dir.chdir(app_path) { system('bundle exec rake assets:clean') } + assert Dir.chdir(app_path) { system('bundle exec rake assets:clobber') } end end def assert_file_exists(filename) - assert File.exists?(filename), "missing #{filename}" + assert Dir[filename].first, "missing #{filename}" end def assert_no_file_exists(filename) @@ -75,12 +76,10 @@ module ApplicationTests precompile! files = Dir["#{app_path}/public/assets/application-*.js"] - files << Dir["#{app_path}/public/assets/application.js"].first files << Dir["#{app_path}/public/assets/foo/application-*.js"].first - files << Dir["#{app_path}/public/assets/foo/application.js"].first files.each do |file| assert_not_nil file, "Expected application.js asset to be generated, but none found" - assert_equal "alert();", File.read(file) + assert_equal "alert();\n", File.read(file) end end @@ -108,21 +107,26 @@ module ApplicationTests precompile! + images_should_compile = ["a-*.png", "happyface-*.png", "happy_face-*.png", "happy.face-*.png", + "happy-face-*.png", "happy.happy_face-*.png", "happy_happy.face-*.png", + "happy.happy.face-*.png", "-happy-*.png", "-happy.face-*.png", + "_happy.face-*.png", "_happy-*.png"] + images_should_compile.each do |filename| assert_file_exists("#{app_path}/public/assets/#{filename}") end - assert_file_exists("#{app_path}/public/assets/application.js") - assert_file_exists("#{app_path}/public/assets/application.css") + assert_file_exists("#{app_path}/public/assets/application-*.js") + assert_file_exists("#{app_path}/public/assets/application-*.css") - assert_no_file_exists("#{app_path}/public/assets/someapplication.js") - assert_no_file_exists("#{app_path}/public/assets/someapplication.css") + assert_no_file_exists("#{app_path}/public/assets/someapplication-*.js") + assert_no_file_exists("#{app_path}/public/assets/someapplication-*.css") - assert_no_file_exists("#{app_path}/public/assets/something.min.js") - assert_no_file_exists("#{app_path}/public/assets/something.min.css") + assert_no_file_exists("#{app_path}/public/assets/something.min-*.js") + assert_no_file_exists("#{app_path}/public/assets/something.min-*.css") - assert_no_file_exists("#{app_path}/public/assets/something.else.js") - assert_no_file_exists("#{app_path}/public/assets/something.else.css") + assert_no_file_exists("#{app_path}/public/assets/something.else-*.js") + assert_no_file_exists("#{app_path}/public/assets/something.else-*.css") end test "precompile something.js for directory containing index file" do @@ -131,7 +135,7 @@ module ApplicationTests precompile! - assert_file_exists("#{app_path}/public/assets/something.js") + assert_file_exists("#{app_path}/public/assets/something-*.js") end test "asset pipeline should use a Sprockets::Index when config.assets.digest is true" do @@ -151,11 +155,11 @@ module ApplicationTests add_to_config "config.assets.digest = true" precompile! - manifest = "#{app_path}/public/assets/manifest.yml" + manifest = Dir["#{app_path}/public/assets/manifest-*.json"].first - assets = YAML.load_file(manifest) - assert_match(/application-([0-z]+)\.js/, assets["application.js"]) - assert_match(/application-([0-z]+)\.css/, assets["application.css"]) + assets = ActiveSupport::JSON.decode(File.read(manifest)) + assert_match(/application-([0-z]+)\.js/, assets["assets"]["application.js"]) + assert_match(/application-([0-z]+)\.css/, assets["assets"]["application.css"]) end test "the manifest file should be saved by default in the same assets folder" do @@ -166,26 +170,9 @@ module ApplicationTests precompile! - manifest = "#{app_path}/public/x/manifest.yml" - assets = YAML.load_file(manifest) - assert_match(/application-([0-z]+)\.js/, assets["application.js"]) - end - - test "precompile does not append asset digests when config.assets.digest is false" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" - app_file "app/assets/javascripts/application.js", "alert();" - add_to_config "config.assets.digest = false" - - precompile! - - assert_file_exists("#{app_path}/public/assets/application.js") - assert_file_exists("#{app_path}/public/assets/application.css") - - manifest = "#{app_path}/public/assets/manifest.yml" - - assets = YAML.load_file(manifest) - assert_equal "application.js", assets["application.js"] - assert_equal "application.css", assets["application.css"] + manifest = Dir["#{app_path}/public/x/manifest-*.json"].first + assets = ActiveSupport::JSON.decode(File.read(manifest)) + assert_match(/application-([0-z]+)\.js/, assets["assets"]["application.js"]) end test "assets do not require any assets group gem when manifest file is present" do @@ -195,9 +182,9 @@ module ApplicationTests ENV["RAILS_ENV"] = "production" precompile! - manifest = "#{app_path}/public/assets/manifest.yml" - assets = YAML.load_file(manifest) - asset_path = assets["application.js"] + manifest = Dir["#{app_path}/public/assets/manifest-*.json"].first + assets = ActiveSupport::JSON.decode(File.read(manifest)) + asset_path = assets["assets"]["application.js"] require "#{app_path}/config/environment" @@ -208,58 +195,6 @@ module ApplicationTests assert !defined?(Uglifier) end - test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled" do - app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" - - app_file "config/routes.rb", <<-RUBY - AppTemplate::Application.routes.draw do - get '/posts', :to => "posts#index" - end - RUBY - - ENV["RAILS_ENV"] = "production" - precompile! - - # Create file after of precompile - app_file "app/assets/javascripts/app.js", "alert();" - - require "#{app_path}/config/environment" - class ::PostsController < ActionController::Base - def show_detailed_exceptions?() true end - end - - get '/posts' - assert_match(/AssetNotPrecompiledError/, last_response.body) - assert_match(/app\.js isn't precompiled/, last_response.body) - end - - test "assets raise AssetNotPrecompiledError when manifest file is present and requested file isn't precompiled if digest is disabled" do - app_file "app/views/posts/index.html.erb", "<%= javascript_include_tag 'app' %>" - add_to_config "config.assets.compile = false" - add_to_config "config.assets.digest = false" - - app_file "config/routes.rb", <<-RUBY - AppTemplate::Application.routes.draw do - get '/posts', :to => "posts#index" - end - RUBY - - ENV["RAILS_ENV"] = "production" - precompile! - - # Create file after of precompile - app_file "app/assets/javascripts/app.js", "alert();" - - require "#{app_path}/config/environment" - class ::PostsController < ActionController::Base - def show_detailed_exceptions?() true end - end - - get '/posts' - assert_match(/AssetNotPrecompiledError/, last_response.body) - assert_match(/app\.js isn't precompiled/, last_response.body) - end - test "precompile properly refers files referenced with asset_path and and run in the provided RAILS_ENV" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" # digest is default in false, we must enable it for test environment @@ -267,33 +202,32 @@ module ApplicationTests precompile!('RAILS_ENV=test') - file = Dir["#{app_path}/public/assets/application.css"].first - assert_match(/\/assets\/rails\.png/, File.read(file)) file = Dir["#{app_path}/public/assets/application-*.css"].first assert_match(/\/assets\/rails-([0-z]+)\.png/, File.read(file)) end - test "precompile shouldn't use the digests present in manifest.yml" do - app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" + test "precompile shouldn't use the digests present in manifest.json" do + app_file "app/assets/stylesheets/application.css.erb", "//= depend_on rails.png\np { url: <%= asset_path('rails.png') %> }" ENV["RAILS_ENV"] = "production" precompile! - manifest = "#{app_path}/public/assets/manifest.yml" - assets = YAML.load_file(manifest) - asset_path = assets["application.css"] + manifest = Dir["#{app_path}/public/assets/manifest-*.json"].first + assets = ActiveSupport::JSON.decode(File.read(manifest)) + asset_path = assets["assets"]["application.css"] - app_file "app/assets/images/rails.png", "image changed" + app_file "app/assets/images/rails.png", "p { url: change }" precompile! - assets = YAML.load_file(manifest) + assets = ActiveSupport::JSON.decode(File.read(manifest)) - assert_not_equal asset_path, assets["application.css"] + assert_not_equal asset_path, assets["assets"]["application.css"] end - test "precompile appends the md5 hash to files referenced with asset_path and run in production as default even using RAILS_GROUPS=assets" do + test "precompile appends the md5 hash to files referenced with asset_path and run in production with digest true" do app_file "app/assets/stylesheets/application.css.erb", "<%= asset_path('rails.png') %>" add_to_config "config.assets.compile = true" + add_to_config "config.assets.digest = true" ENV["RAILS_ENV"] = nil @@ -309,11 +243,16 @@ module ApplicationTests add_to_config "config.assets.precompile = [ /\.png$/, /application.(css|js)$/ ]" precompile! + + manifest = Dir["#{app_path}/public/assets/manifest-*.json"].first + assets = ActiveSupport::JSON.decode(File.read(manifest)) + assert asset_path = assets["assets"].find { |(k, v)| k !~ /rails.png/ && k =~ /.png/ }[1] + require "#{app_path}/config/environment" - get "/assets/#{URI.parser.escape(filename)}" + get "/assets/#{URI.parser.escape(asset_path)}" assert_match "not a image really", last_response.body - assert_file_exists("#{app_path}/public/assets/#{filename}") + assert_file_exists("#{app_path}/public/assets/#{asset_path}") end test "assets are cleaned up properly" do @@ -403,7 +342,7 @@ module ApplicationTests add_to_config "config.assets.digest = false" precompile! - assert_equal "Post;\n", File.read("#{app_path}/public/assets/application.js") + assert_equal "Post;\n", File.read(Dir["#{app_path}/public/assets/application-*.js"].first) end test "assets can't access model information when precompiling if not initializing the app" do @@ -415,7 +354,7 @@ module ApplicationTests add_to_config "config.assets.initialize_on_precompile = false" precompile! - assert_equal "NoPost;\n", File.read("#{app_path}/public/assets/application.js") + assert_equal "NoPost;\n", File.read(Dir["#{app_path}/public/assets/application-*.js"].first) end test "initialization on the assets group should set assets_dir" do @@ -449,7 +388,7 @@ module ApplicationTests clean_assets! - files = Dir["#{app_path}/public/production_assets/application.js"] + files = Dir["#{app_path}/public/production_assets/application-*.js"] assert_equal 0, files.length, "Expected application.js asset to be removed, but still exists" end @@ -471,7 +410,7 @@ module ApplicationTests add_to_config "config.asset_host = 'example.com'" precompile! - assert_match 'src="//example.com/assets/rails.png"', File.read("#{app_path}/public/assets/image_loader.js") + assert_match 'src="//example.com/assets/rails.png"', File.read(Dir["#{app_path}/public/assets/image_loader-*.js"].first) end test "asset paths should use RAILS_RELATIVE_URL_ROOT by default" do @@ -481,19 +420,7 @@ module ApplicationTests add_to_config "config.assets.precompile = %w{app.js}" precompile! - assert_match 'src="/sub/uri/assets/rails.png"', File.read("#{app_path}/public/assets/app.js") - end - - test "html assets are compiled when executing precompile" do - app_file "app/assets/pages/page.html.erb", "<%= javascript_include_tag :application %>" - ENV["RAILS_ENV"] = "production" - ENV["RAILS_GROUP"] = "assets" - - quietly do - Dir.chdir(app_path){ `bundle exec rake assets:precompile` } - end - - assert_file_exists("#{app_path}/public/assets/page.html") + assert_match 'src="/sub/uri/assets/rails.png"', File.read(Dir["#{app_path}/public/assets/app-*.js"].first) end test "assets:cache:clean should clean cache" do @@ -501,11 +428,10 @@ module ApplicationTests precompile! quietly do - Dir.chdir(app_path){ `bundle exec rake assets:cache:clean` } + Dir.chdir(app_path){ `bundle exec rake assets:clobber` } end - require "#{app_path}/config/environment" - assert_equal 0, Dir.entries(Rails.application.assets.cache.cache_path).size - 2 # reject [".", ".."] + assert !File.exist?("#{app_path}/tmp/cache/assets") end private diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index e5397bf4f3..3d1252505a 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -236,7 +236,8 @@ class AppGeneratorTest < Rails::Generators::TestCase end assert_file "config/environments/production.rb" do |content| assert_no_match(/config\.assets\.digest = true/, content) - assert_no_match(/config\.assets\.compress = true/, content) + assert_no_match(/config\.assets\.js_compressor = :uglifier/, content) + assert_no_match(/config\.assets\.css_compressor = :sass/, content) end assert_file "test/performance/browsing_test.rb" end -- cgit v1.2.3 From 117d5e3bbb2d24a1bd4f6d5e18f6fed87c4dc344 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 16 Oct 2012 14:17:41 -0500 Subject: Only compile non-js/css under app/assets by default --- railties/lib/rails/application/configuration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 9ada195dd3..7df517de71 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -50,7 +50,7 @@ module Rails @assets = ActiveSupport::OrderedOptions.new @assets.enabled = false @assets.paths = [] - @assets.precompile = [ Proc.new { |path| !%w(.js .css).include?(File.extname(path)) }, + @assets.precompile = [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) }, /(?:\/|\\|\A)application\.(css|js)$/ ] @assets.prefix = "/assets" @assets.version = '' -- cgit v1.2.3 From d88b65f986147d932b41370c4d4c56b6b8a09bd0 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Wed, 17 Oct 2012 21:51:37 -0500 Subject: Change back to official sprockets-rails --- railties/lib/rails/generators/app_base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 5373eeed00..e761e26b04 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -195,7 +195,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'josh/sprockets-rails' + gem 'sprockets-rails', github: 'rails/sprockets-rails' gem 'sass-rails', github: 'rails/sass-rails' gem 'coffee-rails', github: 'rails/coffee-rails' @@ -209,7 +209,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', github: 'josh/sprockets-rails' + gem 'sprockets-rails', github: 'rails/sprockets-rails' gem 'sass-rails', '~> 4.0.0.beta' gem 'coffee-rails', '~> 4.0.0.beta' -- cgit v1.2.3 From fc32ff4ee322d46c6658a6a2d484fd5f60c07178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Oct 2012 01:03:24 -0300 Subject: Now the Sprockets railtie lives in sprockets/railtie --- railties/lib/rails/all.rb | 2 +- railties/lib/rails/generators/rails/app/templates/config/application.rb | 2 +- .../rails/generators/rails/plugin_new/templates/rails/application.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb index eabe566829..6c9c53fc69 100644 --- a/railties/lib/rails/all.rb +++ b/railties/lib/rails/all.rb @@ -5,7 +5,7 @@ require "rails" action_controller action_mailer rails/test_unit - sprockets/rails + sprockets ).each do |framework| begin require "#{framework}/railtie" diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index fb43c90e21..5f15c973c6 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -7,7 +7,7 @@ require 'rails/all' <%= comment_if :skip_active_record %>require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" -<%= comment_if :skip_sprockets %>require "sprockets/rails/railtie" +<%= comment_if :skip_sprockets %>require "sprockets/railtie" <%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" <% end -%> diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb b/railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb index 2f9b7fc962..8a8ba04a70 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb +++ b/railties/lib/rails/generators/rails/plugin_new/templates/rails/application.rb @@ -7,7 +7,7 @@ require 'rails/all' <%= comment_if :skip_active_record %>require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" -<%= comment_if :skip_sprockets %>require "sprockets/rails/railtie" +<%= comment_if :skip_sprockets %>require "sprockets/railtie" <%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" <% end -%> -- cgit v1.2.3 From 12fb9372bf75d73481b3323b2c84d1851f5d6304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Oct 2012 14:31:12 -0300 Subject: Fix the app_generator and plugin_new tests --- railties/lib/rails/generators/app_base.rb | 3 +++ railties/test/generators/app_generator_test.rb | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index e761e26b04..09ce81d0f9 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -138,12 +138,14 @@ module Rails end def rails_gemfile_entry + # TODO remove sprockets-rails from this list when the version 2.0 is realease if options.dev? <<-GEMFILE.strip_heredoc gem 'rails', path: '#{Rails::Generators::RAILS_DEV_PATH}' gem 'journey', github: 'rails/journey' gem 'arel', github: 'rails/arel' gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' + gem 'sprockets-rails', github: 'rails/sprockets-rails' GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc @@ -151,6 +153,7 @@ module Rails gem 'journey', github: 'rails/journey' gem 'arel', github: 'rails/arel' gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' + gem 'sprockets-rails', github: 'rails/sprockets-rails' GEMFILE else <<-GEMFILE.strip_heredoc diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 3d1252505a..62e1f3531e 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -223,7 +223,7 @@ class AppGeneratorTest < Rails::Generators::TestCase def test_generator_if_skip_sprockets_is_given run_generator [destination_root, "--skip-sprockets"] assert_file "config/application.rb" do |content| - assert_match(/#\s+require\s+["']sprockets\/rails\/railtie["']/, content) + assert_match(/#\s+require\s+["']sprockets\/railtie["']/, content) assert_no_match(/config\.assets\.enabled = true/, content) end assert_file "Gemfile" do |content| -- cgit v1.2.3 From 90733e70d7d7a41bc7d5b0bebd357dd4950c833e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Oct 2012 14:31:52 -0300 Subject: Don't use action_controller.perform_caching to enable rack-rack. Setting the action_dispatch.rack_cache options to true or a hash should be the way to enable it. --- railties/lib/rails/application.rb | 2 +- railties/test/application/middleware/cache_test.rb | 14 ++++++++++++-- railties/test/application/middleware_test.rb | 5 +---- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index eff5bbbdd6..9ef001c7d0 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -286,7 +286,7 @@ module Rails def default_middleware_stack #:nodoc: ActionDispatch::MiddlewareStack.new.tap do |middleware| app = self - if rack_cache = config.action_controller.perform_caching && config.action_dispatch.rack_cache + if rack_cache = config.action_dispatch.rack_cache begin require 'rack/cache' rescue LoadError => error diff --git a/railties/test/application/middleware/cache_test.rb b/railties/test/application/middleware/cache_test.rb index 9b6c76e7aa..c99666d7e4 100644 --- a/railties/test/application/middleware/cache_test.rb +++ b/railties/test/application/middleware/cache_test.rb @@ -49,8 +49,6 @@ module ApplicationTests get ':controller(/:action)' end RUBY - - add_to_config "config.action_dispatch.rack_cache = true" end def test_cache_keeps_if_modified_since @@ -80,6 +78,8 @@ module ApplicationTests def test_cache_works_with_expires simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_header" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "max-age=10, public", last_response.headers["Cache-Control"] @@ -96,6 +96,8 @@ module ApplicationTests def test_cache_works_with_expires_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_header", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "private, max-age=10", last_response.headers["Cache-Control"] @@ -110,6 +112,8 @@ module ApplicationTests def test_cache_works_with_etags simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_etag" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "public", last_response.headers["Cache-Control"] @@ -125,6 +129,8 @@ module ApplicationTests def test_cache_works_with_etags_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_etag", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] @@ -140,6 +146,8 @@ module ApplicationTests def test_cache_works_with_last_modified simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_last_modified" assert_equal "miss, store", last_response.headers["X-Rack-Cache"] assert_equal "public", last_response.headers["Cache-Control"] @@ -155,6 +163,8 @@ module ApplicationTests def test_cache_works_with_last_modified_private simple_controller + add_to_config "config.action_dispatch.rack_cache = true" + get "/expires/expires_last_modified", private: true assert_equal "miss", last_response.headers["X-Rack-Cache"] assert_equal "must-revalidate, private, max-age=0", last_response.headers["Cache-Control"] diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index c03d35e926..c5a0d02fe1 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -57,15 +57,12 @@ module ApplicationTests end test "Rack::Cache is not included by default" do - add_to_config "config.action_controller.perform_caching = true" - boot! assert !middleware.include?("Rack::Cache"), "Rack::Cache is not included in the default stack unless you set config.action_dispatch.rack_cache" end - test "Rack::Cache is present when action_controller.perform_caching is set and action_dispatch.rack_cache is set" do - add_to_config "config.action_controller.perform_caching = true" + test "Rack::Cache is present when action_dispatch.rack_cache is set" do add_to_config "config.action_dispatch.rack_cache = true" boot! -- cgit v1.2.3 From ff79df004c3cd1b3eb9d63e20f991331d35e51b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Thu, 18 Oct 2012 14:33:40 -0300 Subject: Remove warning setting eager_load --- railties/test/application/url_generation_test.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'railties') diff --git a/railties/test/application/url_generation_test.rb b/railties/test/application/url_generation_test.rb index 4ecb94b65e..2a48adae5c 100644 --- a/railties/test/application/url_generation_test.rb +++ b/railties/test/application/url_generation_test.rb @@ -17,6 +17,7 @@ module ApplicationTests config.secret_token = "3b7cd727ee24e8444053437c36cc66c4" config.session_store :cookie_store, key: "_myapp_session" config.active_support.deprecation = :log + config.eager_load = false end MyApp.initialize! -- cgit v1.2.3 From bfc6c17a87792012443e7b083e3e86810173c113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 19 Oct 2012 22:26:11 -0300 Subject: We don't need this anymore since we had a sprockets-rails release --- railties/lib/rails/generators/app_base.rb | 3 --- 1 file changed, 3 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 09ce81d0f9..e761e26b04 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -138,14 +138,12 @@ module Rails end def rails_gemfile_entry - # TODO remove sprockets-rails from this list when the version 2.0 is realease if options.dev? <<-GEMFILE.strip_heredoc gem 'rails', path: '#{Rails::Generators::RAILS_DEV_PATH}' gem 'journey', github: 'rails/journey' gem 'arel', github: 'rails/arel' gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' - gem 'sprockets-rails', github: 'rails/sprockets-rails' GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc @@ -153,7 +151,6 @@ module Rails gem 'journey', github: 'rails/journey' gem 'arel', github: 'rails/arel' gem 'activerecord-deprecated_finders', github: 'rails/activerecord-deprecated_finders' - gem 'sprockets-rails', github: 'rails/sprockets-rails' GEMFILE else <<-GEMFILE.strip_heredoc -- cgit v1.2.3