From 3def2d6113e552548119b3e5e459d2d8b3309d50 Mon Sep 17 00:00:00 2001 From: "Suraj N. Kurapati" Date: Fri, 6 Jan 2012 01:49:06 -0800 Subject: gemspec assumes that user kept all generated files This commit allows the user be lazy and not update their gemspec's `files` directive after deleting unwanted files from their generated Rails plugin. --- railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec index 8588e88077..82ffeebb86 100644 --- a/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin_new/templates/%name%.gemspec @@ -13,7 +13,7 @@ Gem::Specification.new do |s| s.summary = "TODO: Summary of <%= camelized %>." s.description = "TODO: Description of <%= camelized %>." - s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] <% unless options.skip_test_unit? -%> s.test_files = Dir["test/**/*"] <% end -%> -- cgit v1.2.3 From 0e49ef433093c0ed08c7df8609b0b9e3dae5150c Mon Sep 17 00:00:00 2001 From: Patrick Helm Date: Thu, 12 Apr 2012 16:25:28 +0200 Subject: Provided fix for calling rake tasks within mountable engines --- railties/lib/rails/engine.rb | 7 ++++++- railties/test/railties/engine_test.rb | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 131d6e5711..ceb8905c8f 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -603,7 +603,12 @@ module Rails desc "Copy migrations from #{railtie_name} to application" task :migrations do ENV["FROM"] = railtie_name - Rake::Task["railties:install:migrations"].invoke + if Rake::Task.task_defined?("railties:install:migrations") + Rake::Task["railties:install:migrations"].invoke + else + Rake::Task["app:railties:install:migrations"].invoke + end + end end end diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 5e93a8e783..1650a15080 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -112,6 +112,37 @@ module RailtiesTest end end + test "mountable engine should copy migrations within engine_path" do + @plugin.write "lib/bukkits.rb", <<-RUBY + module Bukkits + class Engine < ::Rails::Engine + isolate_namespace Bukkits + end + end + RUBY + + @plugin.write "db/migrate/0_add_first_name_to_users.rb", <<-RUBY + class AddFirstNameToUsers < ActiveRecord::Migration + end + RUBY + + @plugin.write "Rakefile", <<-RUBY + APP_RAKEFILE = '#{app_path}/Rakefile' + load 'rails/tasks/engine.rake' + RUBY + + add_to_config "ActiveRecord::Base.timestamped_migrations = false" + + boot_rails + + Dir.chdir(@plugin.path) do + output = `bundle exec rake app:bukkits:install:migrations` + assert File.exists?("#{app_path}/db/migrate/0_add_first_name_to_users.bukkits.rb") + assert_match(/Copied migration 0_add_first_name_to_users.bukkits.rb from bukkits/, output) + assert_equal 1, Dir["#{app_path}/db/migrate/*.rb"].length + end + end + test "no rake task without migrations" do boot_rails require 'rake' -- cgit v1.2.3 From 9ebfd634a71f7830e994f122bf09bdc6fe0ea17a Mon Sep 17 00:00:00 2001 From: Rodrigo Pavano Date: Tue, 1 May 2012 15:54:15 -0300 Subject: Removing unused local vars in Queue tests --- railties/test/application/queue_test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties') diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index ec809d7cc1..71b0c2bc38 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -32,7 +32,6 @@ module ApplicationTests test "in development mode, an enqueued job will be processed in a separate thread" do app("development") - current = Thread.current job = Struct.new(:origin, :target).new(Thread.current) def job.run @@ -48,7 +47,6 @@ module ApplicationTests test "in test mode, explicitly draining the queue will process it in a separate thread" do app("test") - current = Thread.current job = Struct.new(:origin, :target).new(Thread.current) def job.run -- cgit v1.2.3 From eb3bfe293663746f42bae00b3b516418822f9a81 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 2 May 2012 01:10:59 +0530 Subject: remove unused pguides rake task from railties --- railties/Rakefile | 9 --------- 1 file changed, 9 deletions(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index c4a91a1d36..d1331deac3 100755 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -60,12 +60,3 @@ task :release => :package do Rake::Gemcutter::Tasks.new(spec).define Rake::Task['gem:push'].invoke end - -desc "Publish the guides" -task :pguides => :generate_guides do - require 'rake/contrib/sshpublisher' - mkdir_p 'pkg' - `tar -czf pkg/guides.gz guides/output` - Rake::SshFilePublisher.new("web.rubyonrails.org", "/u/sites/guides.rubyonrails.org/public", "pkg", "guides.gz").upload - `ssh web.rubyonrails.org 'cd /u/sites/guides.rubyonrails.org/public/ && tar -xvzf guides.gz && mv guides/output/* . && rm -rf guides*'` -end -- cgit v1.2.3 From 17f2958d853ef0dbee1aa6fa6d7b89d1ca3d4352 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 1 May 2012 13:01:29 -0700 Subject: Use :github option in Gemfile and make hashes consistent --- railties/lib/rails/generators/app_base.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index b677e974c8..64d8ed0684 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -138,23 +138,23 @@ module Rails if options.dev? <<-GEMFILE.strip_heredoc gem 'rails', :path => '#{Rails::Generators::RAILS_DEV_PATH}' - gem 'journey', :git => 'https://github.com/rails/journey.git' - gem 'arel', :git => 'https://github.com/rails/arel.git' - gem 'active_record_deprecated_finders', :git => 'git://github.com/rails/active_record_deprecated_finders.git' + gem 'journey', :github => 'rails/journey' + gem 'arel', :github => 'rails/arel' + gem 'active_record_deprecated_finders', :github => 'rails/active_record_deprecated_finders' GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc - gem 'rails', :git => 'https://github.com/rails/rails.git' - gem 'journey', :git => 'https://github.com/rails/journey.git' - gem 'arel', :git => 'https://github.com/rails/arel.git' - gem 'active_record_deprecated_finders', :git => 'git://github.com/rails/active_record_deprecated_finders.git' + gem 'rails', :github => 'rails/rails' + gem 'journey', :github => 'rails/journey' + gem 'arel', :github => 'rails/arel' + gem 'active_record_deprecated_finders', :github => 'rails/active_record_deprecated_finders' GEMFILE else <<-GEMFILE.strip_heredoc gem 'rails', '#{Rails::VERSION::STRING}' # Bundle edge Rails instead: - # gem 'rails', :git => 'https://github.com/rails/rails.git' + # gem 'rails', :github => 'rails/rails' GEMFILE end end -- cgit v1.2.3 From ed10107fa1f1e9f1bfe84c53ea6dc74efdbfbfc7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 1 May 2012 16:25:03 -0700 Subject: Fix tests --- railties/test/generators/shared_generator_tests.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 92117855b7..33c6c0d856 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -110,7 +110,7 @@ module SharedGeneratorTests def test_edge_option generator([destination_root], :edge => true).expects(:bundle_command).with('install').once quietly { generator.invoke_all } - assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("https://github.com/rails/rails.git")}["']$} + assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:github\s+=>\s+["']#{Regexp.escape("rails/rails")}["']$} end def test_skip_gemfile -- cgit v1.2.3 From a6c41601fe7d39320cc44091952e360ea2bae726 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Tue, 1 May 2012 23:29:56 -0300 Subject: Build fix for plugin new generator change Related to a06a84bf77082a7435973fa1b6c8254fb410f243 --- railties/test/generators/plugin_new_generator_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 4bb5f04a79..6c31b80c7d 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -32,7 +32,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase content = capture(:stderr){ run_generator [File.join(destination_root, "things4.3")] } assert_equal "Invalid plugin name things4.3. Please give a name which use only alphabetic or numeric or \"_\" characters.\n", content - + content = capture(:stderr){ run_generator [File.join(destination_root, "43things")] } assert_equal "Invalid plugin name 43things. Please give a name which does not start with numbers.\n", content end @@ -211,7 +211,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_creating_gemspec run_generator assert_file "bukkits.gemspec", /s.name\s+= "bukkits"/ - assert_file "bukkits.gemspec", /s.files = Dir\["\{app,config,db,lib\}\/\*\*\/\*"\]/ + assert_file "bukkits.gemspec", /s.files = Dir\["\{app,config,db,lib\}\/\*\*\/\*", "MIT-LICENSE", "Rakefile", "README\.rdoc"\]/ assert_file "bukkits.gemspec", /s.test_files = Dir\["test\/\*\*\/\*"\]/ assert_file "bukkits.gemspec", /s.version\s+ = Bukkits::VERSION/ end -- cgit v1.2.3 From 5d685f9db77e05afe6fbf50ee77d1fb6f63aeaef Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Fri, 27 Apr 2012 11:28:53 +0400 Subject: Add Rails::DBConsole tests --- railties/lib/rails/commands/dbconsole.rb | 56 ++++++++------ railties/test/commands/dbconsole_test.rb | 128 +++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+), 22 deletions(-) create mode 100644 railties/test/commands/dbconsole_test.rb (limited to 'railties') diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 6fc127efae..25a8caeec3 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -5,12 +5,15 @@ require 'rbconfig' module Rails class DBConsole + attr_reader :arguments + def self.start(app) new(app).start end - def initialize(app) + def initialize(app, arguments = ARGV) @app = app + @arguments = arguments end def start @@ -31,8 +34,8 @@ module Rails options['header'] = h end - opt.parse!(ARGV) - abort opt.to_s unless (0..1).include?(ARGV.size) + opt.parse!(arguments) + abort opt.to_s unless (0..1).include?(arguments.size) end unless config = @app.config.database_configuration[Rails.env] @@ -40,20 +43,6 @@ module Rails end - def find_cmd(*commands) - dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR) - commands += commands.map{|cmd| "#{cmd}.exe"} if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ - - full_path_command = nil - found = commands.detect do |cmd| - dir = dirs_on_path.detect do |path| - full_path_command = File.join(path, cmd) - File.executable? full_path_command - end - end - found ? full_path_command : abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.") - end - case config["adapter"] when /^mysql/ args = { @@ -72,17 +61,17 @@ module Rails args << config['database'] - exec(find_cmd('mysql', 'mysql5'), *args) + find_cmd_and_exec(['mysql', 'mysql5'], *args) when "postgresql", "postgres" ENV['PGUSER'] = config["username"] if config["username"] ENV['PGHOST'] = config["host"] if config["host"] ENV['PGPORT'] = config["port"].to_s if config["port"] ENV['PGPASSWORD'] = config["password"].to_s if config["password"] && include_password - exec(find_cmd('psql'), config["database"]) + find_cmd_and_exec('psql', config["database"]) when "sqlite" - exec(find_cmd('sqlite'), config["database"]) + find_cmd_and_exec('sqlite', config["database"]) when "sqlite3" args = [] @@ -91,7 +80,7 @@ module Rails args << "-header" if options['header'] args << config['database'] - exec(find_cmd('sqlite3'), *args) + find_cmd_and_exec('sqlite3', *args) when "oracle", "oracle_enhanced" logon = "" @@ -102,12 +91,35 @@ module Rails logon << "@#{config['database']}" if config['database'] end - exec(find_cmd('sqlplus'), logon) + find_cmd_and_exec('sqlplus', logon) else abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!" end end + + protected + + def find_cmd_and_exec(commands, *args) + commands = Array(commands) + + dirs_on_path = ENV['PATH'].to_s.split(File::PATH_SEPARATOR) + commands += commands.map{|cmd| "#{cmd}.exe"} if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ + + full_path_command = nil + found = commands.detect do |cmd| + dir = dirs_on_path.detect do |path| + full_path_command = File.join(path, cmd) + File.executable? full_path_command + end + end + + if found + exec full_path_command, *args + else + abort("Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.") + end + end end end diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb new file mode 100644 index 0000000000..0bf417c014 --- /dev/null +++ b/railties/test/commands/dbconsole_test.rb @@ -0,0 +1,128 @@ +require 'abstract_unit' +require 'rails/commands/dbconsole' + +class Rails::DBConsoleTest < ActiveSupport::TestCase + def teardown + %w[PGUSER PGHOST PGPORT PGPASSWORD'].each{|key| ENV.delete(key)} + end + + def test_no_database_configured + start [], false + assert aborted + assert_match /No database is configured for the environment '\w+'/, output + end + + def test_mysql + dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], 'db') + start [], {adapter: 'mysql', database: 'db'} + assert !aborted + end + + def test_mysql_full + dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], '--host=locahost', '--port=1234', '--socket=socket', '--user=user', '--default-character-set=UTF-8', '-p', 'db') + start [], {adapter: 'mysql', database: 'db', host: 'locahost', port: 1234, socket: 'socket', username: 'user', password: 'qwerty', encoding: 'UTF-8'} + assert !aborted + end + + def test_mysql_include_password + dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], '--user=user', '--password=qwerty', 'db') + start ['-p'], {adapter: 'mysql', database: 'db', username: 'user', password: 'qwerty'} + assert !aborted + end + + def test_postgresql + dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') + start [], {adapter: 'postgresql', database: 'db'} + assert !aborted + end + + def test_postgresql_full + dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') + start [], {adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3', host: 'host', port: 5432} + assert !aborted + assert_equal 'user', ENV['PGUSER'] + assert_equal 'host', ENV['PGHOST'] + assert_equal '5432', ENV['PGPORT'] + assert_not_equal 'q1w2e3', ENV['PGPASSWORD'] + end + + def test_postgresql_include_password + dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') + start ['-p'], {adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3'} + assert !aborted + assert_equal 'user', ENV['PGUSER'] + assert_equal 'q1w2e3', ENV['PGPASSWORD'] + end + + def test_sqlite + dbconsole.expects(:find_cmd_and_exec).with('sqlite', 'db') + start [], {adapter: 'sqlite', database: 'db'} + assert !aborted + end + + def test_sqlite3 + dbconsole.expects(:find_cmd_and_exec).with('sqlite3', 'db') + start [], {adapter: 'sqlite3', database: 'db'} + assert !aborted + end + + def test_sqlite3_mode + dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-html', 'db') + start ['--mode', 'html'], {adapter: 'sqlite3', database: 'db'} + assert !aborted + end + + def test_sqlite3_header + dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-header', 'db') + start ['--header'], {adapter: 'sqlite3', database: 'db'} + assert !aborted + end + + def test_oracle + dbconsole.expects(:find_cmd_and_exec).with('sqlplus', 'user@db') + start [], {adapter: 'oracle', database: 'db', username: 'user', password: 'secret'} + assert !aborted + end + + def test_oracle_include_password + dbconsole.expects(:find_cmd_and_exec).with('sqlplus', 'user/secret@db') + start ['-p'], {adapter: 'oracle', database: 'db', username: 'user', password: 'secret'} + assert !aborted + end + + def test_unknown_command_line_client + start [], {adapter: 'unknown', database: 'db'} + assert aborted + assert_match /Unknown command-line client for db/, output + end + + private + attr_reader :aborted, :output + + def dbconsole + @dbconsole ||= Rails::DBConsole.new(app) + end + + def start(argv = [], database_configuration = {}) + dbconsole.stubs(arguments: argv) + app.config.stubs(database_configuration: { + Rails.env => database_configuration ? database_configuration.stringify_keys : database_configuration + }) + + @aborted = false + @output = capture(:stderr) do + begin + dbconsole.start + rescue SystemExit + @aborted = true + end + end + end + + def app + @app ||= begin + config = mock("config") + stub("app", config: config) + end + end +end -- cgit v1.2.3 From 5eb32af28b16cf8d26ce291232239892154227d4 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 2 May 2012 10:21:02 +0200 Subject: Use new hash syntax in generated Gemfile --- railties/lib/rails/generators/app_base.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 64d8ed0684..6df33d65e9 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -137,24 +137,24 @@ module Rails def rails_gemfile_entry 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 'active_record_deprecated_finders', :github => 'rails/active_record_deprecated_finders' + gem 'rails', path: '#{Rails::Generators::RAILS_DEV_PATH}' + gem 'journey', github: 'rails/journey' + gem 'arel', github: 'rails/arel' + gem 'active_record_deprecated_finders', github: 'rails/active_record_deprecated_finders' GEMFILE elsif options.edge? <<-GEMFILE.strip_heredoc - gem 'rails', :github => 'rails/rails' - gem 'journey', :github => 'rails/journey' - gem 'arel', :github => 'rails/arel' - gem 'active_record_deprecated_finders', :github => 'rails/active_record_deprecated_finders' + gem 'rails', github: 'rails/rails' + gem 'journey', github: 'rails/journey' + gem 'arel', github: 'rails/arel' + gem 'active_record_deprecated_finders', github: 'rails/active_record_deprecated_finders' GEMFILE else <<-GEMFILE.strip_heredoc gem 'rails', '#{Rails::VERSION::STRING}' # Bundle edge Rails instead: - # gem 'rails', :github => 'rails/rails' + # gem 'rails', github: 'rails/rails' GEMFILE end end @@ -194,9 +194,9 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git' - gem 'sass-rails', :git => 'https://github.com/rails/sass-rails.git' - gem 'coffee-rails', :git => 'https://github.com/rails/coffee-rails.git' + gem 'sprockets-rails', github: 'rails/sprockets-rails' + gem 'sass-rails', github: 'rails/sass-rails' + gem 'coffee-rails', github: 'rails/coffee-rails' # See https://github.com/sstephenson/execjs#readme for more supported runtimes #{javascript_runtime_gemfile_entry} @@ -208,7 +208,7 @@ module Rails # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sprockets-rails', :git => 'https://github.com/rails/sprockets-rails.git' + gem 'sprockets-rails', github: 'rails/sprockets-rails' gem 'sass-rails', '~> 4.0.0.beta' gem 'coffee-rails', '~> 4.0.0.beta' @@ -230,7 +230,7 @@ module Rails if defined?(JRUBY_VERSION) "gem 'therubyrhino'\n" else - "# gem 'therubyracer', :platform => :ruby\n" + "# gem 'therubyracer', platform: :ruby\n" end end -- cgit v1.2.3 From 84feca4aaafb597f8cc16c3a5c16ce7014d95ada Mon Sep 17 00:00:00 2001 From: "Roman V. Babenko" Date: Wed, 2 May 2012 13:36:16 +0300 Subject: Rakefile executable attributes and shebang lines has been removed --- railties/Rakefile | 1 - railties/lib/rails/generators/rails/app/templates/Rakefile | 1 - railties/lib/rails/generators/rails/plugin_new/templates/Rakefile | 1 - 3 files changed, 3 deletions(-) mode change 100755 => 100644 railties/Rakefile mode change 100755 => 100644 railties/lib/rails/generators/rails/app/templates/Rakefile mode change 100755 => 100644 railties/lib/rails/generators/rails/plugin_new/templates/Rakefile (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile old mode 100755 new mode 100644 index d1331deac3..108413235a --- a/railties/Rakefile +++ b/railties/Rakefile @@ -1,4 +1,3 @@ -#!/usr/bin/env rake require 'rake/testtask' require 'rubygems/package_task' diff --git a/railties/lib/rails/generators/rails/app/templates/Rakefile b/railties/lib/rails/generators/rails/app/templates/Rakefile old mode 100755 new mode 100644 index 4dc1023f1f..6eb23f68a3 --- a/railties/lib/rails/generators/rails/app/templates/Rakefile +++ b/railties/lib/rails/generators/rails/app/templates/Rakefile @@ -1,4 +1,3 @@ -#!/usr/bin/env rake # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. diff --git a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile old mode 100755 new mode 100644 index b7bc69d2e5..743036362e --- a/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin_new/templates/Rakefile @@ -1,4 +1,3 @@ -#!/usr/bin/env rake begin require 'bundler/setup' rescue LoadError -- cgit v1.2.3 From e17cc4d493e369217f216418287a5a0de084915d Mon Sep 17 00:00:00 2001 From: "Roman V. Babenko" Date: Wed, 2 May 2012 13:56:13 +0300 Subject: Gem cont presence checking has been removed --- railties/lib/rails/backtrace_cleaner.rb | 2 -- railties/test/backtrace_cleaner_test.rb | 32 +++++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb index 539f68a3be..8cc8eb1103 100644 --- a/railties/lib/rails/backtrace_cleaner.rb +++ b/railties/lib/rails/backtrace_cleaner.rb @@ -17,8 +17,6 @@ module Rails private def add_gem_filters - return unless defined?(Gem) - gems_paths = (Gem.path | [Gem.default_dir]).map { |p| Regexp.escape(p) } return if gems_paths.empty? diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index cbe7d35f6d..2dd74f8fd1 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -1,26 +1,24 @@ require 'abstract_unit' require 'rails/backtrace_cleaner' -if defined? Gem - class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase - def setup - @cleaner = Rails::BacktraceCleaner.new - end +class BacktraceCleanerVendorGemTest < ActiveSupport::TestCase + def setup + @cleaner = Rails::BacktraceCleaner.new + end + + test "should format installed gems correctly" do + @backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ] + @result = @cleaner.clean(@backtrace, :all) + assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] + end - test "should format installed gems correctly" do - @backtrace = [ "#{Gem.path[0]}/gems/nosuchgem-1.2.3/lib/foo.rb" ] + test "should format installed gems not in Gem.default_dir correctly" do + @target_dir = Gem.path.detect { |p| p != Gem.default_dir } + # skip this test if default_dir is the only directory on Gem.path + if @target_dir + @backtrace = [ "#{@target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ] @result = @cleaner.clean(@backtrace, :all) assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] end - - test "should format installed gems not in Gem.default_dir correctly" do - @target_dir = Gem.path.detect { |p| p != Gem.default_dir } - # skip this test if default_dir is the only directory on Gem.path - if @target_dir - @backtrace = [ "#{@target_dir}/gems/nosuchgem-1.2.3/lib/foo.rb" ] - @result = @cleaner.clean(@backtrace, :all) - assert_equal "nosuchgem (1.2.3) lib/foo.rb", @result[0] - end - end end end -- cgit v1.2.3 From 1206e88a7535d29487b416121c31b23762a12abd Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Wed, 2 May 2012 16:27:22 +0530 Subject: build fix for SharedGeneratorTests --- railties/test/generators/shared_generator_tests.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 33c6c0d856..325f9475e7 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -104,13 +104,13 @@ module SharedGeneratorTests 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+=>\s+["']#{Regexp.escape(rails_path)}["']$/ + assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+:\s+["']#{Regexp.escape(rails_path)}["']$/ end def test_edge_option 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+=>\s+["']#{Regexp.escape("rails/rails")}["']$} + assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:github\s+:\s+["']#{Regexp.escape("rails/rails")}["']$} end def test_skip_gemfile -- cgit v1.2.3 From 1cfa34f83e89d8b66bafa2eb866ed4e023a404ed Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Wed, 2 May 2012 17:31:29 +0530 Subject: Fix build for railties generators --- railties/test/generators/app_generator_test.rb | 2 +- railties/test/generators/shared_generator_tests.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 94983c504c..d13dc8d4ac 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -246,7 +246,7 @@ class AppGeneratorTest < Rails::Generators::TestCase if defined?(JRUBY_VERSION) assert_file "Gemfile", /gem\s+["']therubyrhino["']$/ else - assert_file "Gemfile", /# gem\s+["']therubyracer["']+, :platform => :ruby$/ + assert_file "Gemfile", /# gem\s+["']therubyracer["']+, platform: :ruby$/ end end diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 325f9475e7..e78e67725d 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -104,13 +104,13 @@ module SharedGeneratorTests 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+:\s+["']#{Regexp.escape(rails_path)}["']$/ + 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 quietly { generator.invoke_all } - assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+:github\s+:\s+["']#{Regexp.escape("rails/rails")}["']$} + assert_file 'Gemfile', %r{^gem\s+["']rails["'],\s+github:\s+["']#{Regexp.escape("rails/rails")}["']$} end def test_skip_gemfile -- cgit v1.2.3 From 1385388452c6dc86afe0668c41e0f5a491dc193a Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 3 May 2012 00:10:27 -0300 Subject: Allow configuring a different queue consumer Also make sure to not use default queue consumer with custom queue implementation. It is up to the new queue implementation to start / shutdown the consumer. --- railties/lib/rails/application.rb | 2 +- railties/lib/rails/application/configuration.rb | 8 +++-- railties/lib/rails/application/finisher.rb | 4 +-- railties/test/application/queue_test.rb | 39 +++++++++++++++++++++++-- 4 files changed, 44 insertions(+), 9 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index c7b19c964a..c4edbae55b 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -66,7 +66,7 @@ module Rails end end - attr_accessor :assets, :sandbox + attr_accessor :assets, :sandbox, :queue_consumer alias_method :sandbox?, :sandbox attr_reader :reloaders attr_writer :queue diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 25bb680f69..a2e5dece16 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -8,10 +8,11 @@ module Rails attr_accessor :allow_concurrency, :asset_host, :asset_path, :assets, :autoflush_log, :cache_classes, :cache_store, :consider_all_requests_local, :console, :dependency_loading, :exceptions_app, :file_watcher, :filter_parameters, - :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags, :preload_frameworks, - :railties_order, :relative_url_root, :secret_token, + :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags, + :preload_frameworks, :railties_order, :relative_url_root, :secret_token, :serve_static_assets, :ssl_options, :static_cache_control, :session_options, - :time_zone, :reload_classes_only_on_change, :use_schema_cache_dump, :queue + :time_zone, :reload_classes_only_on_change, :use_schema_cache_dump, + :queue, :queue_consumer attr_writer :log_level attr_reader :encoding @@ -44,6 +45,7 @@ module Rails @log_formatter = ActiveSupport::Logger::SimpleFormatter.new @use_schema_cache_dump = true @queue = Rails::Queueing::Queue + @queue_consumer = Rails::Queueing::ThreadedConsumer @assets = ActiveSupport::OrderedOptions.new @assets.enabled = false diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 6a24e01f29..84f2601f28 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -96,8 +96,8 @@ module Rails initializer :activate_queue_consumer do |app| if config.queue == Rails::Queueing::Queue - consumer = Rails::Queueing::ThreadedConsumer.start(app.queue) - at_exit { consumer.shutdown } + app.queue_consumer = config.queue_consumer.start(app.queue) + at_exit { app.queue_consumer.shutdown } end end end diff --git a/railties/test/application/queue_test.rb b/railties/test/application/queue_test.rb index 71b0c2bc38..da8bdeed52 100644 --- a/railties/test/application/queue_test.rb +++ b/railties/test/application/queue_test.rb @@ -63,7 +63,7 @@ module ApplicationTests test "in test mode, the queue can be observed" do app("test") - job = Class.new(Struct.new(:id)) do + job = Struct.new(:id) do def run end end @@ -79,7 +79,7 @@ module ApplicationTests assert_equal jobs, Rails.queue.jobs end - test "a custom queue implementation can be provided" do + def setup_custom_queue add_to_env_config "production", <<-RUBY require "my_queue" config.queue = MyQueue @@ -94,10 +94,14 @@ module ApplicationTests RUBY app("production") + end + + test "a custom queue implementation can be provided" do + setup_custom_queue assert_kind_of MyQueue, Rails.queue - job = Class.new(Struct.new(:id, :ran)) do + job = Struct.new(:id, :ran) do def run self.ran = true end @@ -108,5 +112,34 @@ module ApplicationTests assert_equal true, job1.ran end + + test "a custom consumer implementation can be provided" do + add_to_env_config "production", <<-RUBY + require "my_queue_consumer" + config.queue_consumer = MyQueueConsumer + RUBY + + app_file "lib/my_queue_consumer.rb", <<-RUBY + class MyQueueConsumer < Rails::Queueing::ThreadedConsumer + attr_reader :started + + def start + @started = true + self + end + end + RUBY + + app("production") + + assert_kind_of MyQueueConsumer, Rails.application.queue_consumer + assert Rails.application.queue_consumer.started + end + + test "default consumer is not used with custom queue implementation" do + setup_custom_queue + + assert_nil Rails.application.queue_consumer + end end end -- cgit v1.2.3 From 8fbf2e197f0a327ab95bc85b3d3d683e68e09cf3 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 3 May 2012 00:15:50 -0300 Subject: Allow overriding exception handling in threaded consumer --- railties/lib/rails/queueing.rb | 6 +++++- railties/test/queueing/threaded_consumer_test.rb | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/queueing.rb b/railties/lib/rails/queueing.rb index 2e187b8555..896dd91034 100644 --- a/railties/lib/rails/queueing.rb +++ b/railties/lib/rails/queueing.rb @@ -53,7 +53,7 @@ module Rails begin job.run rescue Exception => e - Rails.logger.error "Job Error: #{e.message}\n#{e.backtrace.join("\n")}" + handle_exception e end end end @@ -64,6 +64,10 @@ module Rails @queue.push nil @thread.join end + + def handle_exception(e) + Rails.logger.error "Job Error: #{e.message}\n#{e.backtrace.join("\n")}" + end end end end diff --git a/railties/test/queueing/threaded_consumer_test.rb b/railties/test/queueing/threaded_consumer_test.rb index 559de2a82d..c34a966d6e 100644 --- a/railties/test/queueing/threaded_consumer_test.rb +++ b/railties/test/queueing/threaded_consumer_test.rb @@ -78,4 +78,23 @@ class TestThreadConsumer < ActiveSupport::TestCase assert_equal 1, logger.logged(:error).size assert_match(/Job Error: RuntimeError: Error!/, logger.logged(:error).last) end + + test "test overriding exception handling" do + @consumer.shutdown + @consumer = Class.new(Rails::Queueing::ThreadedConsumer) do + attr_reader :last_error + def handle_exception(e) + @last_error = e.message + end + end.start(@queue) + + job = Job.new(1) do + raise "RuntimeError: Error!" + end + + @queue.push job + sleep 0.1 + + assert_equal "RuntimeError: Error!", @consumer.last_error + end end -- cgit v1.2.3 From 7a6116b633479effe81a820d84aaf29572cc3412 Mon Sep 17 00:00:00 2001 From: Carlos Antonio da Silva Date: Thu, 3 May 2012 22:26:30 -0300 Subject: Add some docs and changelog entry --- railties/CHANGELOG.md | 4 ++++ railties/lib/rails/queueing.rb | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index bc34ced283..b7c042cee3 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,9 @@ ## Rails 4.0.0 (unreleased) ## +* Add `config.queue_consumer` to allow the default consumer to be configurable. *Carlos Antonio da Silva* + +* Add Rails.queue as an interface with a default implementation that consumes jobs in a separate thread. *Yehuda Katz* + * Remove Rack::SSL in favour of ActionDispatch::SSL. *Rafael Mendonça França* * Remove Active Resource from Rails framework. *Prem Sichangrist* diff --git a/railties/lib/rails/queueing.rb b/railties/lib/rails/queueing.rb index 896dd91034..b4bc7fcd18 100644 --- a/railties/lib/rails/queueing.rb +++ b/railties/lib/rails/queueing.rb @@ -16,13 +16,13 @@ module Rails # Jobs are run in a separate thread to catch mistakes where code # assumes that the job is run in the same thread. class TestQueue < ::Queue - # Get a list of the jobs off this queue. This method may not be + # Get a list of the jobs off this queue. This method may not be # available on production queues. def jobs @que.dup end - # Drain the queue, running all jobs in a different thread. This method + # Drain the queue, running all jobs in a different thread. This method # may not be available on production queues. def drain # run the jobs in a separate thread so assumptions of synchronous -- cgit v1.2.3 From 2ce5e4fa6c6f44eb0c5cbf812ca62aa03b802379 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 4 May 2012 23:11:09 -0700 Subject: Give more detailed instructions in script/rails in engine closes #4894 --- railties/lib/rails/engine/commands.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/engine/commands.rb b/railties/lib/rails/engine/commands.rb index b71119af77..ffbc0b4bd6 100644 --- a/railties/lib/rails/engine/commands.rb +++ b/railties/lib/rails/engine/commands.rb @@ -34,6 +34,10 @@ The common rails commands available for engines are: destroy Undo code generated with "generate" (short-cut alias: "d") All commands can be run with -h for more information. + +If you want to run any commands that need to be run in context +of the application, like `rails server` or `rails console`, +you should do it from application's directory (typically test/dummy). EOT exit(1) end -- cgit v1.2.3 From 657b4ff04ad43bf26ded31ebfc003075f46dad53 Mon Sep 17 00:00:00 2001 From: Alexey Gaziev Date: Tue, 24 Apr 2012 13:59:55 +0400 Subject: Nice logic for deep_dup in rails --- railties/lib/rails/configuration.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 493eacdc5a..7baebed882 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -1,6 +1,8 @@ require 'active_support/deprecation' require 'active_support/ordered_options' +require 'active_support/core_ext/object' require 'active_support/core_ext/hash/deep_dup' +require 'active_support/core_ext/array/deep_dup' require 'rails/paths' require 'rails/rack' -- cgit v1.2.3 From 346bb018499cde6699fcce6c68dd7e9be45c75e1 Mon Sep 17 00:00:00 2001 From: Dmitry Vorotilin Date: Fri, 4 May 2012 18:40:32 +0400 Subject: More faster rails dbconsole --- railties/lib/rails/commands.rb | 3 +- railties/lib/rails/commands/dbconsole.rb | 38 ++++++++++---- railties/test/commands/dbconsole_test.rb | 85 +++++++++++++++++++++----------- 3 files changed, 86 insertions(+), 40 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index 82cdd6053b..7f473c237c 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -57,8 +57,7 @@ when 'server' when 'dbconsole' require 'rails/commands/dbconsole' - require APP_PATH - Rails::DBConsole.start(Rails.application) + Rails::DBConsole.start when 'application', 'runner' require "rails/commands/#{command}" diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 25a8caeec3..aaba47117f 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -5,15 +5,37 @@ require 'rbconfig' module Rails class DBConsole - attr_reader :arguments + attr_reader :arguments, :config - def self.start(app) - new(app).start + def self.start + new(config).start end - def initialize(app, arguments = ARGV) - @app = app - @arguments = arguments + def self.config + config = begin + YAML.load(ERB.new(IO.read("config/database.yml")).result) + rescue SyntaxError, StandardError + require APP_PATH + Rails.application.config.database_configuration + end + + unless config[env] + abort "No database is configured for the environment '#{env}'" + end + + config[env] + end + + def self.env + if Rails.respond_to?(:env) + Rails.env + else + ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development" + end + end + + def initialize(config, arguments = ARGV) + @config, @arguments = config, arguments end def start @@ -38,10 +60,6 @@ module Rails abort opt.to_s unless (0..1).include?(arguments.size) end - unless config = @app.config.database_configuration[Rails.env] - abort "No database is configured for the environment '#{Rails.env}'" - end - case config["adapter"] when /^mysql/ diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index 0bf417c014..5ef7ceef3b 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -3,42 +3,70 @@ require 'rails/commands/dbconsole' class Rails::DBConsoleTest < ActiveSupport::TestCase def teardown - %w[PGUSER PGHOST PGPORT PGPASSWORD'].each{|key| ENV.delete(key)} + %w[PGUSER PGHOST PGPORT PGPASSWORD].each{|key| ENV.delete(key)} end - def test_no_database_configured - start [], false + def test_config + Rails::DBConsole.const_set(:APP_PATH, "erb") + + app_config({}) + capture_abort { Rails::DBConsole.config } assert aborted assert_match /No database is configured for the environment '\w+'/, output + + app_config(development: "with_init") + assert_equal Rails::DBConsole.config, "with_init" + + app_db_file("development:\n without_init") + assert_equal Rails::DBConsole.config, "without_init" + + app_db_file("development:\n <%= Rails.something_app_specific %>") + assert_equal Rails::DBConsole.config, "with_init" + + app_db_file("development:\n\ninvalid") + assert_equal Rails::DBConsole.config, "with_init" + end + + def test_env + assert_equal Rails::DBConsole.env, "development" + + Rails.stubs(:respond_to?).with(:env).returns(false) + assert_equal Rails::DBConsole.env, "development" + + ENV['RACK_ENV'] = "rack_env" + assert_equal Rails::DBConsole.env, "rack_env" + + ENV['RAILS_ENV'] = "rails_env" + assert_equal Rails::DBConsole.env, "rails_env" end def test_mysql dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], 'db') - start [], {adapter: 'mysql', database: 'db'} + start(adapter: 'mysql', database: 'db') assert !aborted end def test_mysql_full dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], '--host=locahost', '--port=1234', '--socket=socket', '--user=user', '--default-character-set=UTF-8', '-p', 'db') - start [], {adapter: 'mysql', database: 'db', host: 'locahost', port: 1234, socket: 'socket', username: 'user', password: 'qwerty', encoding: 'UTF-8'} + start(adapter: 'mysql', database: 'db', host: 'locahost', port: 1234, socket: 'socket', username: 'user', password: 'qwerty', encoding: 'UTF-8') assert !aborted end def test_mysql_include_password dbconsole.expects(:find_cmd_and_exec).with(%w[mysql mysql5], '--user=user', '--password=qwerty', 'db') - start ['-p'], {adapter: 'mysql', database: 'db', username: 'user', password: 'qwerty'} + start({adapter: 'mysql', database: 'db', username: 'user', password: 'qwerty'}, ['-p']) assert !aborted end def test_postgresql dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') - start [], {adapter: 'postgresql', database: 'db'} + start(adapter: 'postgresql', database: 'db') assert !aborted end def test_postgresql_full dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') - start [], {adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3', host: 'host', port: 5432} + start(adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3', host: 'host', port: 5432) assert !aborted assert_equal 'user', ENV['PGUSER'] assert_equal 'host', ENV['PGHOST'] @@ -48,7 +76,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase def test_postgresql_include_password dbconsole.expects(:find_cmd_and_exec).with('psql', 'db') - start ['-p'], {adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3'} + start({adapter: 'postgresql', database: 'db', username: 'user', password: 'q1w2e3'}, ['-p']) assert !aborted assert_equal 'user', ENV['PGUSER'] assert_equal 'q1w2e3', ENV['PGPASSWORD'] @@ -56,42 +84,42 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase def test_sqlite dbconsole.expects(:find_cmd_and_exec).with('sqlite', 'db') - start [], {adapter: 'sqlite', database: 'db'} + start(adapter: 'sqlite', database: 'db') assert !aborted end def test_sqlite3 dbconsole.expects(:find_cmd_and_exec).with('sqlite3', 'db') - start [], {adapter: 'sqlite3', database: 'db'} + start(adapter: 'sqlite3', database: 'db') assert !aborted end def test_sqlite3_mode dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-html', 'db') - start ['--mode', 'html'], {adapter: 'sqlite3', database: 'db'} + start({adapter: 'sqlite3', database: 'db'}, ['--mode', 'html']) assert !aborted end def test_sqlite3_header dbconsole.expects(:find_cmd_and_exec).with('sqlite3', '-header', 'db') - start ['--header'], {adapter: 'sqlite3', database: 'db'} + start({adapter: 'sqlite3', database: 'db'}, ['--header']) assert !aborted end def test_oracle dbconsole.expects(:find_cmd_and_exec).with('sqlplus', 'user@db') - start [], {adapter: 'oracle', database: 'db', username: 'user', password: 'secret'} + start(adapter: 'oracle', database: 'db', username: 'user', password: 'secret') assert !aborted end def test_oracle_include_password dbconsole.expects(:find_cmd_and_exec).with('sqlplus', 'user/secret@db') - start ['-p'], {adapter: 'oracle', database: 'db', username: 'user', password: 'secret'} + start({adapter: 'oracle', database: 'db', username: 'user', password: 'secret'}, ['-p']) assert !aborted end def test_unknown_command_line_client - start [], {adapter: 'unknown', database: 'db'} + start(adapter: 'unknown', database: 'db') assert aborted assert_match /Unknown command-line client for db/, output end @@ -100,29 +128,30 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase attr_reader :aborted, :output def dbconsole - @dbconsole ||= Rails::DBConsole.new(app) + @dbconsole ||= Rails::DBConsole.new(nil) end - def start(argv = [], database_configuration = {}) - dbconsole.stubs(arguments: argv) - app.config.stubs(database_configuration: { - Rails.env => database_configuration ? database_configuration.stringify_keys : database_configuration - }) + def start(config = {}, argv = []) + dbconsole.stubs(config: config.stringify_keys, arguments: argv) + capture_abort { dbconsole.start } + end + def capture_abort @aborted = false @output = capture(:stderr) do begin - dbconsole.start + yield rescue SystemExit @aborted = true end end end - def app - @app ||= begin - config = mock("config") - stub("app", config: config) - end + def app_db_file(result) + IO.stubs(:read).with("config/database.yml").returns(result) + end + + def app_config(result) + Rails.application.config.stubs(:database_configuration).returns(result.stringify_keys) end end -- cgit v1.2.3 From 9d03e20b1969c267a524873907f6993e351cfc97 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 6 May 2012 12:33:02 -0700 Subject: Remove obsolete deep_dup requires --- railties/lib/rails/configuration.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 7baebed882..3d66019e5e 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -1,8 +1,6 @@ require 'active_support/deprecation' require 'active_support/ordered_options' require 'active_support/core_ext/object' -require 'active_support/core_ext/hash/deep_dup' -require 'active_support/core_ext/array/deep_dup' require 'rails/paths' require 'rails/rack' -- cgit v1.2.3 From 055857841ad53fcc1ccd20756f085690bd221646 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 6 May 2012 21:36:59 -0700 Subject: Ensure that Rails.env is equal to "test" by default when running tests. Rails.env when running tests on localhost differs from travis ci which makes it harder to write tests that check env related things. --- railties/test/abstract_unit.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/test/abstract_unit.rb b/railties/test/abstract_unit.rb index 29ebdc6511..dfcf5aa27d 100644 --- a/railties/test/abstract_unit.rb +++ b/railties/test/abstract_unit.rb @@ -1,3 +1,5 @@ +ENV["RAILS_ENV"] ||= "test" + require File.expand_path("../../../load_paths", __FILE__) require 'stringio' -- cgit v1.2.3 From d98bbdee14384ff2e99e2f1716a8dff681521dea Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 6 May 2012 21:38:34 -0700 Subject: Fix build --- railties/test/commands/dbconsole_test.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'railties') diff --git a/railties/test/commands/dbconsole_test.rb b/railties/test/commands/dbconsole_test.rb index 5ef7ceef3b..85a7edfacd 100644 --- a/railties/test/commands/dbconsole_test.rb +++ b/railties/test/commands/dbconsole_test.rb @@ -14,30 +14,33 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase assert aborted assert_match /No database is configured for the environment '\w+'/, output - app_config(development: "with_init") + app_config(test: "with_init") assert_equal Rails::DBConsole.config, "with_init" - app_db_file("development:\n without_init") + app_db_file("test:\n without_init") assert_equal Rails::DBConsole.config, "without_init" - app_db_file("development:\n <%= Rails.something_app_specific %>") + app_db_file("test:\n <%= Rails.something_app_specific %>") assert_equal Rails::DBConsole.config, "with_init" - app_db_file("development:\n\ninvalid") + app_db_file("test:\n\ninvalid") assert_equal Rails::DBConsole.config, "with_init" end def test_env - assert_equal Rails::DBConsole.env, "development" + assert_equal Rails::DBConsole.env, "test" Rails.stubs(:respond_to?).with(:env).returns(false) - assert_equal Rails::DBConsole.env, "development" + assert_equal Rails::DBConsole.env, "test" + ENV['RAILS_ENV'] = nil ENV['RACK_ENV'] = "rack_env" assert_equal Rails::DBConsole.env, "rack_env" ENV['RAILS_ENV'] = "rails_env" assert_equal Rails::DBConsole.env, "rails_env" + ensure + ENV['RAILS_ENV'] = "test" end def test_mysql @@ -138,7 +141,7 @@ class Rails::DBConsoleTest < ActiveSupport::TestCase def capture_abort @aborted = false - @output = capture(:stderr) do + @output = capture(:stderr) do begin yield rescue SystemExit -- cgit v1.2.3 From ceb1dcc3dbd4f3e5d42f46bb5746c87c1fcf47ff Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 8 May 2012 11:44:58 +0100 Subject: add humans.txt --- .../rails/generators/rails/app/templates/public/humans.txt.tt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt b/railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt new file mode 100644 index 0000000000..1c49e5c70a --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt @@ -0,0 +1,9 @@ +# See more about this file at: http://humanstxt.org/ +# For format suggestions, see: http://humanstxt.org/Standard.html +/* TEAM */ + <%= ENV['USER'].titlecase %> + +/* APP */ + Name: <%= app_const_base %> + Date Created: <%= Date.today.strftime("%B %d, %Y") %> + Software: Ruby on Rails -- cgit v1.2.3 From 757a0ce6aaa19af20daea29a1d5e5b16c506f89b Mon Sep 17 00:00:00 2001 From: Arun Agrawal Date: Tue, 8 May 2012 16:41:20 +0530 Subject: Adding test for humans.txt --- railties/test/generators/app_generator_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties') diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index d13dc8d4ac..a0c308a3b8 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -383,6 +383,12 @@ class AppGeneratorTest < Rails::Generators::TestCase assert_no_match(/run bundle install/, output) end + def test_humans_txt_file + date = Date.today.strftime("%B %d, %Y") + run_generator [File.join(destination_root, 'things-43')] + assert_file "things-43/public/humans.txt", /Name: Things43/, /Software: Ruby on Rails/, /Date Created: #{date}/ + end + protected def action(*args, &block) -- cgit v1.2.3 From ef9dd2722342ef86f01cbca1dfd5174993d2d56f Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 9 May 2012 00:47:45 +0200 Subject: registers ceb1dcc in the CHANGELOG --- railties/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) (limited to 'railties') diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index b7c042cee3..01df2c5b64 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 4.0.0 (unreleased) ## +* The application generator generates `public/humans.txt` with some basic data. *Paul Campbell* + * Add `config.queue_consumer` to allow the default consumer to be configurable. *Carlos Antonio da Silva* * Add Rails.queue as an interface with a default implementation that consumes jobs in a separate thread. *Yehuda Katz* -- cgit v1.2.3 From b14d1cd8aefac1895f83139c00ce130e89277c9f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 10 May 2012 14:11:59 -0700 Subject: Failing test for #6251 --- railties/test/generators/plugin_new_generator_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'railties') diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 6c31b80c7d..51374e5f3f 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -236,6 +236,13 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_file "test/dummy" end + def test_creating_dummy_application_with_different_name + run_generator [destination_root, "--dummy_path", "spec/fake"] + assert_file "spec/fake" + assert_file "spec/fake/config/application.rb" + assert_no_file "test/dummy" + end + def test_creating_dummy_without_tests_but_with_dummy_path run_generator [destination_root, "--dummy_path", "spec/dummy", "--skip-test-unit"] assert_file "spec/dummy" -- cgit v1.2.3 From 0d48b12fc56df574bb81cfaf0f5fb4713e9230fc Mon Sep 17 00:00:00 2001 From: David Padilla Date: Thu, 10 May 2012 15:56:13 -0500 Subject: Fixes issue #6251 Plugin generator crashes when using the --dummy-path option Code was assuming the application name in `config/application.rb` was module Dummy. --- railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') 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 f4263d1b98..722e37e20b 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 @@ -302,7 +302,7 @@ task :default => :test dummy_application_path = File.expand_path("#{dummy_path}/config/application.rb", destination_root) unless options[:pretend] || !File.exists?(dummy_application_path) contents = File.read(dummy_application_path) - contents[(contents.index("module Dummy"))..-1] + contents[(contents.index(/module ([\w]+)\n(.*)class Application/m))..-1] end end end -- cgit v1.2.3 From 1abf15657b47b32dd5ba295bcdb618b41b46c0bc Mon Sep 17 00:00:00 2001 From: Enrico Carlesso Date: Fri, 11 May 2012 11:50:15 +0200 Subject: In robots.txt, User-agent should be all downcase except for the first 'U', according with http://en.wikipedia.org/wiki/Robots_exclusion_standard --- railties/lib/rails/generators/rails/app/templates/public/robots.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/public/robots.txt b/railties/lib/rails/generators/rails/app/templates/public/robots.txt index 085187fa58..1a3a5e4dd2 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/robots.txt +++ b/railties/lib/rails/generators/rails/app/templates/public/robots.txt @@ -1,5 +1,5 @@ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file # # To ban all spiders from the entire site uncomment the next two lines: -# User-Agent: * +# User-agent: * # Disallow: / -- cgit v1.2.3 From 36dd1857dc097b6fbc65396bfabaa152da9c899f Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 11 May 2012 13:56:05 -0300 Subject: Remove useless load path modifications --- railties/Rakefile | 3 ++- railties/test/isolation/abstract_unit.rb | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/Rakefile b/railties/Rakefile index 108413235a..993ba840ff 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -20,7 +20,8 @@ namespace :test do 'test', 'lib', "#{File.dirname(__FILE__)}/../activesupport/lib", - "#{File.dirname(__FILE__)}/../actionpack/lib" + "#{File.dirname(__FILE__)}/../actionpack/lib", + "#{File.dirname(__FILE__)}/../activemodel/lib" ] ruby "-I#{dash_i.join ':'}", file end diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb index f2dc0c71b1..03be81e59f 100644 --- a/railties/test/isolation/abstract_unit.rb +++ b/railties/test/isolation/abstract_unit.rb @@ -17,8 +17,8 @@ RAILS_FRAMEWORK_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../..") # These files do not require any others and are needed # to run the tests -require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/testing/isolation" -require "#{RAILS_FRAMEWORK_ROOT}/activesupport/lib/active_support/core_ext/kernel/reporting" +require "active_support/testing/isolation" +require "active_support/core_ext/kernel/reporting" module TestHelpers module Paths @@ -248,7 +248,6 @@ module TestHelpers def use_frameworks(arr) to_remove = [:actionmailer, - :activemodel, :activerecord] - arr if to_remove.include? :activerecord remove_from_config "config.active_record.whitelist_attributes = true" -- cgit v1.2.3 From 1d1939056a81dd809b623a17d9930cf0bd1ca8ca Mon Sep 17 00:00:00 2001 From: Egor Homakov Date: Sat, 12 May 2012 10:26:22 +0400 Subject: Update railties/lib/rails/generators/rails/app/templates/config/application.rb --- .../lib/rails/generators/rails/app/templates/config/application.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'railties') 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 c8a3c13b95..daa04c144e 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -43,6 +43,9 @@ module <%= app_const_base %> # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] + + # Enable escaping HTML in JSON. The default is false. + # config.active_support.escape_html_entities_in_json = true # Use SQL instead of Active Record's schema dumper when creating the database. # This is necessary if your schema can't be completely dumped by the schema dumper, -- cgit v1.2.3 From 38b4e7c8b1c4c46985b6e598d6df2df97457308a Mon Sep 17 00:00:00 2001 From: Geoffrey Roguelon Date: Sat, 12 May 2012 10:36:35 +0200 Subject: Add commas missing in performance tests --- .../generators/rails/app/templates/test/performance/browsing_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb index 3fea27b916..2a849b7f2b 100644 --- a/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb +++ b/railties/lib/rails/generators/rails/app/templates/test/performance/browsing_test.rb @@ -3,7 +3,7 @@ require 'rails/performance_test_help' class BrowsingTest < ActionDispatch::PerformanceTest # Refer to the documentation for all available options - # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] + # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory], # :output => 'tmp/performance', :formats => [:flat] } def test_homepage -- cgit v1.2.3 From f2f6534272b7895aa39183890043bc8c8e0ee1e8 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 12 May 2012 19:08:19 +0530 Subject: s/wether/whether [ci skip] --- railties/lib/rails/generators/rails/app/templates/config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') 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 daa04c144e..6991b5a5f8 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -58,7 +58,7 @@ module <%= app_const_base %> # parameters by using an attr_accessible or attr_protected declaration. <%= comment_if :skip_active_record %>config.active_record.whitelist_attributes = true - # Specifies wether or not has_many or has_one association option :dependent => :restrict raises + # Specifies whether or not has_many or has_one association option :dependent => :restrict raises # an exception. If set to true, then an ActiveRecord::DeleteRestrictionError exception would be # raised. If set to false, then an error will be added on the model instead. <%= comment_if :skip_active_record %>config.active_record.dependent_restrict_raises = false -- cgit v1.2.3 From 17059a4868532f0046f1ec0ecc643a2211d6db45 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 14 May 2012 10:50:40 -0500 Subject: Removing ==Examples and last blank lines of docs from railties --- railties/lib/rails.rb | 3 --- railties/lib/rails/engine.rb | 5 ---- railties/lib/rails/generators.rb | 4 --- railties/lib/rails/generators/actions.rb | 42 ------------------------------ railties/lib/rails/generators/base.rb | 3 --- railties/lib/rails/generators/migration.rb | 4 --- 6 files changed, 61 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index 59c3c56e59..670477f91a 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -107,14 +107,11 @@ module Rails # * The environment variable RAILS_GROUPS; # * The optional envs given as argument and the hash with group dependencies; # - # == Examples - # # groups :assets => [:development, :test] # # # Returns # # => [:default, :development, :assets] for Rails.env == "development" # # => [:default, :production] for Rails.env == "production" - # def groups(*groups) hash = groups.extract_options! env = Rails.env diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 9bf9cbe022..ef48bc4f94 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -39,8 +39,6 @@ module Rails # and autoload_once_paths, which, differently from a Railtie, are scoped to # the current engine. # - # Example: - # # class MyEngine < Rails::Engine # # Add a load path for this specific Engine # config.autoload_paths << File.expand_path("../lib/some/path", __FILE__) @@ -336,11 +334,8 @@ module Rails # It will affect the priority of loading views, helpers, assets and all the other files # related to engine or application. # - # Example: - # # # load Blog::Engine with highest priority, followed by application and other railties # config.railties_order = [Blog::Engine, :main_app, :all] - # class Engine < Railtie autoload :Configuration, "rails/engine/configuration" autoload :Railties, "rails/engine/railties" diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 55642f8140..4fa990171d 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -95,7 +95,6 @@ module Rails # some of them are not available by adding a fallback: # # Rails::Generators.fallbacks[:shoulda] = :test_unit - # def self.fallbacks @fallbacks ||= {} end @@ -115,8 +114,6 @@ module Rails # Generators names must end with "_generator.rb". This is required because Rails # looks in load paths and loads the generator just before it's going to be used. # - # ==== Examples - # # find_by_namespace :webrat, :rails, :integration # # Will search for the following generators: @@ -125,7 +122,6 @@ module Rails # # Notice that "rails:generators:webrat" could be loaded as well, what # Rails looks for is the first and last parts of the namespace. - # def self.find_by_namespace(name, base=nil, context=nil) #:nodoc: lookups = [] lookups << "#{base}:#{name}" if base diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 9b0649e456..6cd2ea2bbd 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -8,12 +8,9 @@ module Rails # Adds an entry into Gemfile for the supplied gem. If env # is specified, add the gem to the given environment. # - # ==== Example - # # 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 @@ -43,12 +40,9 @@ module Rails # Wraps gem entries inside a group. # - # ==== Example - # # gem_group :development, :test do # gem "rspec-rails" # end - # def gem_group(*names, &block) name = names.map(&:inspect).join(", ") log :gemfile, "group #{name}" @@ -66,10 +60,7 @@ module Rails # Add the given source to Gemfile # - # ==== Example - # # add_source "http://gems.github.com/" - # def add_source(source, options={}) log :source, source @@ -83,8 +74,6 @@ module Rails # If options :env is specified, the line is appended to the corresponding # file in config/environments. # - # ==== Examples - # # environment do # "config.autoload_paths += %W(#{config.root}/extras)" # end @@ -92,7 +81,6 @@ module Rails # environment(nil, :env => "development") do # "config.active_record.observers = :cacher" # end - # def environment(data=nil, options={}, &block) sentinel = /class [a-z_:]+ < Rails::Application/i env_file_sentinel = /::Application\.configure do/ @@ -112,12 +100,9 @@ module Rails # Run a command in git. # - # ==== Examples - # # git :init # git :add => "this.file that.rb" # git :add => "onefile.rb", :rm => "badfile.cxx" - # def git(commands={}) if commands.is_a?(Symbol) run "git #{commands}" @@ -131,15 +116,12 @@ module Rails # Create a new file in the vendor/ directory. Code can be specified # in a block or a data string can be given. # - # ==== Examples - # # vendor("sekrit.rb") do # sekrit_salt = "#{Time.now}--#{3.years.ago}--#{rand}--" # "salt = '#{sekrit_salt}'" # end # # vendor("foreign.rb", "# Foreign code is fun") - # def vendor(filename, data=nil, &block) log :vendor, filename create_file("vendor/#{filename}", data, :verbose => false, &block) @@ -148,14 +130,11 @@ module Rails # Create a new file in the lib/ directory. Code can be specified # in a block or a data string can be given. # - # ==== Examples - # # lib("crypto.rb") do # "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'" # end # # lib("foreign.rb", "# Foreign code is fun") - # def lib(filename, data=nil, &block) log :lib, filename create_file("lib/#{filename}", data, :verbose => false, &block) @@ -163,8 +142,6 @@ module Rails # Create a new Rakefile with the provided code (either in a block or a string). # - # ==== Examples - # # rakefile("bootstrap.rake") do # project = ask("What is the UNIX name of your project?") # @@ -178,7 +155,6 @@ module Rails # end # # rakefile('seed.rake', 'puts "Planting seeds"') - # def rakefile(filename, data=nil, &block) log :rakefile, filename create_file("lib/tasks/#{filename}", data, :verbose => false, &block) @@ -186,8 +162,6 @@ module Rails # Create a new initializer with the provided code (either in a block or a string). # - # ==== Examples - # # initializer("globals.rb") do # data = "" # @@ -199,7 +173,6 @@ module Rails # end # # initializer("api.rb", "API_KEY = '123456'") - # def initializer(filename, data=nil, &block) log :initializer, filename create_file("config/initializers/#{filename}", data, :verbose => false, &block) @@ -209,10 +182,7 @@ module Rails # The second parameter is the argument string that is passed to # the generator or an Array that is joined. # - # ==== Example - # # generate(:authenticated, "user session") - # def generate(what, *args) log :generate, what argument = args.map {|arg| arg.to_s }.flatten.join(" ") @@ -222,12 +192,9 @@ module Rails # Runs the supplied rake task # - # ==== Example - # # rake("db:migrate") # rake("db:migrate", :env => "production") # rake("gems:install", :sudo => true) - # def rake(command, options={}) log :rake, command env = options[:env] || ENV["RAILS_ENV"] || 'development' @@ -237,10 +204,7 @@ module Rails # Just run the capify command in root # - # ==== Example - # # capify! - # def capify! log :capify, "" in_root { run("#{extify(:capify)} .", :verbose => false) } @@ -248,10 +212,7 @@ module Rails # Make an entry in Rails routing file config/routes.rb # - # === Example - # # route "root :to => 'welcome#index'" - # def route(routing_code) log :route, routing_code sentinel = /\.routes\.draw do\s*$/ @@ -263,10 +224,7 @@ module Rails # Reads the given file at the source root and prints it in the console. # - # === Example - # # readme "README" - # def readme(path) log File.read(find_in_source_paths(path)) end diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 1648b9674a..28d7680669 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -187,10 +187,7 @@ module Rails # Remove a previously added hook. # - # ==== Examples - # # remove_hook_for :orm - # def self.remove_hook_for(*names) remove_invocation(*names) diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index 0c5c4f6e09..5bf98bb6e0 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -3,7 +3,6 @@ module Rails # Holds common methods for migrations. It assumes that migrations has the # [0-9]*_name format and can be used by another frameworks (like Sequel) # just by implementing the next migration version method. - # module Migration attr_reader :migration_number, :migration_file_name, :migration_class_name @@ -38,10 +37,7 @@ module Rails # The migration version, migration file name, migration class name are # available as instance variables in the template to be rendered. # - # ==== Examples - # # migration_template "migration.rb", "db/migrate/add_foo_to_bar.rb" - # def migration_template(source, destination=nil, config={}) destination = File.expand_path(destination || source, self.destination_root) -- cgit v1.2.3