diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 2 | ||||
-rw-r--r-- | railties/lib/rails.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 42 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/generators/base.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/generators/migration.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/application.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt | 2 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 5 | ||||
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 9 | ||||
-rw-r--r-- | railties/test/railties/engine_test.rb | 10 |
14 files changed, 34 insertions, 76 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index 01df2c5b64..1f88843ee9 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 4.0.0 (unreleased) ## +* Load all environments available in `config.paths["config/environments"]`. *Piotr Sarnacki* + * 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* 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..47856c87c6 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -39,8 +39,6 @@ module Rails # and <tt>autoload_once_paths</tt>, which, differently from a <tt>Railtie</tt>, 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" @@ -572,8 +567,9 @@ module Rails end initializer :load_environment_config, :before => :load_environment_hook, :group => :all do - environment = paths["config/environments"].existent.first - require environment if environment + paths["config/environments"].existent.each do |environment| + require environment + end end initializer :append_assets_path, :group => :all do |app| 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/app_base.rb b/railties/lib/rails/generators/app_base.rb index 2c1742c6be..10ad475d55 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -246,8 +246,17 @@ module Rails # is easier to silence stdout in the existing test suite this way. The # end-user gets the bundler commands called anyway, so no big deal. # + # We unset temporary bundler variables to load proper bundler and Gemfile. + # # Thanks to James Tucker for the Gem tricks involved in this call. - print `"#{Gem.ruby}" "#{Gem.bin_path('bundler', 'bundle')}" #{command}` + _bundle_command = Gem.bin_path('bundler', 'bundle') + + bundle_bin_path, bundle_gemfile, rubyopt = ENV['BUNDLE_BIN_PATH'], ENV['BUNDLE_GEMFILE'], ENV['RUBYOPT'] + ENV['BUNDLE_BIN_PATH'], ENV['BUNDLE_GEMFILE'], ENV['RUBYOPT'] = "", "", "" + + print `"#{Gem.ruby}" "#{_bundle_command}" #{command}` + + ENV['BUNDLE_BIN_PATH'], ENV['BUNDLE_GEMFILE'], ENV['RUBYOPT'] = bundle_bin_path, bundle_gemfile, rubyopt end def run_bundle 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) diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css index 3b5cc6648e..3192ec897b 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/stylesheets/application.css @@ -10,4 +10,4 @@ * *= require_self *= require_tree . -*/ + */ 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 5fa96397f0..d816f973e6 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -44,9 +44,6 @@ 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, # like if you have constraints or database-specific column types. 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 index 1c49e5c70a..f081e08b6c 100644 --- a/railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt +++ b/railties/lib/rails/generators/rails/app/templates/public/humans.txt.tt @@ -1,9 +1,7 @@ # 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 diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 59212d4f58..26e912fd9e 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -89,7 +89,7 @@ class AppGeneratorTest < Rails::Generators::TestCase output = Dir.chdir(app_root) do `rails new --help` end - assert_match /rails new APP_PATH \[options\]/, output + assert_match(/rails new APP_PATH \[options\]/, output) assert_equal true, $?.success? end @@ -378,9 +378,8 @@ class AppGeneratorTest < Rails::Generators::TestCase 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}/ + assert_file "things-43/public/humans.txt", /Name: Things43/, /Software: Ruby on Rails/ end protected diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 51374e5f3f..b0e1865b26 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -99,7 +99,13 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase end def test_generation_runs_bundle_install_with_full_and_mountable - result = run_generator [destination_root, "--mountable", "--full"] + result = run_generator [destination_root, "--mountable", "--full", "--dev"] + assert_file "#{destination_root}/Gemfile.lock" do |contents| + assert_match(/bukkits/, contents) + end + assert_match(/run bundle install/, result) + assert_match(/Using bukkits \(0\.0\.1\)/, result) + assert_match(/Your bundle is complete/, result) assert_equal 1, result.scan("Your bundle is complete").size end @@ -348,4 +354,3 @@ protected silence(:stdout){ generator.send(*args, &block) } end end - diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index 9a6b2b66ca..55f72f532f 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -537,10 +537,11 @@ YAML assert_equal "foo", last_response.body end - test "it loads its environment file" do + test "it loads its environments file" do @plugin.write "lib/bukkits.rb", <<-RUBY module Bukkits class Engine < ::Rails::Engine + config.paths["config/environments"].push "config/environments/additional.rb" end end RUBY @@ -551,9 +552,16 @@ YAML end RUBY + @plugin.write "config/environments/additional.rb", <<-RUBY + Bukkits::Engine.configure do + config.additional_environment_loaded = true + end + RUBY + boot_rails assert Bukkits::Engine.config.environment_loaded + assert Bukkits::Engine.config.additional_environment_loaded end test "it passes router in env" do |