diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2008-05-15 21:54:46 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-15 21:54:46 +0100 |
commit | 879493c35fd8d9e12e5cf3e56cd67ff07c3345c5 (patch) | |
tree | 9615859e1d9a52f71da444b0b7359817bb6acc50 /railties | |
parent | d6ecce66f4e125531875006eea8022b73fe135b5 (diff) | |
parent | fc02eabf296d6edb74a95174c7322293a54c9492 (diff) | |
download | rails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.tar.gz rails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.tar.bz2 rails-879493c35fd8d9e12e5cf3e56cd67ff07c3345c5.zip |
Merge commit 'mainstream/master'
Conflicts:
actionmailer/lib/action_mailer/base.rb
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/MIT-LICENSE | 2 | ||||
-rw-r--r-- | railties/Rakefile | 12 | ||||
-rw-r--r-- | railties/configs/initializers/new_rails_defaults.rb | 3 | ||||
-rw-r--r-- | railties/html/javascripts/controls.js | 2 | ||||
-rw-r--r-- | railties/html/javascripts/dragdrop.js | 2 | ||||
-rw-r--r-- | railties/html/javascripts/effects.js | 2 | ||||
-rw-r--r-- | railties/lib/commands/dbconsole.rb | 3 | ||||
-rw-r--r-- | railties/lib/dispatcher.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/plugin/locator.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/version.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 25 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb | 3 | ||||
-rw-r--r-- | railties/lib/tasks/databases.rake | 4 | ||||
-rw-r--r-- | railties/test/generators/generator_test_helper.rb | 34 | ||||
-rw-r--r-- | railties/test/generators/rails_controller_generator_test.rb | 20 |
16 files changed, 85 insertions, 38 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 2ca1965d97..11d2926f31 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,4 +1,4 @@ -*SVN* +*2.1.0 RC1 (May 11th, 2008)* * script/dbconsole fires up the command-line database client. #102 [Steve Purcell] diff --git a/railties/MIT-LICENSE b/railties/MIT-LICENSE index 5fee6e106d..93be57f683 100644 --- a/railties/MIT-LICENSE +++ b/railties/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2007 David Heinemeier Hansson +Copyright (c) 2004-2008 David Heinemeier Hansson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/railties/Rakefile b/railties/Rakefile index 4eaa1bef63..45ba394299 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -303,12 +303,12 @@ spec = Gem::Specification.new do |s| on top of either MySQL, PostgreSQL, SQLite, DB2, SQL Server, or Oracle with eRuby- or Builder-based templates. EOF - s.add_dependency('rake', '>= 0.7.2') - s.add_dependency('activesupport', '= 2.0.2' + PKG_BUILD) - s.add_dependency('activerecord', '= 2.0.2' + PKG_BUILD) - s.add_dependency('actionpack', '= 2.0.2' + PKG_BUILD) - s.add_dependency('actionmailer', '= 2.0.2' + PKG_BUILD) - s.add_dependency('activeresource', '= 2.0.2' + PKG_BUILD) + s.add_dependency('rake', '>= 0.8.1') + s.add_dependency('activesupport', '= 2.0.991' + PKG_BUILD) + s.add_dependency('activerecord', '= 2.0.991' + PKG_BUILD) + s.add_dependency('actionpack', '= 2.0.991' + PKG_BUILD) + s.add_dependency('actionmailer', '= 2.0.991' + PKG_BUILD) + s.add_dependency('activeresource', '= 2.0.991' + PKG_BUILD) s.rdoc_options << '--exclude' << '.' s.has_rdoc = false diff --git a/railties/configs/initializers/new_rails_defaults.rb b/railties/configs/initializers/new_rails_defaults.rb index 3a617e3ae3..b8f0e2cac2 100644 --- a/railties/configs/initializers/new_rails_defaults.rb +++ b/railties/configs/initializers/new_rails_defaults.rb @@ -7,6 +7,9 @@ ActiveRecord::Base.partial_updates = true # Include ActiveRecord class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true +# Store the full class name (including module namespace) in STI type column +ActiveRecord::Base.store_full_sti_class = true + # Use ISO 8601 format for JSON serialized times and dates ActiveSupport.use_standard_json_time_format = true diff --git a/railties/html/javascripts/controls.js b/railties/html/javascripts/controls.js index fbc4418b83..5aaf0bb2b7 100644 --- a/railties/html/javascripts/controls.js +++ b/railties/html/javascripts/controls.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) // Contributors: diff --git a/railties/html/javascripts/dragdrop.js b/railties/html/javascripts/dragdrop.js index ccf4a1e45c..bf5cfea66c 100644 --- a/railties/html/javascripts/dragdrop.js +++ b/railties/html/javascripts/dragdrop.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) // // script.aculo.us is freely distributable under the terms of an MIT-style license. diff --git a/railties/html/javascripts/effects.js b/railties/html/javascripts/effects.js index 65aed23957..f030b5dbe9 100644 --- a/railties/html/javascripts/effects.js +++ b/railties/html/javascripts/effects.js @@ -1,4 +1,4 @@ -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // Contributors: // Justin Palmer (http://encytemedia.com/) // Mark Pilgrim (http://diveintomark.org/) diff --git a/railties/lib/commands/dbconsole.rb b/railties/lib/commands/dbconsole.rb index 28c3a3e41f..3e5010c688 100644 --- a/railties/lib/commands/dbconsole.rb +++ b/railties/lib/commands/dbconsole.rb @@ -1,3 +1,4 @@ +require 'erb' require 'yaml' require 'optparse' @@ -8,7 +9,7 @@ OptionParser.new do |opt| end env = ARGV.first || ENV['RAILS_ENV'] || 'development' -unless config = YAML.load_file(RAILS_ROOT + "/config/database.yml")[env] +unless config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/database.yml")).result)[env] abort "No database is configured for the environment '#{env}'" end diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index 9db424f14b..0bad45d9d8 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -1,5 +1,5 @@ #-- -# Copyright (c) 2004-2007 David Heinemeier Hansson +# Copyright (c) 2004-2008 David Heinemeier Hansson # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the diff --git a/railties/lib/rails/plugin/locator.rb b/railties/lib/rails/plugin/locator.rb index fd7de4ee28..f06a51a572 100644 --- a/railties/lib/rails/plugin/locator.rb +++ b/railties/lib/rails/plugin/locator.rb @@ -78,11 +78,12 @@ module Rails # a <tt>rails/init.rb</tt> file. class GemLocator < Locator def plugins - specs = initializer.configuration.gems.map(&:specification) - specs + Gem.loaded_specs.values.select do |spec| + specs = initializer.configuration.gems.map(&:specification) + specs += Gem.loaded_specs.values.select do |spec| spec.loaded_from && # prune stubs File.exist?(File.join(spec.full_gem_path, "rails", "init.rb")) end + specs.compact! require "rubygems/dependency_list" diff --git a/railties/lib/rails/version.rb b/railties/lib/rails/version.rb index da90645738..fea63beea9 100644 --- a/railties/lib/rails/version.rb +++ b/railties/lib/rails/version.rb @@ -2,7 +2,7 @@ module Rails module VERSION #:nodoc: MAJOR = 2 MINOR = 0 - TINY = 2 + TINY = 991 STRING = [MAJOR, MINOR, TINY].join('.') end diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 440bab276c..03b7d354a6 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -154,28 +154,35 @@ HELP # Ruby or Rails. In the future, expand to check other namespaces # such as the rest of the user's app. def class_collisions(*class_names) + + # Initialize some check varibles + last_class = Object + current_class = nil + name = nil + class_names.flatten.each do |class_name| # Convert to string to allow symbol arguments. class_name = class_name.to_s # Skip empty strings. - next if class_name.strip.empty? + class_name.strip.empty? ? next : current_class = class_name # Split the class from its module nesting. nesting = class_name.split('::') name = nesting.pop # Extract the last Module in the nesting. - last = nesting.inject(Object) { |last, nest| - break unless last.const_defined?(nest) - last.const_get(nest) + last = nesting.inject(last_class) { |last, nest| + break unless last_class.const_defined?(nest) + last_class = last_class.const_get(nest) } - # If the last Module exists, check whether the given - # class exists and raise a collision if so. - if last and last.const_defined?(name.camelize) - raise_class_collision(class_name) - end + end + # If the last Module exists, check whether the given + # class exists and raise a collision if so. + + if last_class and last_class.const_defined?(name.camelize) + raise_class_collision(current_class) end end diff --git a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb index 864a0bc528..e2902bf4b9 100644 --- a/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +++ b/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb @@ -34,7 +34,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase m.class_collisions(controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}Helper") m.class_collisions(class_path, "#{class_name}") - # Controller, helper, views, and test directories. + # Controller, helper, views, test and stylesheets directories. m.directory(File.join('app/models', class_path)) m.directory(File.join('app/controllers', controller_class_path)) m.directory(File.join('app/helpers', controller_class_path)) @@ -42,6 +42,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase m.directory(File.join('app/views/layouts', controller_class_path)) m.directory(File.join('test/functional', controller_class_path)) m.directory(File.join('test/unit', class_path)) + m.directory(File.join('public/stylesheets', class_path)) for action in scaffold_views m.template( diff --git a/railties/lib/tasks/databases.rake b/railties/lib/tasks/databases.rake index 63f71448f8..f40f8463f7 100644 --- a/railties/lib/tasks/databases.rake +++ b/railties/lib/tasks/databases.rake @@ -45,7 +45,7 @@ namespace :db do when 'postgresql' @encoding = config[:encoding] || ENV['CHARSET'] || 'utf8' begin - ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) + ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) ActiveRecord::Base.connection.create_database(config['database'], config.merge('encoding' => @encoding)) ActiveRecord::Base.establish_connection(config) rescue @@ -368,7 +368,7 @@ def drop_database(config) when /^sqlite/ FileUtils.rm(File.join(RAILS_ROOT, config['database'])) when 'postgresql' - ActiveRecord::Base.establish_connection(config.merge('database' => 'template1')) + ActiveRecord::Base.establish_connection(config.merge('database' => 'postgres', 'schema_search_path' => 'public')) ActiveRecord::Base.connection.drop_database config['database'] end end diff --git a/railties/test/generators/generator_test_helper.rb b/railties/test/generators/generator_test_helper.rb index 190bc91d52..c99df6e2d3 100644 --- a/railties/test/generators/generator_test_helper.rb +++ b/railties/test/generators/generator_test_helper.rb @@ -13,7 +13,7 @@ module ActiveRecord module ConnectionAdapters class Column attr_reader :name, :default, :type, :limit, :null, :sql_type, :precision, :scale - + def initialize(name, default, sql_type = nil) @name = name @default = default @@ -59,16 +59,16 @@ require 'rails_generator' class GeneratorTestCase < Test::Unit::TestCase include FileUtils - + def setup ActiveRecord::Base.pluralize_table_names = true - + mkdir_p "#{RAILS_ROOT}/app/views/layouts" mkdir_p "#{RAILS_ROOT}/config" mkdir_p "#{RAILS_ROOT}/db" mkdir_p "#{RAILS_ROOT}/test/fixtures" mkdir_p "#{RAILS_ROOT}/public/stylesheets" - + File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| f << "ActionController::Routing::Routes.draw do |map|\n\nend" end @@ -85,7 +85,7 @@ class GeneratorTestCase < Test::Unit::TestCase def test_truth # don't complain, test/unit end - + # Instantiates the Generator def build_generator(name, params) Rails::Generator::Base.instance(name, params) @@ -171,9 +171,16 @@ class GeneratorTestCase < Test::Unit::TestCase # asserts that the given class source file was generated. # It takes a path without the <tt>.rb</tt> part and an optional super class. # the contents of the class source file is passed to a block. - def assert_generated_class(path, parent=nil) - path =~ /\/?(\d+_)?(\w+)$/ - class_name = $2.camelize + def assert_generated_class(path, parent = nil) + # FIXME: Sucky way to detect namespaced classes + if path.split('/').size > 3 + path =~ /\/?(\d+_)?(\w+)\/(\w+)$/ + class_name = "#{$2.camelize}::#{$3.camelize}" + else + path =~ /\/?(\d+_)?(\w+)$/ + class_name = $2.camelize + end + assert_generated_file("#{path}.rb") do |body| assert_match /class #{class_name}#{parent.nil? ? '':" < #{parent}"}/, body, "the file '#{path}.rb' should be a class" yield body if block_given? @@ -184,8 +191,15 @@ class GeneratorTestCase < Test::Unit::TestCase # It takes a path without the <tt>.rb</tt> part. # the contents of the class source file is passed to a block. def assert_generated_module(path) - path =~ /\/?(\w+)$/ - module_name = $1.camelize + # FIXME: Sucky way to detect namespaced modules + if path.split('/').size > 3 + path =~ /\/?(\w+)\/(\w+)$/ + module_name = "#{$1.camelize}::#{$2.camelize}" + else + path =~ /\/?(\w+)$/ + module_name = $1.camelize + end + assert_generated_file("#{path}.rb") do |body| assert_match /module #{module_name}/, body, "the file '#{path}.rb' should be a module" yield body if block_given? diff --git a/railties/test/generators/rails_controller_generator_test.rb b/railties/test/generators/rails_controller_generator_test.rb new file mode 100644 index 0000000000..0090d21b85 --- /dev/null +++ b/railties/test/generators/rails_controller_generator_test.rb @@ -0,0 +1,20 @@ +require 'generators/generator_test_helper' + +class RailsControllerGeneratorTest < GeneratorTestCase + + def test_controller_generates_controller + run_generator('controller', %w(products)) + + assert_generated_controller_for :products + assert_generated_functional_test_for :products + assert_generated_helper_for :products + end + + def test_controller_generates_namespaced_controller + run_generator('controller', %w(admin::products)) + + assert_generated_controller_for "admin::products" + assert_generated_functional_test_for "admin::products" + assert_generated_helper_for "admin::products" + end +end |