diff options
Diffstat (limited to 'railties/lib')
128 files changed, 825 insertions, 752 deletions
diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index ecd8c22dd8..b1f7c29b5a 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -14,7 +14,7 @@ require 'rails/version'  require 'active_support/railtie'  require 'action_dispatch/railtie' -# For Ruby 1.9, UTF-8 is the default internal and external encoding. +# UTF-8 is the default internal and external encoding.  silence_warnings do    Encoding.default_external = Encoding::UTF_8    Encoding.default_internal = Encoding::UTF_8 @@ -29,7 +29,13 @@ module Rails    autoload :WelcomeController    class << self -    attr_accessor :application, :cache, :logger +    @application = @app_class = nil + +    attr_writer :application +    attr_accessor :app_class, :cache, :logger +    def application +      @application ||= (app_class.instance if app_class) +    end      delegate :initialize!, :initialized?, to: :application @@ -50,10 +56,18 @@ module Rails        application && application.config.root      end +    # Returns the current Rails environment. +    # +    #   Rails.env # => "development" +    #   Rails.env.development? # => true +    #   Rails.env.production? # => false      def env        @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")      end +    # Sets the Rails environment. +    # +    #   Rails.env = "staging" # => "staging"      def env=(environment)        @_env = ActiveSupport::StringInquirer.new(environment)      end diff --git a/railties/lib/rails/all.rb b/railties/lib/rails/all.rb index 2e83c0fe14..45361fca83 100644 --- a/railties/lib/rails/all.rb +++ b/railties/lib/rails/all.rb @@ -5,6 +5,7 @@ require "rails"    action_controller    action_view    action_mailer +  active_job    rails/test_unit    sprockets  ).each do |framework| diff --git a/railties/lib/rails/api/task.rb b/railties/lib/rails/api/task.rb index 3e32576040..a082932632 100644 --- a/railties/lib/rails/api/task.rb +++ b/railties/lib/rails/api/task.rb @@ -50,6 +50,13 @@ module Rails            )          }, +        'activejob' => { +          :include => %w( +            README.md +            lib/active_job/**/*.rb +          ) +        }, +          'railties' => {            :include => %w(              README.rdoc @@ -145,19 +152,5 @@ module Rails          File.read('RAILS_VERSION').strip        end      end - -    class AppTask < Task -      def component_root_dir(gem_name) -        $:.grep(%r{#{gem_name}[\w.-]*/lib\z}).first[0..-5] -      end - -      def api_dir -        'doc/api' -      end - -      def rails_version -        Rails::VERSION::STRING -      end -    end    end  end diff --git a/railties/lib/rails/app_rails_loader.rb b/railties/lib/rails/app_rails_loader.rb index 56f05b3844..39d8007333 100644 --- a/railties/lib/rails/app_rails_loader.rb +++ b/railties/lib/rails/app_rails_loader.rb @@ -2,6 +2,8 @@ require 'pathname'  module Rails    module AppRailsLoader +    extend self +      RUBY = Gem.ruby      EXECUTABLES = ['bin/rails', 'script/rails']      BUNDLER_WARNING = <<EOS @@ -26,7 +28,7 @@ generate it and add it to source control:  EOS -    def self.exec_app_rails +    def exec_app_rails        original_cwd = Dir.pwd        loop do @@ -54,7 +56,7 @@ EOS        end      end -    def self.find_executable +    def find_executable        EXECUTABLES.find { |exe| File.file?(exe) }      end    end diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 362713eb75..b11815e013 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -87,7 +87,20 @@ module Rails      class << self        def inherited(base)          super -        base.instance +        Rails.app_class = base +        add_lib_to_load_path!(find_root(base.called_from)) +      end + +      def instance +        super.run_load_hooks! +      end + +      def create(initial_variable_values = {}, &block) +        new(initial_variable_values, &block).run_load_hooks! +      end + +      def find_root(from) +        find_root_with_flag "config.ru", from, Dir.pwd        end        # Makes the +new+ method public. @@ -116,24 +129,31 @@ module Rails        @ordered_railties  = nil        @railties          = nil        @message_verifiers = {} +      @ran_load_hooks    = false + +      # are these actually used? +      @initial_variable_values = initial_variable_values +      @block = block +    end -      Rails.application ||= self +    # Returns true if the application is initialized. +    def initialized? +      @initialized +    end -      add_lib_to_load_path! +    def run_load_hooks! # :nodoc: +      return self if @ran_load_hooks +      @ran_load_hooks = true        ActiveSupport.run_load_hooks(:before_configuration, self) -      initial_variable_values.each do |variable_name, value| +      @initial_variable_values.each do |variable_name, value|          if INITIAL_VARIABLES.include?(variable_name)            instance_variable_set("@#{variable_name}", value)          end        end -      instance_eval(&block) if block_given? -    end - -    # Returns true if the application is initialized. -    def initialized? -      @initialized +      instance_eval(&@block) if @block +      self      end      # Implements call according to the Rack API. It simply @@ -158,7 +178,7 @@ module Rails            key_generator = ActiveSupport::KeyGenerator.new(secrets.secret_key_base, iterations: 1000)            ActiveSupport::CachingKeyGenerator.new(key_generator)          else -          ActiveSupport::LegacyKeyGenerator.new(config.secret_token) +          ActiveSupport::LegacyKeyGenerator.new(secrets.secret_token)          end      end @@ -187,6 +207,38 @@ module Rails        end      end +    # Convenience for loading config/foo.yml for the current Rails env. +    # +    # Example: +    # +    #     # config/exception_notification.yml: +    #     production: +    #       url: http://127.0.0.1:8080 +    #       namespace: my_app_production +    #     development: +    #       url: http://localhost:3001 +    #       namespace: my_app_development +    # +    #     # config/production.rb +    #     Rails.application.configure do +    #       config.middleware.use ExceptionNotifier, config_for(:exception_notification) +    #     end +    def config_for(name) +      yaml = Pathname.new("#{paths["config"].existent.first}/#{name}.yml") + +      if yaml.exist? +        require "yaml" +        require "erb" +        (YAML.load(ERB.new(yaml.read).result) || {})[Rails.env] || {} +      else +        raise "Could not load configuration. No such file - #{yaml}" +      end +    rescue Psych::SyntaxError => e +      raise "YAML syntax error occurred while parsing #{yaml}. " \ +        "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \ +        "Error: #{e.message}" +    end +      # Stores some of the Rails initial environment parameters which      # will be used by middlewares and engines to configure themselves.      def env_config @@ -196,7 +248,7 @@ module Rails          super.merge({            "action_dispatch.parameter_filter" => config.filter_parameters,            "action_dispatch.redirect_filter" => config.filter_redirect, -          "action_dispatch.secret_token" => config.secret_token, +          "action_dispatch.secret_token" => secrets.secret_token,            "action_dispatch.secret_key_base" => secrets.secret_key_base,            "action_dispatch.show_exceptions" => config.action_dispatch.show_exceptions,            "action_dispatch.show_detailed_exceptions" => config.consider_all_requests_local, @@ -207,7 +259,8 @@ module Rails            "action_dispatch.signed_cookie_salt" => config.action_dispatch.signed_cookie_salt,            "action_dispatch.encrypted_cookie_salt" => config.action_dispatch.encrypted_cookie_salt,            "action_dispatch.encrypted_signed_cookie_salt" => config.action_dispatch.encrypted_signed_cookie_salt, -          "action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer +          "action_dispatch.cookies_serializer" => config.action_dispatch.cookies_serializer, +          "action_dispatch.cookies_digest" => config.action_dispatch.cookies_digest          })        end      end @@ -263,8 +316,8 @@ module Rails      # are changing config.root inside your application definition or having a custom      # Rails application, you will need to add lib to $LOAD_PATH on your own in case      # you need to load files in lib/ during the application configuration as well. -    def add_lib_to_load_path! #:nodoc: -      path = File.join config.root, 'lib' +    def self.add_lib_to_load_path!(root) #:nodoc: +      path = File.join root, 'lib'        if File.exist?(path) && !$LOAD_PATH.include?(path)          $LOAD_PATH.unshift(path)        end @@ -308,14 +361,28 @@ module Rails      end      def config #:nodoc: -      @config ||= Application::Configuration.new(find_root_with_flag("config.ru", Dir.pwd)) +      @config ||= Application::Configuration.new(self.class.find_root(self.class.called_from))      end      def config=(configuration) #:nodoc:        @config = configuration      end -    def secrets #:nodoc: +    # Returns secrets added to config/secrets.yml. +    # +    # Example: +    # +    #     development: +    #       secret_key_base: 836fa3665997a860728bcb9e9a1e704d427cfc920e79d847d79c8a9a907b9e965defa4154b2b86bdec6930adbe33f21364523a6f6ce363865724549fdfc08553 +    #     test: +    #       secret_key_base: 5a37811464e7d378488b0f073e2193b093682e4e21f5d6f3ae0a4e1781e61a351fdc878a843424e81c73fb484a40d23f92c8dafac4870e74ede6e5e174423010 +    #     production: +    #       secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> +    #       namespace: my_app_production +    # +    # +Rails.application.secrets.namespace+ returns +my_app_production+ in the +    # production environment. +    def secrets        @secrets ||= begin          secrets = ActiveSupport::OrderedOptions.new          yaml = config.paths["config/secrets"].first @@ -328,6 +395,8 @@ module Rails          # Fallback to config.secret_key_base if secrets.secret_key_base isn't set          secrets.secret_key_base ||= config.secret_key_base +        # Fallback to config.secret_token if secrets.secret_token isn't set +        secrets.secret_token ||= config.secret_token          secrets        end @@ -351,21 +420,18 @@ module Rails      console do        unless ::Kernel.private_method_defined?(:y) -        if RUBY_VERSION >= '2.0' -          require "psych/y" -        else -          module ::Kernel -            def y(*objects) -              puts ::Psych.dump_stream(*objects) -            end -            private :y -          end -        end +        require "psych/y"        end      end +    # Return an array of railties respecting the order they're loaded +    # and the order specified by the +railties_order+ config. +    # +    # While when running initializers we need engines in reverse +    # order here when copying migrations from railties we need them in the same +    # order as given by +railties_order+.      def migration_railties # :nodoc: -      (ordered_railties & railties_without_main_app).reverse +      ordered_railties.flatten - [self]      end    protected @@ -398,11 +464,6 @@ module Rails        super      end -    def railties_without_main_app # :nodoc: -      @railties_without_main_app ||= Rails::Railtie.subclasses.map(&:instance) + -        Rails::Engine.subclasses.map(&:instance) -    end -      # Returns the ordered railties for this application considering railties_order.      def ordered_railties #:nodoc:        @ordered_railties ||= begin @@ -422,13 +483,13 @@ module Rails          index = order.index(:all)          order[index] = all -        order.reverse.flatten +        order        end      end      def railties_initializers(current) #:nodoc:        initializers = [] -      ordered_railties.each do |r| +      ordered_railties.reverse.flatten.each do |r|          if r == self            initializers += current          else @@ -456,8 +517,13 @@ module Rails      end      def validate_secret_key_config! #:nodoc: -      if secrets.secret_key_base.blank? && config.secret_token.blank? -        raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`" +      if secrets.secret_key_base.blank? +        ActiveSupport::Deprecation.warn "You didn't set `secret_key_base`. " + +          "Read the upgrade documentation to learn more about this new config option." + +        if secrets.secret_token.blank? +          raise "Missing `secret_token` and `secret_key_base` for '#{Rails.env}' environment, set these values in `config/secrets.yml`" +        end        end      end    end diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb index a26d41c0cf..0f4d932749 100644 --- a/railties/lib/rails/application/bootstrap.rb +++ b/railties/lib/rails/application/bootstrap.rb @@ -47,7 +47,8 @@ INFO            logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDERR))            logger.level = ActiveSupport::Logger::WARN            logger.warn( -            "Rails Error: Unable to access log file. Please ensure that #{path} exists and is chmod 0666. " + +            "Rails Error: Unable to access log file. Please ensure that #{path} exists and is writable " + +            "(ie, make it writable for user and group: chmod 0664 #{path}). " +              "The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."            )            logger diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 5e8f4de847..dc3ec4274b 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -6,14 +6,14 @@ require 'rails/source_annotation_extractor'  module Rails    class Application      class Configuration < ::Rails::Engine::Configuration -      attr_accessor :allow_concurrency, :asset_host, :assets, :autoflush_log, +      attr_accessor :allow_concurrency, :asset_host, :autoflush_log,                      :cache_classes, :cache_store, :consider_all_requests_local, :console,                      :eager_load, :exceptions_app, :file_watcher, :filter_parameters,                      :force_ssl, :helpers_paths, :logger, :log_formatter, :log_tags,                      :railties_order, :relative_url_root, :secret_key_base, :secret_token, -                    :serve_static_assets, :ssl_options, :static_cache_control, :session_options, +                    :serve_static_files, :ssl_options, :static_cache_control, :session_options,                      :time_zone, :reload_classes_only_on_change, -                    :beginning_of_week, :filter_redirect +                    :beginning_of_week, :filter_redirect, :x        attr_writer :log_level        attr_reader :encoding @@ -26,7 +26,7 @@ module Rails          @filter_parameters             = []          @filter_redirect               = []          @helpers_paths                 = [] -        @serve_static_assets           = true +        @serve_static_files            = true          @static_cache_control          = nil          @force_ssl                     = false          @ssl_options                   = {} @@ -48,21 +48,7 @@ module Rails          @eager_load                    = nil          @secret_token                  = nil          @secret_key_base               = nil - -        @assets = ActiveSupport::OrderedOptions.new -        @assets.enabled                  = true -        @assets.paths                    = [] -        @assets.precompile               = [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) }, -                                             /(?:\/|\\|\A)application\.(css|js)$/ ] -        @assets.prefix                   = "/assets" -        @assets.version                  = '1.0' -        @assets.debug                    = false -        @assets.compile                  = true -        @assets.digest                   = false -        @assets.cache_store              = [ :file_store, "#{root}/tmp/cache/assets/#{Rails.env}/" ] -        @assets.js_compressor            = nil -        @assets.css_compressor           = nil -        @assets.logger                   = nil +        @x                             = Custom.new        end        def encoding=(value) @@ -92,9 +78,10 @@ module Rails        # Loads and returns the entire raw configuration of database from        # values stored in `config/database.yml`.        def database_configuration -        yaml = Pathname.new(paths["config/database"].existent.first || "") +        path = paths["config/database"].existent.first +        yaml = Pathname.new(path) if path -        config = if yaml.exist? +        config = if yaml && yaml.exist?            require "yaml"            require "erb"            YAML.load(ERB.new(yaml.read).result) || {} @@ -103,7 +90,7 @@ module Rails            # by Active Record.            {}          else -          raise "Could not load database configuration. No such file - #{yaml}" +          raise "Could not load database configuration. No such file - #{paths["config/database"].instance_variable_get(:@paths)}"          end          config @@ -116,7 +103,7 @@ module Rails        end        def log_level -        @log_level ||= Rails.env.production? ? :info : :debug +        @log_level ||= (Rails.env.production? ? :info : :debug)        end        def colorize_logging @@ -154,6 +141,23 @@ module Rails        def annotations          SourceAnnotationExtractor::Annotation        end + +      private +        class Custom #:nodoc: +          def initialize +            @configurations = Hash.new +          end + +          def method_missing(method, *args) +            if method =~ /=$/ +              @configurations[$`.to_sym] = args.first +            else +              @configurations.fetch(method) { +                @configurations[method] = ActiveSupport::OrderedOptions.new +              } +            end +          end +        end      end    end  end diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb index a00afe008c..02eea82b0c 100644 --- a/railties/lib/rails/application/default_middleware_stack.rb +++ b/railties/lib/rails/application/default_middleware_stack.rb @@ -17,7 +17,7 @@ module Rails            middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header -          if config.serve_static_assets +          if config.serve_static_files              middleware.use ::ActionDispatch::Static, paths["public"].first, config.static_cache_control            end @@ -66,7 +66,11 @@ module Rails          end          def allow_concurrency? -          config.allow_concurrency.nil? ? config.cache_classes : config.allow_concurrency +          if config.allow_concurrency.nil? +            config.cache_classes && config.eager_load +          else +            config.allow_concurrency +          end          end          def load_rack_cache diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index 5b8509b2e9..0599e988d9 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -22,8 +22,6 @@ module Rails        initializer :add_builtin_route do |app|          if Rails.env.development?            app.routes.append do -            get '/rails/mailers'         => "rails/mailers#index" -            get '/rails/mailers/*path'   => "rails/mailers#preview"              get '/rails/info/properties' => "rails/info#properties"              get '/rails/info/routes'     => "rails/info#routes"              get '/rails/info'            => "rails/info#index" @@ -110,6 +108,13 @@ module Rails            ActionDispatch::Reloader.to_cleanup(&callback)          end        end + +      # Disable dependency loading during request cycle +      initializer :disable_dependency_loading do +        if config.eager_load && config.cache_classes +          ActiveSupport::Dependencies.unhook! +        end +      end      end    end  end diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 737977adf9..cf0a4e128f 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -41,9 +41,7 @@ module Rails        end        def finalize! -        route_sets.each do |routes| -          routes.finalize! -        end +        route_sets.each(&:finalize!)        end        def revert diff --git a/railties/lib/rails/backtrace_cleaner.rb b/railties/lib/rails/backtrace_cleaner.rb index 8cc8eb1103..5276eb33c9 100644 --- a/railties/lib/rails/backtrace_cleaner.rb +++ b/railties/lib/rails/backtrace_cleaner.rb @@ -4,12 +4,16 @@ module Rails    class BacktraceCleaner < ActiveSupport::BacktraceCleaner      APP_DIRS_PATTERN = /^\/?(app|config|lib|test)/      RENDER_TEMPLATE_PATTERN = /:in `_render_template_\w*'/ +    EMPTY_STRING = ''.freeze +    SLASH        = '/'.freeze +    DOT_SLASH    = './'.freeze      def initialize        super -      add_filter   { |line| line.sub("#{Rails.root}/", '') } -      add_filter   { |line| line.sub(RENDER_TEMPLATE_PATTERN, '') } -      add_filter   { |line| line.sub('./', '/') } # for tests +      @root = "#{Rails.root}/".freeze +      add_filter { |line| line.sub(@root, EMPTY_STRING) } +      add_filter { |line| line.sub(RENDER_TEMPLATE_PATTERN, EMPTY_STRING) } +      add_filter { |line| line.sub(DOT_SLASH, SLASH) } # for tests        add_gem_filters        add_silencer { |line| line !~ APP_DIRS_PATTERN } @@ -21,7 +25,8 @@ module Rails          return if gems_paths.empty?          gems_regexp = %r{(#{gems_paths.join('|')})/gems/([^/]+)-([\w.]+)/(.*)} -        add_filter { |line| line.sub(gems_regexp, '\2 (\3) \4') } +        gems_result = '\2 (\3) \4'.freeze +        add_filter { |line| line.sub(gems_regexp, gems_result) }        end    end  end diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb index 0ae6d2a455..0bdf63943f 100644 --- a/railties/lib/rails/code_statistics.rb +++ b/railties/lib/rails/code_statistics.rb @@ -6,9 +6,8 @@ class CodeStatistics #:nodoc:                  'Helper tests',                  'Model tests',                  'Mailer tests', -                'Integration tests', -                'Functional tests (old)', -                'Unit tests (old)'] +                'Job tests', +                'Integration tests']    def initialize(*pairs)      @pairs      = pairs diff --git a/railties/lib/rails/code_statistics_calculator.rb b/railties/lib/rails/code_statistics_calculator.rb index 60e4aef9b7..a142236dbe 100644 --- a/railties/lib/rails/code_statistics_calculator.rb +++ b/railties/lib/rails/code_statistics_calculator.rb @@ -24,6 +24,8 @@ class CodeStatisticsCalculator #:nodoc:      }    } +  PATTERNS[:minitest] = PATTERNS[:rb].merge method: /^\s*(def|test)\s+['"_a-z]/ +    def initialize(lines = 0, code_lines = 0, classes = 0, methods = 0)      @lines = lines      @code_lines = code_lines @@ -74,6 +76,10 @@ class CodeStatisticsCalculator #:nodoc:    private      def file_type(file_path) -      File.extname(file_path).sub(/\A\./, '').downcase.to_sym +      if file_path.end_with? '_test.rb' +        :minitest +      else +        File.extname(file_path).sub(/\A\./, '').downcase.to_sym +      end      end  end diff --git a/railties/lib/rails/commands/commands_tasks.rb b/railties/lib/rails/commands/commands_tasks.rb index 6cfbc70c51..8bae08e44e 100644 --- a/railties/lib/rails/commands/commands_tasks.rb +++ b/railties/lib/rails/commands/commands_tasks.rb @@ -127,7 +127,7 @@ EOT          require 'rails/generators'          require_application_and_environment!          Rails.application.load_generators -        require "rails/commands/#{command}" +        require_command!(command)        end        # Change to the application's path if there is no config.ru file in current directory. diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 555d8f31e1..5d37a2b699 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -18,14 +18,6 @@ module Rails            opt.on("-e", "--environment=name", String,                    "Specifies the environment to run this console under (test/development/production).",                    "Default: development") { |v| options[:environment] = v.strip } -          opt.on("--debugger", 'Enable the debugger.') do |v| -            if RUBY_VERSION < '2.0.0' -              options[:debugger] = v -            else -              puts "=> Notice: debugger option is ignored since ruby 2.0 and " \ -                   "it will be removed in future versions" -            end -          end            opt.parse!(arguments)          end @@ -76,25 +68,7 @@ module Rails        Rails.env = environment      end -    if RUBY_VERSION < '2.0.0' -      def debugger? -        options[:debugger] -      end - -      def require_debugger -        require 'debugger' -        puts "=> Debugger enabled" -      rescue LoadError -        puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again." -        exit(1) -      end -    end -      def start -      if RUBY_VERSION < '2.0.0' -        require_debugger if debugger? -      end -        set_environment! if environment?        if sandbox? @@ -105,7 +79,7 @@ module Rails        end        if defined?(console::ExtendCommandBundle) -        console::ExtendCommandBundle.send :include, Rails::ConsoleMethods +        console::ExtendCommandBundle.include(Rails::ConsoleMethods)        end        console.start      end diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 1a2613a8d0..5175e31f14 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -1,7 +1,6 @@  require 'erb'  require 'yaml'  require 'optparse' -require 'rbconfig'  module Rails    class DBConsole @@ -44,7 +43,7 @@ module Rails          find_cmd_and_exec(['mysql', 'mysql5'], *args) -      when "postgresql", "postgres", "postgis" +      when /^postgres|^postgis/          ENV['PGUSER']     = config["username"] if config["username"]          ENV['PGHOST']     = config["host"] if config["host"]          ENV['PGPORT']     = config["port"].to_s if config["port"] @@ -74,6 +73,21 @@ module Rails          find_cmd_and_exec('sqlplus', logon) +      when "sqlserver" +        args = [] + +        args += ["-D", "#{config['database']}"] if config['database'] +        args += ["-U", "#{config['username']}"] if config['username'] +        args += ["-P", "#{config['password']}"] if config['password'] + +        if config['host'] +          host_arg = "#{config['host']}" +          host_arg << ":#{config['port']}" if config['port'] +          args += ["-S", host_arg] +        end + +        find_cmd_and_exec("sqsh", *args) +        else          abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!"        end @@ -157,13 +171,15 @@ module Rails        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/ +      unless (ext = RbConfig::CONFIG['EXEEXT']).empty? +        commands = commands.map{|cmd| "#{cmd}#{ext}"} +      end        full_path_command = nil        found = commands.detect do |cmd|          dirs_on_path.detect do |path|            full_path_command = File.join(path, cmd) -          File.executable? full_path_command +          File.file?(full_path_command) && File.executable?(full_path_command)          end        end diff --git a/railties/lib/rails/commands/destroy.rb b/railties/lib/rails/commands/destroy.rb index 5479da86a0..ce26cc3fde 100644 --- a/railties/lib/rails/commands/destroy.rb +++ b/railties/lib/rails/commands/destroy.rb @@ -1,5 +1,7 @@  require 'rails/generators' +#if no argument/-h/--help is passed to rails destroy command, then +#it generates the help associated.  if [nil, "-h", "--help"].include?(ARGV.first)    Rails::Generators.help 'destroy'    exit diff --git a/railties/lib/rails/commands/generate.rb b/railties/lib/rails/commands/generate.rb index 351c59c645..926c36b967 100644 --- a/railties/lib/rails/commands/generate.rb +++ b/railties/lib/rails/commands/generate.rb @@ -1,5 +1,7 @@  require 'rails/generators' +#if no argument/-h/--help is passed to rails generate command, then +#it generates the help associated.  if [nil, "-h", "--help"].include?(ARGV.first)    Rails::Generators.help 'generate'    exit diff --git a/railties/lib/rails/commands/plugin.rb b/railties/lib/rails/commands/plugin.rb index 95bbdd4cdf..52d8966ead 100644 --- a/railties/lib/rails/commands/plugin.rb +++ b/railties/lib/rails/commands/plugin.rb @@ -11,7 +11,7 @@ else                end      if File.exist?(railsrc)        extra_args_string = File.read(railsrc) -      extra_args = extra_args_string.split(/\n+/).flat_map {|l| l.split} +      extra_args = extra_args_string.split(/\n+/).flat_map(&:split)        puts "Using #{extra_args.join(" ")} from #{railsrc}"        ARGV.insert(1, *extra_args)      end diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 3a71f8d3f8..86bce9b2fe 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -1,5 +1,4 @@  require 'optparse' -require 'rbconfig'  options = { environment: (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup }  code_or_file = nil diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 6146b6c1db..546d3725d8 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -9,23 +9,25 @@ module Rails        def parse!(args)          args, options = args.dup, {} -        opt_parser = OptionParser.new do |opts| -          opts.banner = "Usage: rails server [mongrel, thin, etc] [options]" +        option_parser(options).parse! args + +        options[:log_stdout] = options[:daemonize].blank? && (options[:environment] || Rails.env) == "development" +        options[:server]     = args.shift +        options +      end + +      private + +      def option_parser(options) +        OptionParser.new do |opts| +          opts.banner = "Usage: rails server [mongrel, thin etc] [options]"            opts.on("-p", "--port=port", Integer,                    "Runs Rails on the specified port.", "Default: 3000") { |v| options[:Port] = v } -          opts.on("-b", "--binding=ip", String, -                  "Binds Rails to the specified ip.", "Default: 0.0.0.0") { |v| options[:Host] = v } +          opts.on("-b", "--binding=IP", String, +                  "Binds Rails to the specified IP.", "Default: localhost") { |v| options[:Host] = v }            opts.on("-c", "--config=file", String, -                  "Use custom rackup configuration file") { |v| options[:config] = v } -          opts.on("-d", "--daemon", "Make server run as a Daemon.") { options[:daemonize] = true } -          opts.on("-u", "--debugger", "Enable the debugger") do -            if RUBY_VERSION < '2.0.0' -              options[:debugger] = true -            else -              puts "=> Notice: debugger option is ignored since ruby 2.0 and " \ -                   "it will be removed in future versions" -            end -          end +                  "Uses a custom rackup configuration.") { |v| options[:config] = v } +          opts.on("-d", "--daemon", "Runs server as a Daemon.") { options[:daemonize] = true }            opts.on("-e", "--environment=name", String,                    "Specifies the environment to run this server under (test/development/production).",                    "Default: development") { |v| options[:environment] = v } @@ -35,14 +37,8 @@ module Rails            opts.separator "" -          opts.on("-h", "--help", "Show this help message.") { puts opts; exit } +          opts.on("-h", "--help", "Shows this help message.") { puts opts; exit }          end - -        opt_parser.parse! args - -        options[:log_stdout] = options[:daemonize].blank? && (options[:environment] || Rails.env) == "development" -        options[:server]     = args.shift -        options        end      end @@ -82,9 +78,6 @@ module Rails      def middleware        middlewares = [] -      if RUBY_VERSION < '2.0.0' -        middlewares << [Rails::Rack::Debugger] if options[:debugger] -      end        middlewares << [::Rack::ContentLength]        # FIXME: add Rack::Lock in the case people are using webrick. @@ -98,17 +91,12 @@ module Rails        Hash.new(middlewares)      end -    def log_path -      "log/#{options[:environment]}.log" -    end -      def default_options        super.merge({          Port:               3000,          DoNotReverseLookup: true,          environment:        (ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "development").dup,          daemonize:          false, -        debugger:           false,          pid:                File.expand_path("tmp/pids/server.pid"),          config:             File.expand_path("config.ru")        }) @@ -122,15 +110,11 @@ module Rails          puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}"          puts "=> Run `rails server -h` for more startup options" -        if options[:Host].to_s.match(/0\.0\.0\.0/) -          puts "=> Notice: server is listening on all interfaces (#{options[:Host]}). Consider using 127.0.0.1 (--binding option)" -        end -          puts "=> Ctrl-C to shutdown server" unless options[:daemonize]        end        def create_tmp_directories -        %w(cache pids sessions sockets).each do |dir_to_make| +        %w(cache pids sockets).each do |dir_to_make|            FileUtils.mkdir_p(File.join(Rails.root, 'tmp', dir_to_make))          end        end diff --git a/railties/lib/rails/commands/update.rb b/railties/lib/rails/commands/update.rb deleted file mode 100644 index 59fae5c337..0000000000 --- a/railties/lib/rails/commands/update.rb +++ /dev/null @@ -1,9 +0,0 @@ -require File.expand_path(File.join(File.dirname(__FILE__), '..', 'generators')) - -if ARGV.size == 0 -  Rails::Generators.help -  exit -end - -name = ARGV.shift -Rails::Generators.invoke name, ARGV, behavior: :skip diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index f5d7dede66..f99cec04c5 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -18,11 +18,11 @@ module Rails      # This will put the <tt>Magical::Unicorns</tt> middleware on the end of the stack.      # You can use +insert_before+ if you wish to add a middleware before another:      # -    #     config.middleware.insert_before ActionDispatch::Head, Magical::Unicorns +    #     config.middleware.insert_before Rack::Head, Magical::Unicorns      #      # There's also +insert_after+ which will insert a middleware after another:      # -    #     config.middleware.insert_after ActionDispatch::Head, Magical::Unicorns +    #     config.middleware.insert_after Rack::Head, Magical::Unicorns      #      # Middlewares can also be completely swapped out and replaced with others:      # diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb deleted file mode 100644 index 89f54069e9..0000000000 --- a/railties/lib/rails/deprecation.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'active_support/deprecation/proxy_wrappers' - -module Rails -  class DeprecatedConstant < ActiveSupport::Deprecation::DeprecatedConstantProxy -    def self.deprecate(old, current) -      # double assignment is used to avoid "assigned but unused variable" warning -      constant = constant = new(old, current) -      eval "::#{old} = constant" -    end - -    private - -    def target -      ::Kernel.eval @new_const.to_s -    end -  end - -  DeprecatedConstant.deprecate('RAILS_CACHE', '::Rails.cache') -end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index b36ab3d0d5..e1d5caf790 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -110,8 +110,8 @@ module Rails    #    # == Endpoint    # -  # An engine can be also a rack application. It can be useful if you have a rack application that -  # you would like to wrap with +Engine+ and provide some of the +Engine+'s features. +  # An engine can also be a rack application. It can be useful if you have a rack application that +  # you would like to wrap with +Engine+ and provide with some of the +Engine+'s features.    #    # To do that, use the +endpoint+ method:    # @@ -217,7 +217,7 @@ module Rails    # <tt>url_helpers</tt> from <tt>MyEngine::Engine.routes</tt>.    #    # The next thing that changes in isolated engines is the behavior of routes. Normally, when you namespace -  # your controllers, you also need to do namespace all your routes. With an isolated engine, +  # your controllers, you also need to namespace all your routes. With an isolated engine,    # the namespace is applied by default, so you can ignore it in routes:    #    #   MyEngine::Engine.routes.draw do @@ -296,7 +296,7 @@ module Rails    #     helper MyEngine::SharedEngineHelper    #   end    # -  # If you want to include all of the engine's helpers, you can use #helper method on an engine's +  # If you want to include all of the engine's helpers, you can use the #helper method on an engine's    # instance:    #    #   class ApplicationController < ActionController::Base @@ -312,7 +312,7 @@ module Rails    # Engines can have their own migrations. The default path for migrations is exactly the same    # as in application: <tt>db/migrate</tt>    # -  # To use engine's migrations in application you can use rake task, which copies them to +  # To use engine's migrations in application you can use the rake task below, which copies them to    # application's dir:    #    #   rake ENGINE_NAME:install:migrations @@ -328,7 +328,7 @@ module Rails    #    # == Loading priority    # -  # In order to change engine's priority you can use +config.railties_order+ in main application. +  # In order to change engine's priority you can use +config.railties_order+ in the main application.    # It will affect the priority of loading views, helpers, assets and all the other files    # related to engine or application.    # @@ -351,7 +351,7 @@ module Rails            base.called_from = begin              call_stack = if Kernel.respond_to?(:caller_locations) -              caller_locations.map(&:path) +              caller_locations.map { |l| l.absolute_path || l.path }              else                # Remove the line number from backtraces making sure we don't leave anything behind                caller.map { |p| p.sub(/:\d+.*/, '') } @@ -364,6 +364,10 @@ module Rails          super        end +      def find_root(from) +        find_root_with_flag "lib", from +      end +        def endpoint(endpoint = nil)          @endpoint ||= nil          @endpoint = endpoint if endpoint @@ -395,7 +399,7 @@ module Rails              end              unless mod.respond_to?(:railtie_routes_url_helpers) -              define_method(:railtie_routes_url_helpers) { railtie.routes.url_helpers } +              define_method(:railtie_routes_url_helpers) {|include_path_helpers = true| railtie.routes.url_helpers(include_path_helpers) }              end            end          end @@ -480,7 +484,7 @@ module Rails          helpers = Module.new          all = ActionController::Base.all_helpers_from_path(helpers_paths)          ActionController::Base.modules_for_helpers(all).each do |mod| -          helpers.send(:include, mod) +          helpers.include(mod)          end          helpers        end @@ -509,7 +513,7 @@ module Rails      def call(env)        env.merge!(env_config)        if env['SCRIPT_NAME'] -        env.merge! "ROUTES_#{routes.object_id}_SCRIPT_NAME" => env['SCRIPT_NAME'].dup +        env["ROUTES_#{routes.object_id}_SCRIPT_NAME"] = env['SCRIPT_NAME'].dup        end        app.call(env)      end @@ -531,7 +535,7 @@ module Rails      # Define the configuration object for the engine.      def config -      @config ||= Engine::Configuration.new(find_root_with_flag("lib")) +      @config ||= Engine::Configuration.new(self.class.find_root(self.class.called_from))      end      # Load data from db/seeds.rb file. It can be used in to load engines' @@ -567,10 +571,10 @@ module Rails      end      initializer :add_routing_paths do |app| -      paths = self.paths["config/routes.rb"].existent +      routing_paths = self.paths["config/routes.rb"].existent -      if routes? || paths.any? -        app.routes_reloader.paths.unshift(*paths) +      if routes? || routing_paths.any? +        app.routes_reloader.paths.unshift(*routing_paths)          app.routes_reloader.route_sets << routes        end      end @@ -595,12 +599,6 @@ module Rails        end      end -    initializer :append_assets_path, group: :all do |app| -      app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories) -      app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories) -      app.config.assets.paths.unshift(*paths["app/assets"].existent_directories) -    end -      initializer :prepend_helpers_path do |app|        if !isolated? || (app == self)          app.config.helpers_paths.unshift(*paths["app/helpers"].existent) @@ -658,8 +656,7 @@ module Rails        paths["db/migrate"].existent.any?      end -    def find_root_with_flag(flag, default=nil) #:nodoc: -      root_path = self.class.called_from +    def self.find_root_with_flag(flag, root_path, default=nil) #:nodoc:        while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}")          parent = File.dirname(root_path) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 10d1821709..62a4139d07 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -39,7 +39,7 @@ module Rails          @paths ||= begin            paths = Rails::Paths::Root.new(@root) -          paths.add "app",                 eager_load: true, glob: "*" +          paths.add "app",                 eager_load: true, glob: "{*,*/concerns}"            paths.add "app/assets",          glob: "*"            paths.add "app/controllers",     eager_load: true            paths.add "app/helpers",         eager_load: true @@ -47,9 +47,6 @@ module Rails            paths.add "app/mailers",         eager_load: true            paths.add "app/views" -          paths.add "app/controllers/concerns", eager_load: true -          paths.add "app/models/concerns",      eager_load: true -            paths.add "lib",                 load_path: true            paths.add "lib/assets",          glob: "*"            paths.add "lib/tasks",           glob: "**/*.rake" diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index c7397c4f15..7d74b1bfe5 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -5,8 +5,8 @@ module Rails    end    module VERSION -    MAJOR = 4 -    MINOR = 2 +    MAJOR = 5 +    MINOR = 0      TINY  = 0      PRE   = "alpha" diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index bf2390cb7e..db8b184213 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -153,10 +153,10 @@ module Rails      def self.invoke(namespace, args=ARGV, config={})        names = namespace.to_s.split(':')        if klass = find_by_namespace(names.pop, names.any? && names.join(':')) -        args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? } +        args << "--help" if args.empty? && klass.arguments.any?(&:required?)          klass.start(args, config)        else -        options     = sorted_groups.map(&:last).flatten +        options     = sorted_groups.flat_map(&:last)          suggestions = options.sort_by {|suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)          msg =  "Could not find generator '#{namespace}'. "          msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.join(" or ") }\n" @@ -226,7 +226,7 @@ module Rails      def self.public_namespaces        lookup! -      subclasses.map { |k| k.namespace } +      subclasses.map(&:namespace)      end      def self.print_generators @@ -286,7 +286,7 @@ module Rails            d[m] = x          end -        return x +        x        end        # Prints a list of generators. diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index a239874df0..c1bc646c65 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -1,5 +1,4 @@  require 'open-uri' -require 'rbconfig'  module Rails    module Generators @@ -7,6 +6,7 @@ module Rails        def initialize(*) # :nodoc:          super          @in_group = nil +        @after_bundle_callbacks = []        end        # Adds an entry into +Gemfile+ for the supplied gem. @@ -84,10 +84,10 @@ module Rails        #   environment(nil, env: "development") do        #     "config.autoload_paths += %W(#{config.root}/extras)"        #   end -      def environment(data=nil, options={}, &block) +      def environment(data=nil, options={})          sentinel = /class [a-z_:]+ < Rails::Application/i          env_file_sentinel = /Rails\.application\.configure do/ -        data = block.call if !data && block_given? +        data = yield if !data && block_given?          in_root do            if options[:env].nil? @@ -188,7 +188,7 @@ module Rails        #   generate(:authenticated, "user session")        def generate(what, *args)          log :generate, what -        argument = args.flat_map {|arg| arg.to_s }.join(" ") +        argument = args.flat_map(&:to_s).join(" ")          in_root { run_ruby_script("bin/rails generate #{what} #{argument}", verbose: false) }        end @@ -218,10 +218,10 @@ module Rails        #   route "root 'welcome#index'"        def route(routing_code)          log :route, routing_code -        sentinel = /\.routes\.draw do\s*$/ +        sentinel = /\.routes\.draw do\s*\n/m          in_root do -          inject_into_file 'config/routes.rb', "\n  #{routing_code}", { after: sentinel, verbose: false } +          inject_into_file 'config/routes.rb', "  #{routing_code}", { after: sentinel, verbose: false, force: true }          end        end @@ -232,6 +232,16 @@ module Rails          log File.read(find_in_source_paths(path))        end +      # Registers a callback to be executed after bundle and spring binstubs +      # have run. +      # +      #   after_bundle do +      #     git add: '.' +      #   end +      def after_bundle(&block) +        @after_bundle_callbacks << block +      end +        protected          # Define log for backwards compatibility. If just one argument is sent, @@ -257,11 +267,13 @@ module Rails          # Surround string with single quotes if there is no quotes.          # Otherwise fall back to double quotes -        def quote(str) -          if str.include?("'") -            str.inspect +        def quote(value) +          return value.inspect unless value.is_a? String + +          if value.include?("'") +            value.inspect            else -            "'#{str}'" +            "'#{value}'"            end          end      end diff --git a/railties/lib/rails/generators/actions/create_migration.rb b/railties/lib/rails/generators/actions/create_migration.rb index cf3b7acfff..cffdef6ec9 100644 --- a/railties/lib/rails/generators/actions/create_migration.rb +++ b/railties/lib/rails/generators/actions/create_migration.rb @@ -39,7 +39,7 @@ module Rails          protected -        def on_conflict_behavior(&block) +        def on_conflict_behavior            options = base.options.merge(config)            if identical?              say_status :identical, :blue, relative_existing_migration @@ -48,14 +48,15 @@ module Rails              say_status :create, :green              unless pretend?                ::FileUtils.rm_rf(existing_migration) -              block.call +              yield              end            elsif options[:skip]              say_status :skip, :yellow            else              say_status :conflict, :red              raise Error, "Another migration is already named #{migration_file_name}: " + -                         "#{existing_migration}. Use --force to replace this migration file." +              "#{existing_migration}. Use --force to replace this migration " + +              "or --skip to ignore conflicted file."            end          end diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 569afe8104..253272c7dd 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -38,12 +38,13 @@ module Rails          class_option :skip_keeps,         type: :boolean, default: false,                                            desc: 'Skip source control .keep files' +        class_option :skip_action_mailer, type: :boolean, aliases: "-M", +                                          default: false, +                                          desc: "Skip Action Mailer files" +          class_option :skip_active_record, type: :boolean, aliases: '-O', default: false,                                            desc: 'Skip Active Record files' -        class_option :skip_action_view,   type: :boolean, aliases: '-V', default: false, -                                          desc: 'Skip Action View files' -          class_option :skip_sprockets,     type: :boolean, aliases: '-S', default: false,                                            desc: 'Skip Sprockets files' @@ -65,8 +66,11 @@ module Rails          class_option :edge,               type: :boolean, default: false,                                            desc: "Setup the #{name} with Gemfile pointing to Rails repository" -        class_option :skip_test_unit,     type: :boolean, aliases: '-T', default: false, -                                          desc: 'Skip Test::Unit files' +        class_option :skip_turbolinks,    type: :boolean, default: false, +                                          desc: 'Skip turbolinks gem' + +        class_option :skip_test,          type: :boolean, aliases: '-T', default: false, +                                          desc: 'Skip test files'          class_option :rc,                 type: :string, default: false,                                            desc: "Path to file containing extra configuration options for rails command" @@ -104,14 +108,13 @@ module Rails        end        def gemfile_entries -        [ rails_gemfile_entry, -          database_gemfile_entry, -          assets_gemfile_entry, -          javascript_gemfile_entry, -          jbuilder_gemfile_entry, -          sdoc_gemfile_entry, -          spring_gemfile_entry, -          @extra_entries].flatten.find_all(&@gem_filter) +        [rails_gemfile_entry, +         database_gemfile_entry, +         assets_gemfile_entry, +         javascript_gemfile_entry, +         jbuilder_gemfile_entry, +         psych_gemfile_entry, +         @extra_entries].flatten.find_all(&@gem_filter)        end        def add_gem_entry_filter @@ -123,7 +126,7 @@ module Rails        def builder          @builder ||= begin            builder_class = get_builder_class -          builder_class.send(:include, ActionMethods) +          builder_class.include(ActionMethods)            builder_class.new(self)          end        end @@ -164,7 +167,7 @@ module Rails        end        def include_all_railties? -        !options[:skip_active_record] && !options[:skip_action_view] && !options[:skip_test_unit] && !options[:skip_sprockets] +        options.values_at(:skip_active_record, :skip_action_mailer, :skip_test, :skip_sprockets).none?        end        def comment_if(value) @@ -180,8 +183,12 @@ module Rails            super          end -        def self.github(name, github, comment = nil) -          new(name, nil, comment, github: github) +        def self.github(name, github, branch = nil, comment = nil) +          if branch +            new(name, nil, comment, github: github, branch: branch) +          else +            new(name, nil, comment, github: github) +          end          end          def self.version(name, version, comment = nil) @@ -191,19 +198,19 @@ module Rails          def self.path(name, path, comment = nil)            new(name, nil, comment, path: path)          end - -        def padding(max_width) -          ' ' * (max_width - name.length + 2) -        end        end        def rails_gemfile_entry          if options.dev? -          [GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), -           GemfileEntry.github('arel', 'rails/arel')] +          [ +            GemfileEntry.path('rails', Rails::Generators::RAILS_DEV_PATH), +            GemfileEntry.github('arel', 'rails/arel') +          ]          elsif options.edge? -          [GemfileEntry.github('rails', 'rails/rails'), -           GemfileEntry.github('arel', 'rails/arel')] +          [ +            GemfileEntry.github('rails', 'rails/rails'), +            GemfileEntry.github('arel', 'rails/arel') +          ]          else            [GemfileEntry.version('rails',                              Rails::VERSION::STRING, @@ -242,16 +249,8 @@ module Rails          return [] if options[:skip_sprockets]          gems = [] -        if options.dev? || options.edge? -          gems << GemfileEntry.github('sprockets-rails', 'rails/sprockets-rails', -                                    'Use edge version of sprockets-rails') -          gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', -                                    'Use SCSS for stylesheets') -        else -          gems << GemfileEntry.version('sass-rails', -                                     '~> 4.0.3', +        gems << GemfileEntry.version('sass-rails', '~> 5.0',                                       'Use SCSS for stylesheets') -        end          gems << GemfileEntry.version('uglifier',                                     '>= 1.3.0', @@ -265,17 +264,12 @@ module Rails          GemfileEntry.version('jbuilder', '~> 2.0', comment)        end -      def sdoc_gemfile_entry -        comment = 'bundle exec rake doc:rails generates the API under doc/api.' -        GemfileEntry.new('sdoc', '~> 0.4.0', comment, group: :doc) -      end -        def coffee_gemfile_entry -        comment = 'Use CoffeeScript for .js.coffee assets and views' +        comment = 'Use CoffeeScript for .coffee assets and views'          if options.dev? || options.edge? -          GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', comment +          GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, comment          else -          GemfileEntry.version 'coffee-rails', '~> 4.0.0', comment +          GemfileEntry.version 'coffee-rails', '~> 4.1.0', comment          end        end @@ -285,10 +279,13 @@ module Rails          else            gems = [coffee_gemfile_entry, javascript_runtime_gemfile_entry]            gems << GemfileEntry.version("#{options[:javascript]}-rails", nil, -                                 "Use #{options[:javascript]} as the JavaScript library") +                                       "Use #{options[:javascript]} as the JavaScript library") + +          unless options[:skip_turbolinks] +            gems << GemfileEntry.version("turbolinks", nil, +             "Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks") +          end -          gems << GemfileEntry.version("turbolinks", nil, -            "Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks")            gems          end        end @@ -302,10 +299,12 @@ module Rails          end        end -      def spring_gemfile_entry -        return [] unless spring_install? -        comment = 'Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring' -        GemfileEntry.new('spring', nil, comment, group: :development) +      def psych_gemfile_entry +        return [] unless defined?(Rubinius) + +        comment = 'Use Psych as the YAML engine, instead of Syck, so serialized ' \ +                  'data can be read safely from different rubies (see http://git.io/uuLVag)' +        GemfileEntry.new('psych', '~> 2.0', comment, platforms: :rbx)        end        def bundle_command(command) @@ -337,7 +336,7 @@ module Rails        end        def spring_install? -        !options[:skip_spring] && Process.respond_to?(:fork) +        !options[:skip_spring] && Process.respond_to?(:fork) && !RUBY_PLATFORM.include?("cygwin")        end        def run_bundle diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 9af6435f23..813b8b629e 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -273,7 +273,7 @@ module Rails          # Use Rails default banner.          def self.banner -          "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]".gsub(/\s+/, ' ') +          "rails generate #{namespace.sub(/^rails:/,'')} #{self.arguments.map(&:usage).join(' ')} [options]".gsub(/\s+/, ' ')          end          # Sets the base_name taking into account the current class namespace. diff --git a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb index 66b17bd10e..7d27321610 100644 --- a/railties/lib/rails/generators/erb/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/erb/mailer/mailer_generator.rb @@ -1,8 +1,31 @@ -require 'rails/generators/erb/controller/controller_generator' +require 'rails/generators/erb'  module Erb # :nodoc:    module Generators # :nodoc: -    class MailerGenerator < ControllerGenerator # :nodoc: +    class MailerGenerator < Base # :nodoc: +      argument :actions, type: :array, default: [], banner: "method method" + +      def copy_view_files +        view_base_path = File.join("app/views", class_path, file_name) +        empty_directory view_base_path + +        if self.behavior == :invoke +          formats.each do |format| +            layout_path = File.join("app/views/layouts", filename_with_extensions("mailer", format)) +            template filename_with_extensions(:layout, format), layout_path +          end +        end + +        actions.each do |action| +          @action = action + +          formats.each do |format| +            @path = File.join(view_base_path, filename_with_extensions(action, format)) +            template filename_with_extensions(:view, format), @path +          end +        end +      end +        protected        def formats diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb new file mode 100644 index 0000000000..93110e74ad --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.html.erb @@ -0,0 +1,5 @@ +<html> +  <body> +    <%%= yield %> +  </body> +</html> diff --git a/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb new file mode 100644 index 0000000000..6363733e6e --- /dev/null +++ b/railties/lib/rails/generators/erb/mailer/templates/layout.text.erb @@ -0,0 +1 @@ +<%%= yield %> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb index da99e74435..d9713b0238 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb @@ -1,10 +1,10 @@ -<%%= form_for(@<%= singular_table_name %>) do |f| %> -  <%% if @<%= singular_table_name %>.errors.any? %> +<%%= form_for(<%= singular_table_name %>) do |f| %> +  <%% if <%= singular_table_name %>.errors.any? %>      <div id="error_explanation"> -      <h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2> +      <h2><%%= pluralize(<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>        <ul> -      <%% @<%= singular_table_name %>.errors.full_messages.each do |message| %> +      <%% <%= singular_table_name %>.errors.full_messages.each do |message| %>          <li><%%= message %></li>        <%% end %>        </ul> @@ -17,7 +17,7 @@      <%%= f.label :password %><br>      <%%= f.password_field :password %>    </div> -  <div> +  <div class="field">      <%%= f.label :password_confirmation %><br>      <%%= f.password_field :password_confirmation %>  <% else -%> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb index e58b9fbd08..81329473d9 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb @@ -1,6 +1,6 @@ -<h1>Editing <%= singular_table_name %></h1> +<h1>Editing <%= singular_table_name.titleize %></h1> -<%%= render 'form' %> +<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>  <%%= link_to 'Show', @<%= singular_table_name %> %> |  <%%= link_to 'Back', <%= index_helper %>_path %> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb index 814d6fdb0e..c3b8ef1181 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb @@ -1,4 +1,6 @@ -<h1>Listing <%= plural_table_name %></h1> +<p id="notice"><%%= notice %></p> + +<h1><%= plural_table_name.titleize %></h1>  <table>    <thead> diff --git a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb index 02ae4d015e..9b2b2f4875 100644 --- a/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb +++ b/railties/lib/rails/generators/erb/scaffold/templates/new.html.erb @@ -1,5 +1,5 @@ -<h1>New <%= singular_table_name %></h1> +<h1>New <%= singular_table_name.titleize %></h1> -<%%= render 'form' %> +<%%= render 'form', <%= singular_table_name %>: @<%= singular_table_name %> %>  <%%= link_to 'Back', <%= index_helper %>_path %> diff --git a/railties/lib/rails/generators/generated_attribute.rb b/railties/lib/rails/generators/generated_attribute.rb index c5326d70d1..8145a26e22 100644 --- a/railties/lib/rails/generators/generated_attribute.rb +++ b/railties/lib/rails/generators/generated_attribute.rb @@ -44,8 +44,11 @@ module Rails              return $1, limit: $2.to_i            when /decimal\{(\d+)[,.-](\d+)\}/              return :decimal, precision: $1.to_i, scale: $2.to_i -          when /(references|belongs_to)\{polymorphic\}/ -            return $1, polymorphic: true +          when /(references|belongs_to)\{(.+)\}/ +            type = $1 +            provided_options = $2.split(/[,.-]/) +            options = Hash[provided_options.map { |opt| [opt.to_sym, true] }] +            return type, options            else              return type, {}            end @@ -123,7 +126,11 @@ module Rails        end        def polymorphic? -        self.attr_options.has_key?(:polymorphic) +        self.attr_options[:polymorphic] +      end + +      def required? +        self.attr_options[:required]        end        def has_index? @@ -135,16 +142,33 @@ module Rails        end        def password_digest? -        name == 'password' && type == :digest  +        name == 'password' && type == :digest +      end + +      def token? +        type == :token        end        def inject_options -        "".tap { |s| @attr_options.each { |k,v| s << ", #{k}: #{v.inspect}" } } +        "".tap { |s| options_for_migration.each { |k,v| s << ", #{k}: #{v.inspect}" } }        end        def inject_index_options          has_uniq_index? ? ", unique: true" : ""        end + +      def options_for_migration +        @attr_options.dup.tap do |options| +          if required? +            options.delete(:required) +            options[:null] = false +          end + +          if reference? && !polymorphic? +            options[:foreign_key] = true +          end +        end +      end      end    end  end diff --git a/railties/lib/rails/generators/migration.rb b/railties/lib/rails/generators/migration.rb index cd388e590a..51e6d68bf0 100644 --- a/railties/lib/rails/generators/migration.rb +++ b/railties/lib/rails/generators/migration.rb @@ -3,8 +3,8 @@ require 'rails/generators/actions/create_migration'  module Rails    module Generators -    # Holds common methods for migrations. It assumes that migrations has the -    # [0-9]*_name format and can be used by another frameworks (like Sequel) +    # Holds common methods for migrations. It assumes that migrations have the +    # [0-9]*_name format and can be used by other frameworks (like Sequel)      # just by implementing the next migration version method.      module Migration        extend ActiveSupport::Concern diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index b7da44ca2d..36456e64f5 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -99,7 +99,7 @@ module Rails          end          def class_name -          (class_path + [file_name]).map!{ |m| m.camelize }.join('::') +          (class_path + [file_name]).map!(&:camelize).join('::')          end          def human_name @@ -145,7 +145,7 @@ module Rails            @route_url ||= class_path.collect {|dname| "/" + dname }.join + "/" + plural_file_name          end -        # Tries to retrieve the application name or simple return application. +        # Tries to retrieve the application name or simply return application.          def application_name            if defined?(Rails) && Rails.application              Rails.application.class.name.split('::').first.underscore @@ -156,7 +156,7 @@ module Rails          def assign_names!(name) #:nodoc:            @class_path = name.include?('/') ? name.split('/') : name.split('::') -          @class_path.map! { |m| m.underscore } +          @class_path.map!(&:underscore)            @file_name = @class_path.pop          end diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 188e62b6c8..977f5a1c03 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -38,7 +38,7 @@ module Rails      end      def readme -      copy_file "README.rdoc", "README.rdoc" +      copy_file "README.md", "README.md"      end      def gemfile @@ -88,9 +88,14 @@ module Rails      def config_when_updating        cookie_serializer_config_exist = File.exist?('config/initializers/cookies_serializer.rb') +      callback_terminator_config_exist = File.exist?('config/initializers/callback_terminator.rb')        config +      unless callback_terminator_config_exist +        remove_file 'config/initializers/callback_terminator.rb' +      end +        unless cookie_serializer_config_exist          gsub_file 'config/initializers/cookies_serializer.rb', /json/, 'marshal'        end @@ -120,6 +125,7 @@ module Rails      def test        empty_directory_with_keep_file 'test/fixtures' +      empty_directory_with_keep_file 'test/fixtures/files'        empty_directory_with_keep_file 'test/controllers'        empty_directory_with_keep_file 'test/mailers'        empty_directory_with_keep_file 'test/models' @@ -229,7 +235,7 @@ module Rails        end        def create_test_files -        build(:test) unless options[:skip_test_unit] +        build(:test) unless options[:skip_test]        end        def create_tmp_files @@ -259,6 +265,10 @@ module Rails        public_task :apply_rails_template, :run_bundle        public_task :generate_spring_binstubs +      def run_after_bundle_callbacks +        @after_bundle_callbacks.each(&:call) +      end +      protected        def self.banner @@ -334,7 +344,7 @@ module Rails      #      # This class should be called before the AppGenerator is required and started      # since it configures and mutates ARGV correctly. -    class ARGVScrubber # :nodoc +    class ARGVScrubber # :nodoc:        def initialize(argv = ARGV)          @argv = argv        end diff --git a/railties/lib/rails/generators/rails/app/templates/Gemfile b/railties/lib/rails/generators/rails/app/templates/Gemfile index 5bdbd58097..143673f711 100644 --- a/railties/lib/rails/generators/rails/app/templates/Gemfile +++ b/railties/lib/rails/generators/rails/app/templates/Gemfile @@ -1,6 +1,5 @@  source 'https://rubygems.org' -<% max_width = gemfile_entries.map { |g| g.name.length }.max -%>  <% gemfile_entries.each do |gem| -%>  <% if gem.comment -%> @@ -8,7 +7,7 @@ source 'https://rubygems.org'  <% end -%>  <%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<%= %(, '#{gem.version}') if gem.version -%>  <% if gem.options.any? -%> -,<%= gem.padding(max_width) %><%= gem.options.map { |k,v| +, <%= gem.options.map { |k,v|    "#{k}: #{v.inspect}" }.join(', ') %>  <% end -%>  <% end -%> @@ -22,16 +21,29 @@ source 'https://rubygems.org'  # Use Capistrano for deployment  # gem 'capistrano-rails', group: :development -<% unless defined?(JRUBY_VERSION) -%> -# To use a debugger -  <%- if RUBY_VERSION < '2.0.0' -%> -# gem 'debugger', group: [:development, :test] +group :development, :test do +<% if RUBY_ENGINE == 'ruby' -%> +  # Call 'byebug' anywhere in the code to stop execution and get a debugger console +  gem 'byebug' + +  # Access an IRB console on exception pages or by using <%%= console %> in views +  <%- if options.dev? || options.edge? -%> +  gem 'web-console', github: "rails/web-console"    <%- else -%> -# gem 'byebug', group: [:development, :test] +  gem 'web-console', '~> 2.0'    <%- end -%> +<%- if spring_install? %> +  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring +  gem 'spring' +<% end -%> + +  # Adds `Method#source` and `Method#comment` to get the source code of a +  # method from the console +  gem 'method_source'  <% end -%> +end -<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince/) -%> +<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>  # Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]  <% end -%> diff --git a/railties/lib/rails/generators/rails/app/templates/README.rdoc b/railties/lib/rails/generators/rails/app/templates/README.md index dd4e97e22e..55e144da18 100644 --- a/railties/lib/rails/generators/rails/app/templates/README.rdoc +++ b/railties/lib/rails/generators/rails/app/templates/README.md @@ -1,4 +1,4 @@ -== README +## README  This README would normally document whatever steps are necessary to get the  application up and running. @@ -22,7 +22,3 @@ Things you may want to cover:  * Deployment instructions  * ... - - -Please feel free to use a different markup language if you do not plan to run -<tt>rake doc:app</tt>. diff --git a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt index 07ea09cdbd..c1a77944e8 100644 --- a/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt +++ b/railties/lib/rails/generators/rails/app/templates/app/assets/javascripts/application.js.tt @@ -2,7 +2,7 @@  // listed below.  //  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.  //  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the  // compiled file. 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 a443db3401..0cdd2788d0 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 @@ -3,12 +3,11 @@   * listed below.   *   * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.   *   * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any styles - * defined in the other CSS/SCSS files in this directory. It is generally better to create a new - * file per style scope. + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. It is generally better to create a new file per style scope.   *   *= require_tree .   *= require_self diff --git a/railties/lib/rails/generators/rails/app/templates/bin/rails b/railties/lib/rails/generators/rails/app/templates/bin/rails index 6a128b95e5..80ec8080ab 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/rails +++ b/railties/lib/rails/generators/rails/app/templates/bin/rails @@ -1,3 +1,3 @@ -APP_PATH = File.expand_path('../../config/application',  __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__)  require_relative '../config/boot'  require 'rails/commands' diff --git a/railties/lib/rails/generators/rails/app/templates/bin/setup b/railties/lib/rails/generators/rails/app/templates/bin/setup index 0e22b3fa5c..eee810be30 100644 --- a/railties/lib/rails/generators/rails/app/templates/bin/setup +++ b/railties/lib/rails/generators/rails/app/templates/bin/setup @@ -1,28 +1,30 @@  require 'pathname' +require 'fileutils' +include FileUtils  # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../',  __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) -Dir.chdir APP_ROOT do +chdir APP_ROOT do    # This script is a starting point to setup your application. -  # Add necessary setup steps to this file: +  # Add necessary setup steps to this file. -  puts "== Installing dependencies ==" -  system "gem install bundler --conservative" -  system "bundle check || bundle install" +  puts '== Installing dependencies ==' +  system 'gem install bundler --conservative' +  system('bundle check') or system('bundle install')    # puts "\n== Copying sample files ==" -  # unless File.exist?("config/database.yml") -  #   system "cp config/database.yml.sample config/database.yml" +  # unless File.exist?('config/database.yml') +  #   cp 'config/database.yml.sample', 'config/database.yml'    # end    puts "\n== Preparing database ==" -  system "bin/rake db:setup" +  system 'ruby bin/rake db:setup'    puts "\n== Removing old logs and tempfiles ==" -  system "rm -f log/*" -  system "rm -rf tmp/cache" +  rm_f Dir.glob('log/*') +  rm_rf 'tmp/cache'    puts "\n== Restarting application server ==" -  system "touch tmp/restart.txt" +  touch 'tmp/restart.txt'  end diff --git a/railties/lib/rails/generators/rails/app/templates/config.ru b/railties/lib/rails/generators/rails/app/templates/config.ru index 5bc2a619e8..bd83b25412 100644 --- a/railties/lib/rails/generators/rails/app/templates/config.ru +++ b/railties/lib/rails/generators/rails/app/templates/config.ru @@ -1,4 +1,4 @@  # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment',  __FILE__) +require ::File.expand_path('../config/environment', __FILE__)  run Rails.application 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 16fe50bab8..a2661bfb51 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -3,14 +3,16 @@ require File.expand_path('../boot', __FILE__)  <% if include_all_railties? -%>  require 'rails/all'  <% else -%> +require "rails"  # Pick the frameworks you want:  require "active_model/railtie" +require "active_job/railtie"  <%= comment_if :skip_active_record %>require "active_record/railtie"  require "action_controller/railtie" -require "action_mailer/railtie" -<%= comment_if :skip_action_view %>require "action_view/railtie" +<%= comment_if :skip_action_mailer %>require "action_mailer/railtie" +require "action_view/railtie"  <%= comment_if :skip_sprockets %>require "sprockets/railtie" -<%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" +<%= comment_if :skip_test %>require "rails/test_unit/railtie"  <% end -%>  # Require the gems listed in Gemfile, including any gems diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb index 5e5f0c1fac..6b750f00b1 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile.  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml index 4b2e6646c7..596c916573 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/databases/mysql.yml @@ -1,6 +1,6 @@  # MySQL.  Versions 5.0+ are recommended.  # -# Install the MYSQL driver +# Install the MySQL driver  #   gem install mysql2  #  # Ensure the MySQL gem is defined in your Gemfile diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt index bbb409616d..ecb5d4170f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.tt @@ -12,9 +12,11 @@ Rails.application.configure do    # Show full error reports and disable caching.    config.consider_all_requests_local       = true    config.action_controller.perform_caching = false +  <%- unless options.skip_action_mailer? -%>    # Don't care if the mailer can't send.    config.action_mailer.raise_delivery_errors = false +  <%- end -%>    # Print deprecation notices to the Rails logger.    config.active_support.deprecation = :log @@ -30,7 +32,8 @@ Rails.application.configure do    # number of complex assets.    config.assets.debug = true -  # Generate digests for assets URLs. +  # Asset digests allow you to set far-future HTTP expiration dates on all assets, +  # yet still be able to expire them through the digest params.    config.assets.digest = true    # Adds additional error checking when serving assets at runtime. diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt index a2aa7c09db..75666d20c5 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/production.rb.tt @@ -14,13 +14,9 @@ Rails.application.configure do    config.consider_all_requests_local       = false    config.action_controller.perform_caching = true -  # Enable Rack::Cache to put a simple HTTP cache in front of your application -  # Add `rack-cache` to your Gemfile before enabling this. -  # For large-scale production use, consider using a caching reverse proxy like NGINX, varnish or squid. -  # config.action_dispatch.rack_cache = true - -  # Disable Rails's static asset server (Apache or NGINX will already do this). -  config.serve_static_assets = false +  # Disable serving static files from the `/public` folder by default since +  # Apache or NGINX already handles this. +  config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?    <%- unless options.skip_sprockets? -%>    # Compress JavaScripts and CSS. @@ -30,21 +26,26 @@ Rails.application.configure do    # Do not fallback to assets pipeline if a precompiled asset is missed.    config.assets.compile = false -  # Generate digests for assets URLs. +  # Asset digests allow you to set far-future HTTP expiration dates on all assets, +  # yet still be able to expire them through the digest params.    config.assets.digest = true -  # `config.assets.precompile` has moved to config/initializers/assets.rb +  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb    <%- end -%> +  # Enable serving of images, stylesheets, and JavaScripts from an asset server. +  # config.action_controller.asset_host = 'http://assets.example.com' +    # Specifies the header that your server uses for sending files. -  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache +  # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache    # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX    # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.    # config.force_ssl = true -  # Set to :debug to see everything in the log. -  config.log_level = :info +  # Use the lowest log level to ensure availability of diagnostic information +  # when problems arise. +  config.log_level = :debug    # Prepend all log lines with the following tags.    # config.log_tags = [ :subdomain, :uuid ] @@ -55,12 +56,15 @@ Rails.application.configure do    # Use a different cache store in production.    # config.cache_store = :mem_cache_store -  # Enable serving of images, stylesheets, and JavaScripts from an asset server. -  # config.action_controller.asset_host = "http://assets.example.com" +  # Use a real queuing backend for Active Job (and separate queues per environment) +  # config.active_job.queue_adapter     = :resque +  # config.active_job.queue_name_prefix = "<%= app_name %>_#{Rails.env}" +  <%- unless options.skip_action_mailer? -%>    # Ignore bad email addresses and do not raise email delivery errors.    # Set this to true and configure the email server for immediate delivery to raise delivery errors.    # config.action_mailer.raise_delivery_errors = false +  <%- end -%>    # Enable locale fallbacks for I18n (makes lookups for any locale fall back to    # the I18n.default_locale when a translation cannot be found). @@ -69,9 +73,6 @@ Rails.application.configure do    # Send deprecation notices to registered listeners.    config.active_support.deprecation = :notify -  # Disable automatic flushing of the log to improve performance. -  # config.autoflush_log = false -    # Use default logging formatter so that PID and timestamp are not suppressed.    config.log_formatter = ::Logger::Formatter.new    <%- unless options.skip_active_record? -%> diff --git a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt index 053f5b66d7..0306deb18c 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/environments/test.rb.tt @@ -12,8 +12,8 @@ Rails.application.configure do    # preloads Rails for running tests, you may have to set it to true.    config.eager_load = false -  # Configure static asset server for tests with Cache-Control for performance. -  config.serve_static_assets  = true +  # Configure static file server for tests with Cache-Control for performance. +  config.serve_static_files   = true    config.static_cache_control = 'public, max-age=3600'    # Show full error reports and disable caching. @@ -25,11 +25,16 @@ Rails.application.configure do    # Disable request forgery protection in test environment.    config.action_controller.allow_forgery_protection = false +  <%- unless options.skip_action_mailer? -%>    # Tell Action Mailer not to deliver emails to the real world.    # The :test delivery method accumulates sent emails in the    # ActionMailer::Base.deliveries array.    config.action_mailer.delivery_method = :test +  <%- end -%> + +  # Randomize the order test cases are executed. +  config.active_support.test_order = :random    # Print deprecation notices to the stderr.    config.active_support.deprecation = :stderr diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000000..ea930f54da --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/application_controller_renderer.rb @@ -0,0 +1,6 @@ +## Change renderer defaults here. +# +# ApplicationController.renderer.defaults.merge!( +#   http_host: 'example.org', +#   https: false +# ) diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt index d2f4ec33a6..01ef3e6630 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.tt @@ -3,6 +3,9 @@  # Version of your assets, change this if you want to expire all your assets.  Rails.application.config.assets.version = '1.0' +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path +  # Precompile additional assets.  # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.  # Rails.application.config.assets.precompile += %w( search.js ) diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb b/railties/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb new file mode 100644 index 0000000000..e63022da91 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/callback_terminator.rb @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Do not halt callback chains when a callback returns false. +Rails.application.config.active_support.halt_callback_chains_on_return_false = false diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt index f2110c2c70..94f612c3dd 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt @@ -11,6 +11,6 @@ end  # To enable root element in JSON for ActiveRecord objects.  # ActiveSupport.on_load(:active_record) do -#  self.include_root_in_json = true +#   self.include_root_in_json = true  # end  <%- end -%> diff --git a/railties/lib/rails/generators/rails/app/templates/gitignore b/railties/lib/rails/generators/rails/app/templates/gitignore index 8775e5e235..7c6f2098b8 100644 --- a/railties/lib/rails/generators/rails/app/templates/gitignore +++ b/railties/lib/rails/generators/rails/app/templates/gitignore @@ -14,5 +14,6 @@  <% end -%>  # Ignore all logfiles and tempfiles. -/log/*.log +/log/* +!/log/.keep  /tmp diff --git a/railties/lib/rails/generators/rails/controller/USAGE b/railties/lib/rails/generators/rails/controller/USAGE index de33900e0a..64239ad599 100644 --- a/railties/lib/rails/generators/rails/controller/USAGE +++ b/railties/lib/rails/generators/rails/controller/USAGE @@ -16,4 +16,3 @@ Example:          Test:       test/controllers/credit_cards_controller_test.rb          Views:      app/views/credit_cards/debit.html.erb [...]          Helper:     app/helpers/credit_cards_helper.rb -        Test:       test/helpers/credit_cards_helper_test.rb diff --git a/railties/lib/rails/generators/rails/controller/controller_generator.rb b/railties/lib/rails/generators/rails/controller/controller_generator.rb index 7588a558e7..df615c88b5 100644 --- a/railties/lib/rails/generators/rails/controller/controller_generator.rb +++ b/railties/lib/rails/generators/rails/controller/controller_generator.rb @@ -2,6 +2,8 @@ module Rails    module Generators      class ControllerGenerator < NamedBase # :nodoc:        argument :actions, type: :array, default: [], banner: "action action" +      class_option :skip_routes, type: :boolean, desc: "Don't add routes to config/routes.rb." +        check_class_collision suffix: "Controller"        def create_controller_files @@ -9,8 +11,10 @@ module Rails        end        def add_routes -        actions.reverse.each do |action| -          route generate_routing_code(action) +        unless options[:skip_routes] +          actions.reverse_each do |action| +            route generate_routing_code(action) +          end          end        end diff --git a/railties/lib/rails/generators/rails/helper/USAGE b/railties/lib/rails/generators/rails/helper/USAGE index 30e323a858..8855ef3b01 100644 --- a/railties/lib/rails/generators/rails/helper/USAGE +++ b/railties/lib/rails/generators/rails/helper/USAGE @@ -5,13 +5,9 @@ Description:      To create a helper within a module, specify the helper name as a      path like 'parent_module/helper_name'. -    This generates a helper class in app/helpers and invokes the configured -    test framework. -  Example:      `rails generate helper CreditCard`      Credit card helper.          Helper:     app/helpers/credit_card_helper.rb -        Test:       test/helpers/credit_card_helper_test.rb diff --git a/railties/lib/rails/generators/rails/migration/migration_generator.rb b/railties/lib/rails/generators/rails/migration/migration_generator.rb index 965c42db36..fca2a8fef4 100644 --- a/railties/lib/rails/generators/rails/migration/migration_generator.rb +++ b/railties/lib/rails/generators/rails/migration/migration_generator.rb @@ -2,7 +2,7 @@ module Rails    module Generators      class MigrationGenerator < NamedBase # :nodoc:        argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]" -      hook_for :orm, required: true +      hook_for :orm, required: true, desc: "ORM to be invoked"      end    end  end diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE index 833b7beb7f..11daa5c3cb 100644 --- a/railties/lib/rails/generators/rails/model/USAGE +++ b/railties/lib/rails/generators/rails/model/USAGE @@ -6,6 +6,11 @@ Description:      model's attributes. Timestamps are added by default, so you don't have to      specify them by hand as 'created_at:datetime updated_at:datetime'. +    As a special case, specifying 'password:digest' will generate a +    password_digest field of string type, and configure your generated model and +    tests for use with ActiveModel has_secure_password (assuming the default ORM +    and test framework are being used). +      You don't have to think up every attribute up front, but it helps to      sketch out a few so you can start working with the model immediately. @@ -17,7 +22,7 @@ Description:      If you pass a namespaced model name (e.g. admin/account or Admin::Account)      then the generator will create a module with a table_name_prefix method -    to prefix the model's table name with the module name (e.g. admin_account) +    to prefix the model's table name with the module name (e.g. admin_accounts)  Available field types: @@ -27,7 +32,8 @@ Available field types:          `rails generate model post title:string body:text`      will generate a title column with a varchar type and a body column with a text -    type. You can use the following types: +    type. If no type is specified the string type will be used by default. +    You can use the following types:          integer          primary_key @@ -40,7 +46,6 @@ Available field types:          date          time          datetime -        timestamp      You can also consider `references` as a kind of type. For instance, if you run: @@ -73,6 +78,15 @@ Available field types:          `rails generate model user username:string{30}:uniq`          `rails generate model product supplier:references{polymorphic}:index` +    If you require a `password_digest` string column for use with +    has_secure_password, you can specify `password:digest`: + +        `rails generate model user password:digest` + +    If you require a `token` string column for use with +    has_secure_token, you can specify `auth_token:token`: + +        `rails generate model user auth_token:token`  Examples:      `rails generate model account` diff --git a/railties/lib/rails/generators/rails/model/model_generator.rb b/railties/lib/rails/generators/rails/model/model_generator.rb index 87bab129bb..ec78fd855d 100644 --- a/railties/lib/rails/generators/rails/model/model_generator.rb +++ b/railties/lib/rails/generators/rails/model/model_generator.rb @@ -6,7 +6,7 @@ module Rails        include Rails::Generators::ModelHelpers        argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]" -      hook_for :orm, required: true +      hook_for :orm, required: true, desc: "ORM to be invoked"      end    end  end diff --git a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb index 584f776c01..68c3829515 100644 --- a/railties/lib/rails/generators/rails/plugin/plugin_generator.rb +++ b/railties/lib/rails/generators/rails/plugin/plugin_generator.rb @@ -18,14 +18,14 @@ module Rails      def app        if mountable?          directory 'app' -        empty_directory_with_keep_file "app/assets/images/#{name}" +        empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"        elsif full?          empty_directory_with_keep_file 'app/models'          empty_directory_with_keep_file 'app/controllers'          empty_directory_with_keep_file 'app/views'          empty_directory_with_keep_file 'app/helpers'          empty_directory_with_keep_file 'app/mailers' -        empty_directory_with_keep_file "app/assets/images/#{name}" +        empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"        end      end @@ -50,10 +50,10 @@ module Rails      end      def lib -      template "lib/%name%.rb" -      template "lib/tasks/%name%_tasks.rake" -      template "lib/%name%/version.rb" -      template "lib/%name%/engine.rb" if engine? +      template "lib/%namespaced_name%.rb" +      template "lib/tasks/%namespaced_name%_tasks.rake" +      template "lib/%namespaced_name%/version.rb" +      template "lib/%namespaced_name%/engine.rb" if engine?      end      def config @@ -62,7 +62,7 @@ module Rails      def test        template "test/test_helper.rb" -      template "test/%name%_test.rb" +      template "test/%namespaced_name%_test.rb"        append_file "Rakefile", <<-EOF  #{rakefile_test_tasks} @@ -74,7 +74,8 @@ task default: :test      end      PASSTHROUGH_OPTIONS = [ -      :skip_active_record, :skip_javascript, :database, :javascript, :quiet, :pretend, :force, :skip +      :skip_active_record, :skip_action_mailer, :skip_javascript, :database, +      :javascript, :quiet, :pretend, :force, :skip      ]      def generate_test_dummy(force = false) @@ -116,9 +117,9 @@ task default: :test      def stylesheets        if mountable?          copy_file "rails/stylesheets.css", -                  "app/assets/stylesheets/#{name}/application.css" +                  "app/assets/stylesheets/#{namespaced_name}/application.css"        elsif full? -        empty_directory_with_keep_file "app/assets/stylesheets/#{name}" +        empty_directory_with_keep_file "app/assets/stylesheets/#{namespaced_name}"        end      end @@ -127,9 +128,9 @@ task default: :test        if mountable?          template "rails/javascripts.js", -                 "app/assets/javascripts/#{name}/application.js" +                 "app/assets/javascripts/#{namespaced_name}/application.js"        elsif full? -        empty_directory_with_keep_file "app/assets/javascripts/#{name}" +        empty_directory_with_keep_file "app/assets/javascripts/#{namespaced_name}"        end      end @@ -225,7 +226,7 @@ task default: :test        end        def create_test_files -        build(:test) unless options[:skip_test_unit] +        build(:test) unless options[:skip_test]        end        def create_test_dummy_files @@ -255,6 +256,14 @@ task default: :test          end        end +      def underscored_name +        @underscored_name ||= original_name.underscore +      end + +      def namespaced_name +        @namespaced_name ||= name.gsub('-', '/') +      end +      protected        def app_templates_dir @@ -293,7 +302,7 @@ task default: :test        end        def with_dummy_app? -        options[:skip_test_unit].blank? || options[:dummy_path] != 'test/dummy' +        options[:skip_test].blank? || options[:dummy_path] != 'test/dummy'        end        def self.banner @@ -304,6 +313,27 @@ task default: :test          @original_name ||= File.basename(destination_root)        end +      def modules +        @modules ||= namespaced_name.camelize.split("::") +      end + +      def wrap_in_modules(unwrapped_code) +        unwrapped_code = "#{unwrapped_code}".strip.gsub(/\W$\n/, '') +        modules.reverse.inject(unwrapped_code) do |content, mod| +          str = "module #{mod}\n" +          str += content.lines.map { |line| "  #{line}" }.join +          str += content.present? ? "\nend" : "end" +        end +      end + +      def camelized_modules +        @camelized_modules ||= namespaced_name.camelize +      end + +      def humanized +        @humanized ||= original_name.underscore.humanize +      end +        def camelized          @camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize        end @@ -327,8 +357,10 @@ task default: :test        end        def valid_const? -        if original_name =~ /[^0-9a-zA-Z_]+/ -          raise Error, "Invalid plugin name #{original_name}. Please give a name which use only alphabetic or numeric or \"_\" characters." +        if original_name =~ /-\d/ +          raise Error, "Invalid plugin name #{original_name}. Please give a name which does not contain a namespace starting with numeric characters." +        elsif original_name =~ /[^\w-]+/ +          raise Error, "Invalid plugin name #{original_name}. Please give a name which uses only alphabetic, numeric, \"_\" or \"-\" characters."          elsif camelized =~ /^\d/            raise Error, "Invalid plugin name #{original_name}. Please give a name which does not start with numbers."          elsif RESERVED_NAMES.include?(name) diff --git a/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec b/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec index 919c349470..f8ece4fe73 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec +++ b/railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec @@ -1,21 +1,21 @@  $:.push File.expand_path("../lib", __FILE__)  # Maintain your gem's version: -require "<%= name %>/version" +require "<%= namespaced_name %>/version"  # Describe your gem and declare its dependencies:  Gem::Specification.new do |s|    s.name        = "<%= name %>" -  s.version     = <%= camelized %>::VERSION +  s.version     = <%= camelized_modules %>::VERSION    s.authors     = ["<%= author %>"]    s.email       = ["<%= email %>"]    s.homepage    = "TODO" -  s.summary     = "TODO: Summary of <%= camelized %>." -  s.description = "TODO: Description of <%= camelized %>." +  s.summary     = "TODO: Summary of <%= camelized_modules %>." +  s.description = "TODO: Description of <%= camelized_modules %>."    s.license     = "MIT"    s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"] -<% unless options.skip_test_unit? -%> +<% unless options.skip_test? -%>    s.test_files = Dir["test/**/*"]  <% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/Gemfile b/railties/lib/rails/generators/rails/plugin/templates/Gemfile index 796587f316..f325455bac 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/Gemfile +++ b/railties/lib/rails/generators/rails/plugin/templates/Gemfile @@ -31,17 +31,17 @@ end  <% end -%>  <%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<%= %(, '#{gem.version}') if gem.version -%>  <% if gem.options.any? -%> -,<%= gem.padding(max_width) %><%= gem.options.map { |k,v| +, <%= gem.options.map { |k,v|    "#{k}: #{v.inspect}" }.join(', ') %>  <% end -%>  <% end -%>  <% end -%> -<% unless defined?(JRUBY_VERSION) -%> +<% if RUBY_ENGINE == 'ruby' -%>  # To use a debugger -  <%- if RUBY_VERSION < '2.0.0' -%> -# gem 'debugger', group: [:development, :test] -  <%- else -%>  # gem 'byebug', group: [:development, :test] -  <%- end -%> +<% end -%> + +<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%> +gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]  <% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/README.rdoc b/railties/lib/rails/generators/rails/plugin/templates/README.rdoc index 301d647731..25983ca5da 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/README.rdoc +++ b/railties/lib/rails/generators/rails/plugin/templates/README.rdoc @@ -1,3 +1,3 @@ -= <%= camelized %> += <%= camelized_modules %>  This project rocks and uses MIT-LICENSE.
\ No newline at end of file diff --git a/railties/lib/rails/generators/rails/plugin/templates/Rakefile b/railties/lib/rails/generators/rails/plugin/templates/Rakefile index c338a0bdb1..bda55bae29 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/Rakefile +++ b/railties/lib/rails/generators/rails/plugin/templates/Rakefile @@ -8,7 +8,7 @@ require 'rdoc/task'  RDoc::Task.new(:rdoc) do |rdoc|    rdoc.rdoc_dir = 'rdoc' -  rdoc.title    = '<%= camelized %>' +  rdoc.title    = '<%= camelized_modules %>'    rdoc.options << '--line-numbers'    rdoc.rdoc_files.include('README.rdoc')    rdoc.rdoc_files.include('lib/**/*.rb') diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt index 448ad7f989..7157e48c42 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%name%/application_controller.rb.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/app/controllers/%namespaced_name%/application_controller.rb.tt @@ -1,4 +1,5 @@ -module <%= camelized %> +<%= wrap_in_modules <<-rb.strip_heredoc    class ApplicationController < ActionController::Base    end -end +rb +%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt deleted file mode 100644 index 40ae9f52c2..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%name%/application_helper.rb.tt +++ /dev/null @@ -1,4 +0,0 @@ -module <%= camelized %> -  module ApplicationHelper -  end -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt new file mode 100644 index 0000000000..25d692732d --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/app/helpers/%namespaced_name%/application_helper.rb.tt @@ -0,0 +1,5 @@ +<%= wrap_in_modules <<-rb.strip_heredoc +  module ApplicationHelper +  end +rb +%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt deleted file mode 100644 index 1d380420b4..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%name%/application.html.erb.tt +++ /dev/null @@ -1,14 +0,0 @@ -<!DOCTYPE html> -<html> -<head> -  <title><%= camelized %></title> -  <%%= stylesheet_link_tag    "<%= name %>/application", media: "all" %> -  <%%= javascript_include_tag "<%= name %>/application" %> -  <%%= csrf_meta_tags %> -</head> -<body> - -<%%= yield %> - -</body> -</html> diff --git a/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt b/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt new file mode 100644 index 0000000000..6bc480161d --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html> +<head> +  <title><%= humanized %></title> +  <%%= stylesheet_link_tag    "<%= namespaced_name %>/application", media: "all" %> +  <%%= javascript_include_tag "<%= namespaced_name %>/application" %> +  <%%= csrf_meta_tags %> +</head> +<body> + +<%%= yield %> + +</body> +</html> diff --git a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt index c3314d7e68..3edaac35c9 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt +++ b/railties/lib/rails/generators/rails/plugin/templates/bin/rails.tt @@ -1,7 +1,7 @@  # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.  ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/<%= name -%>/engine', __FILE__) +ENGINE_PATH = File.expand_path('../../lib/<%= namespaced_name -%>/engine', __FILE__)  # Set up gems listed in the Gemfile.  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) diff --git a/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb index 8e158d5831..154452bfe5 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/config/routes.rb @@ -1,5 +1,5 @@  <% if mountable? -%> -<%= camelized %>::Engine.routes.draw do +<%= camelized_modules %>::Engine.routes.draw do  <% else -%>  Rails.application.routes.draw do  <% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/gitignore b/railties/lib/rails/generators/rails/plugin/templates/gitignore index 086d87818a..d524fcbc4e 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/gitignore +++ b/railties/lib/rails/generators/rails/plugin/templates/gitignore @@ -1,10 +1,10 @@  .bundle/  log/*.log  pkg/ -<% unless options[:skip_test_unit] && options[:dummy_path] == 'test/dummy' -%> +<% unless options[:skip_test] && options[:dummy_path] == 'test/dummy' -%>  <%= dummy_path %>/db/*.sqlite3  <%= dummy_path %>/db/*.sqlite3-journal  <%= dummy_path %>/log/*.log  <%= dummy_path %>/tmp/  <%= dummy_path %>/.sass-cache -<% end -%>
\ No newline at end of file +<% end -%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%.rb deleted file mode 100644 index 40c074cced..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%.rb +++ /dev/null @@ -1,6 +0,0 @@ -<% if engine? -%> -require "<%= name %>/engine" - -<% end -%> -module <%= camelized %> -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb deleted file mode 100644 index 967668fe66..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/engine.rb +++ /dev/null @@ -1,7 +0,0 @@ -module <%= camelized %> -  class Engine < ::Rails::Engine -<% if mountable? -%> -    isolate_namespace <%= camelized %> -<% end -%> -  end -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb deleted file mode 100644 index ef07ef2e19..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/%name%/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module <%= camelized %> -  VERSION = "0.0.1" -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb new file mode 100644 index 0000000000..40b1c4cee7 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%.rb @@ -0,0 +1,5 @@ +<% if engine? -%> +require "<%= namespaced_name %>/engine" + +<% end -%> +<%= wrap_in_modules "# Your code goes here..." %> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb new file mode 100644 index 0000000000..17afd52177 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/engine.rb @@ -0,0 +1,6 @@ +<%= wrap_in_modules <<-rb.strip_heredoc +  class Engine < ::Rails::Engine +  #{mountable? ? '  isolate_namespace ' + camelized_modules : ' '} +  end +rb +%> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb new file mode 100644 index 0000000000..d257295988 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/%namespaced_name%/version.rb @@ -0,0 +1 @@ +<%= wrap_in_modules 'VERSION = "0.0.1"' %> diff --git a/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%name%_tasks.rake b/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake index 7121f5ae23..88a2c4120f 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%name%_tasks.rake +++ b/railties/lib/rails/generators/rails/plugin/templates/lib/tasks/%namespaced_name%_tasks.rake @@ -1,4 +1,4 @@  # desc "Explaining what the task does" -# task :<%= name %> do +# task :<%= underscored_name %> do  #   # Task goes here  # end diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb index 5508829f6b..b1038c839e 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/application.rb @@ -6,13 +6,13 @@ require 'rails/all'  # Pick the frameworks you want:  <%= comment_if :skip_active_record %>require "active_record/railtie"  require "action_controller/railtie" -require "action_mailer/railtie" -<%= comment_if :skip_action_view %>require "action_view/railtie" +<%= comment_if :skip_action_mailer %>require "action_mailer/railtie" +require "action_view/railtie"  <%= comment_if :skip_sprockets %>require "sprockets/railtie" -<%= comment_if :skip_test_unit %>require "rails/test_unit/railtie" +<%= comment_if :skip_test %>require "rails/test_unit/railtie"  <% end -%>  Bundler.require(*Rails.groups) -require "<%= name %>" +require "<%= namespaced_name %>"  <%= application_definition %> diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js index 5bc2e1c8b5..c28e5badc6 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/javascripts.js @@ -2,7 +2,7 @@  // listed below.  //  // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.  //  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the  // compiled file. diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb b/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb index 730ee31c3d..673de44108 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/routes.rb @@ -1,4 +1,4 @@  Rails.application.routes.draw do -  mount <%= camelized %>::Engine => "/<%= name %>" +  mount <%= camelized_modules %>::Engine => "/<%= name %>"  end diff --git a/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css b/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css index a443db3401..0cdd2788d0 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css +++ b/railties/lib/rails/generators/rails/plugin/templates/rails/stylesheets.css @@ -3,12 +3,11 @@   * listed below.   *   * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.   *   * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any styles - * defined in the other CSS/SCSS files in this directory. It is generally better to create a new - * file per style scope. + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. It is generally better to create a new file per style scope.   *   *= require_tree .   *= require_self diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb b/railties/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb deleted file mode 100644 index 0a8bbd4aaf..0000000000 --- a/railties/lib/rails/generators/rails/plugin/templates/test/%name%_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class <%= camelized %>Test < ActiveSupport::TestCase -  test "truth" do -    assert_kind_of Module, <%= camelized %> -  end -end diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb b/railties/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb new file mode 100644 index 0000000000..1ee05d7871 --- /dev/null +++ b/railties/lib/rails/generators/rails/plugin/templates/test/%namespaced_name%_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class <%= camelized_modules %>::Test < ActiveSupport::TestCase +  test "truth" do +    assert_kind_of Module, <%= camelized_modules %> +  end +end diff --git a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb index 1e26a313cd..0852ffce9a 100644 --- a/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb +++ b/railties/lib/rails/generators/rails/plugin/templates/test/test_helper.rb @@ -1,15 +1,25 @@  # Configure Rails Environment  ENV["RAILS_ENV"] = "test" -require File.expand_path("../dummy/config/environment.rb",  __FILE__) +require File.expand_path("../../<%= options[:dummy_path] -%>/config/environment.rb",  __FILE__) +<% unless options[:skip_active_record] -%> +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../<%= options[:dummy_path] -%>/db/migrate", __FILE__)] +<% if options[:mountable] -%> +ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__) +<% end -%> +<% end -%>  require "rails/test_help" -Rails.backtrace_cleaner.remove_silencers! +# Filter out Minitest backtrace while allowing backtrace from other libraries +# to be shown. +Minitest.backtrace_filter = Minitest::BacktraceFilter.new  # Load support files  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }  # Load fixtures from the engine -if ActiveSupport::TestCase.method_defined?(:fixture_path=) +if ActiveSupport::TestCase.respond_to?(:fixture_path=)    ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__) +  ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "files" +  ActiveSupport::TestCase.fixtures :all  end diff --git a/railties/lib/rails/generators/rails/scaffold/USAGE b/railties/lib/rails/generators/rails/scaffold/USAGE index 4a3eb2c7c7..1b2a944103 100644 --- a/railties/lib/rails/generators/rails/scaffold/USAGE +++ b/railties/lib/rails/generators/rails/scaffold/USAGE @@ -9,11 +9,16 @@ Description:      Attributes are field arguments specifying the model's attributes. You can      optionally pass the type and an index to each field. For instance: -    "title body:text tracking_id:integer:uniq" will generate a title field of +    'title body:text tracking_id:integer:uniq' will generate a title field of      string type, a body with text type and a tracking_id as an integer with an      unique index. "index" could also be given instead of "uniq" if one desires      a non unique index. +    As a special case, specifying 'password:digest' will generate a +    password_digest field of string type, and configure your generated model, +    controller, views, and test suite for use with ActiveModel +    has_secure_password (assuming they are using Rails defaults). +      Timestamps are added by default, so you don't have to specify them by hand      as 'created_at:datetime updated_at:datetime'. @@ -33,3 +38,4 @@ Examples:      `rails generate scaffold post`      `rails generate scaffold post title body:text published:boolean`      `rails generate scaffold purchase amount:decimal tracking_id:integer:uniq` +    `rails generate scaffold user email:uniq password:digest` diff --git a/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css b/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css index 1ae7000299..69af1e8307 100644 --- a/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css +++ b/railties/lib/rails/generators/rails/scaffold/templates/scaffold.css @@ -4,6 +4,7 @@ body, p, ol, ul, td {    font-family: verdana, arial, helvetica, sans-serif;    font-size:   13px;    line-height: 18px; +  margin: 33px;  }  pre { @@ -16,6 +17,16 @@ a { color: #000; }  a:visited { color: #666; }  a:hover { color: #fff; background-color:#000; } +th { +  padding-bottom: 5px; +} + +td { +  padding-bottom: 7px; +  padding-left: 5px; +  padding-right: 5px; +} +  div.field, div.actions {    margin-bottom: 10px;  } diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb index 6bf0a33a5f..c01b82884d 100644 --- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb +++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb @@ -7,6 +7,7 @@ module Rails        check_class_collision suffix: "Controller" +      class_option :helper, type: :boolean        class_option :orm, banner: "NAME", type: :string, required: true,                           desc: "ORM to generate the controller for" diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 4669935156..9c2037783e 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -8,7 +8,7 @@ module Rails      module ResourceHelpers # :nodoc:        def self.included(base) #:nodoc: -        base.send :include, Rails::Generators::ModelHelpers +        base.include(Rails::Generators::ModelHelpers)          base.class_option :model_name, type: :string, desc: "ModelName to be used"        end @@ -39,7 +39,7 @@ module Rails          def assign_controller_names!(name)            @controller_name = name            @controller_class_path = name.include?('/') ? name.split('/') : name.split('::') -          @controller_class_path.map! { |m| m.underscore } +          @controller_class_path.map!(&:underscore)            @controller_file_name = @controller_class_path.pop          end @@ -48,7 +48,7 @@ module Rails          end          def controller_class_name -          (controller_class_path + [controller_file_name]).map!{ |m| m.camelize }.join('::') +          (controller_class_path + [controller_file_name]).map!(&:camelize).join('::')          end          def controller_i18n_scope diff --git a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb index 0db76f9eaf..bde4e88915 100644 --- a/railties/lib/rails/generators/test_unit/helper/helper_generator.rb +++ b/railties/lib/rails/generators/test_unit/helper/helper_generator.rb @@ -3,11 +3,7 @@ require 'rails/generators/test_unit'  module TestUnit # :nodoc:    module Generators # :nodoc:      class HelperGenerator < Base # :nodoc: -      check_class_collision suffix: "HelperTest" - -      def create_helper_files -        template 'helper_test.rb', File.join('test/helpers', class_path, "#{file_name}_helper_test.rb") -      end +      # Rails does not generate anything here.      end    end  end diff --git a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb b/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb deleted file mode 100644 index 7d37bda0f9..0000000000 --- a/railties/lib/rails/generators/test_unit/helper/templates/helper_test.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'test_helper' - -<% module_namespacing do -%> -class <%= class_name %>HelperTest < ActionView::TestCase -end -<% end -%> diff --git a/railties/lib/rails/generators/test_unit/job/job_generator.rb b/railties/lib/rails/generators/test_unit/job/job_generator.rb new file mode 100644 index 0000000000..566b61ca66 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/job/job_generator.rb @@ -0,0 +1,13 @@ +require 'rails/generators/test_unit' + +module TestUnit # :nodoc: +  module Generators # :nodoc: +    class JobGenerator < Base # :nodoc: +      check_class_collision suffix: 'JobTest' + +      def create_test_file +        template 'unit_test.rb.erb', File.join('test/jobs', class_path, "#{file_name}_job_test.rb") +      end +    end +  end +end diff --git a/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb new file mode 100644 index 0000000000..f5351d0ec6 --- /dev/null +++ b/railties/lib/rails/generators/test_unit/job/templates/unit_test.rb.erb @@ -0,0 +1,9 @@ +require 'test_helper' + +<% module_namespacing do -%> +class <%= class_name %>JobTest < ActiveJob::TestCase +  # test "the truth" do +  #   assert true +  # end +end +<% end -%> diff --git a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb index 85dee1a066..ba131da79d 100644 --- a/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb +++ b/railties/lib/rails/generators/test_unit/mailer/mailer_generator.rb @@ -6,15 +6,15 @@ module TestUnit # :nodoc:        argument :actions, type: :array, default: [], banner: "method method"        def check_class_collision -        class_collisions "#{class_name}Test", "#{class_name}Preview" +        class_collisions "#{class_name}MailerTest", "#{class_name}MailerPreview"        end        def create_test_files -        template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_test.rb") +        template "functional_test.rb", File.join('test/mailers', class_path, "#{file_name}_mailer_test.rb")        end        def create_preview_files -        template "preview.rb", File.join('test/mailers/previews', class_path, "#{file_name}_preview.rb") +        template "preview.rb", File.join('test/mailers/previews', class_path, "#{file_name}_mailer_preview.rb")        end      end    end diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb index 7e204105a3..3cee517db3 100644 --- a/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb +++ b/railties/lib/rails/generators/test_unit/mailer/templates/functional_test.rb @@ -1,7 +1,7 @@  require 'test_helper'  <% module_namespacing do -%> -class <%= class_name %>Test < ActionMailer::TestCase +class <%= class_name %>MailerTest < ActionMailer::TestCase  <% actions.each do |action| -%>    test "<%= action %>" do      mail = <%= class_name %>.<%= action %> diff --git a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb index 3bfd5426e8..6b85764a66 100644 --- a/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb +++ b/railties/lib/rails/generators/test_unit/mailer/templates/preview.rb @@ -1,11 +1,11 @@  <% module_namespacing do -%>  # Preview all emails at http://localhost:3000/rails/mailers/<%= file_path %> -class <%= class_name %>Preview < ActionMailer::Preview +class <%= class_name %>MailerPreview < ActionMailer::Preview  <% actions.each do |action| -%>    # Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>    def <%= action %> -    <%= class_name %>.<%= action %> +    <%= class_name %>Mailer.<%= action %>    end  <% end -%> diff --git a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml index f19e9d1d87..50ca61a35b 100644 --- a/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml +++ b/railties/lib/rails/generators/test_unit/model/templates/fixtures.yml @@ -5,6 +5,8 @@  <% attributes.each do |attribute| -%>    <%- if attribute.password_digest? -%>    password_digest: <%%= BCrypt::Password.create('secret') %> +  <%- elsif attribute.reference? -%> +  <%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default) %>    <%- else -%>    <%= yaml_key_value(attribute.column_name, attribute.default) %>    <%- end -%> diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb index 18bd1ece9d..8d825ae7b0 100644 --- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb +++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb @@ -19,30 +19,30 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase    test "should create <%= singular_table_name %>" do      assert_difference('<%= class_name %>.count') do -      post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %> +      post :create, params: { <%= "#{singular_table_name}: { #{attributes_hash} }" %> }      end      assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))    end    test "should show <%= singular_table_name %>" do -    get :show, id: <%= "@#{singular_table_name}" %> +    get :show, params: { id: <%= "@#{singular_table_name}" %> }      assert_response :success    end    test "should get edit" do -    get :edit, id: <%= "@#{singular_table_name}" %> +    get :edit, params: { id: <%= "@#{singular_table_name}" %> }      assert_response :success    end    test "should update <%= singular_table_name %>" do -    patch :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> +    patch :update, params: { id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %> }      assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))    end    test "should destroy <%= singular_table_name %>" do      assert_difference('<%= class_name %>.count', -1) do -      delete :destroy, id: <%= "@#{singular_table_name}" %> +      delete :destroy, params: { id: <%= "@#{singular_table_name}" %> }      end      assert_redirected_to <%= index_helper %>_path diff --git a/railties/lib/rails/generators/testing/assertions.rb b/railties/lib/rails/generators/testing/assertions.rb index 2e877f8762..bd069e4bd0 100644 --- a/railties/lib/rails/generators/testing/assertions.rb +++ b/railties/lib/rails/generators/testing/assertions.rb @@ -1,3 +1,5 @@ +require 'shellwords' +  module Rails    module Generators      module Testing diff --git a/railties/lib/rails/generators/testing/behaviour.rb b/railties/lib/rails/generators/testing/behaviour.rb index 7576eba6e0..c9700e1cd7 100644 --- a/railties/lib/rails/generators/testing/behaviour.rb +++ b/railties/lib/rails/generators/testing/behaviour.rb @@ -2,6 +2,7 @@ require 'active_support/core_ext/class/attribute'  require 'active_support/core_ext/module/delegation'  require 'active_support/core_ext/hash/reverse_merge'  require 'active_support/core_ext/kernel/reporting' +require 'active_support/testing/stream'  require 'active_support/concern'  require 'rails/generators' @@ -10,6 +11,7 @@ module Rails      module Testing        module Behaviour          extend ActiveSupport::Concern +        include ActiveSupport::Testing::Stream          included do            class_attribute :destination_root, :current_path, :generator_class, :default_arguments @@ -50,7 +52,7 @@ module Rails          #   class AppGeneratorTest < Rails::Generators::TestCase          #     tests AppGenerator          #     destination File.expand_path("../tmp", File.dirname(__FILE__)) -        #     teardown :cleanup_destination_root +        #     setup :prepare_destination          #          #     test "database.yml is not created when skipping Active Record" do          #       run_generator %w(myapp --skip-active-record) @@ -100,6 +102,7 @@ module Rails              dirname, file_name = File.dirname(absolute), File.basename(absolute).sub(/\.rb$/, '')              Dir.glob("#{dirname}/[0-9]*_*.rb").grep(/\d+_#{file_name}.rb$/).first            end +        end      end    end diff --git a/railties/lib/rails/info.rb b/railties/lib/rails/info.rb index 9502876ebb..5909446b66 100644 --- a/railties/lib/rails/info.rb +++ b/railties/lib/rails/info.rb @@ -1,11 +1,14 @@  require "cgi"  module Rails +  # This module helps build the runtime properties used to display in the +  # Rails::InfoController responses. Including the active Rails version, Ruby +  # version, Rack version, and so on.    module Info      mattr_accessor :properties      class << (@@properties = [])        def names -        map {|val| val.first } +        map(&:first)        end        def value_for(property_name) @@ -22,19 +25,8 @@ module Rails        rescue Exception        end -      def frameworks -        %w( active_record action_pack action_view action_mailer active_support active_model ) -      end - -      def framework_version(framework) -        if Object.const_defined?(framework.classify) -          require "#{framework}/version" -          framework.classify.constantize.version.to_s -        end -      end -        def to_s -        column_width = properties.names.map {|name| name.length}.max +        column_width = properties.names.map(&:length).max          info = properties.map do |name, value|            value = value.join(", ") if value.is_a?(Array)            "%-#{column_width}s   %s" % [name, value] @@ -61,6 +53,11 @@ module Rails        end      end +    # The Rails version. +    property 'Rails version' do +      Rails.version.to_s +    end +      # The Ruby version and platform, e.g. "2.0.0-p247 (x86_64-darwin12.4.0)".      property 'Ruby version' do        "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_PLATFORM})" @@ -75,23 +72,10 @@ module Rails        ::Rack.release      end -    # The Rails version. -    property 'Rails version' do -      Rails.version.to_s -    end -      property 'JavaScript Runtime' do        ExecJS.runtime.name      end -    # Versions of each Rails framework (Active Record, Action Pack, -    # Action Mailer, and Active Support). -    frameworks.each do |framework| -      property "#{framework.titlecase} version" do -        framework_version(framework) -      end -    end -      property 'Middleware' do        Rails.configuration.middleware.map(&:inspect)      end diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb index 3eb66c07af..5458036219 100644 --- a/railties/lib/rails/paths.rb +++ b/railties/lib/rails/paths.rb @@ -77,23 +77,23 @@ module Rails        end        def all_paths -        values.tap { |v| v.uniq! } +        values.tap(&:uniq!)        end        def autoload_once -        filter_by { |p| p.autoload_once? } +        filter_by(&:autoload_once?)        end        def eager_load -        filter_by { |p| p.eager_load? } +        filter_by(&:eager_load?)        end        def autoload_paths -        filter_by { |p| p.autoload? } +        filter_by(&:autoload?)        end        def load_paths -        filter_by { |p| p.load_path? } +        filter_by(&:load_path?)        end      private @@ -167,8 +167,8 @@ module Rails          @paths.concat paths        end -      def unshift(path) -        @paths.unshift path +      def unshift(*paths) +        @paths.unshift(*paths)        end        def to_ary diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb index 886f0e52e1..a4c4527a72 100644 --- a/railties/lib/rails/rack.rb +++ b/railties/lib/rails/rack.rb @@ -1,7 +1,5 @@  module Rails    module Rack -    autoload :Debugger,      "rails/rack/debugger"   if RUBY_VERSION < '2.0.0' -    autoload :Logger,        "rails/rack/logger" -    autoload :LogTailer,     "rails/rack/log_tailer" +    autoload :Logger, "rails/rack/logger"    end  end diff --git a/railties/lib/rails/rack/debugger.rb b/railties/lib/rails/rack/debugger.rb index f7b77bcb3b..1fde3db070 100644 --- a/railties/lib/rails/rack/debugger.rb +++ b/railties/lib/rails/rack/debugger.rb @@ -1,24 +1,3 @@ -module Rails -  module Rack -    class Debugger -      def initialize(app) -        @app = app +require 'active_support/deprecation' -        ARGV.clear # clear ARGV so that rails server options aren't passed to IRB - -        require 'debugger' - -        ::Debugger.start -        ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings) -        puts "=> Debugger enabled" -      rescue LoadError -        puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again." -        exit(1) -      end - -      def call(env) -        @app.call(env) -      end -    end -  end -end +ActiveSupport::Deprecation.warn("This file is deprecated and will be removed in Rails 5.1 with no replacement.") diff --git a/railties/lib/rails/rack/log_tailer.rb b/railties/lib/rails/rack/log_tailer.rb deleted file mode 100644 index 50d0eb96fc..0000000000 --- a/railties/lib/rails/rack/log_tailer.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Rails -  module Rack -    class LogTailer -      def initialize(app, log = nil) -        @app = app - -        path = Pathname.new(log || "#{::File.expand_path(Rails.root)}/log/#{Rails.env}.log").cleanpath - -        @cursor = @file = nil -        if ::File.exist?(path) -          @cursor = ::File.size(path) -          @file = ::File.open(path, 'r') -        end -      end - -      def call(env) -        response = @app.call(env) -        tail! -        response -      end - -      def tail! -        return unless @cursor -        @file.seek @cursor - -        unless @file.eof? -          contents = @file.read -          @cursor = @file.tell -          $stdout.print contents -        end -      end -    end -  end -end diff --git a/railties/lib/rails/rack/logger.rb b/railties/lib/rails/rack/logger.rb index 3b35798679..9962e6d943 100644 --- a/railties/lib/rails/rack/logger.rb +++ b/railties/lib/rails/rack/logger.rb @@ -34,7 +34,7 @@ module Rails          instrumenter = ActiveSupport::Notifications.instrumenter          instrumenter.start 'request.action_dispatch', request: request -        logger.info started_request_message(request) +        logger.info { started_request_message(request) }          resp = @app.call(env)          resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }          resp diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 2b33beaa2b..8c24d1d56d 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -93,7 +93,7 @@ module Rails    #     end    #   end    # -  # By default, Rails load generators from your load path. However, if you want to place +  # By default, Rails loads generators from your load path. However, if you want to place    # your generators at a different location, you can specify in your Railtie a block which    # will load them during normal generators lookup:    # diff --git a/railties/lib/rails/ruby_version_check.rb b/railties/lib/rails/ruby_version_check.rb index df74643a59..aea3d2339c 100644 --- a/railties/lib/rails/ruby_version_check.rb +++ b/railties/lib/rails/ruby_version_check.rb @@ -1,13 +1,13 @@ -if RUBY_VERSION < '1.9.3' +if RUBY_VERSION < '2.2.0'    desc = defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"    abort <<-end_message -    Rails 4 prefers to run on Ruby 2.1 or newer. +    Rails 5 requires to run on Ruby 2.2.0 or newer.      You're running        #{desc} -    Please upgrade to Ruby 1.9.3 or newer to continue. +    Please upgrade to Ruby 2.2.0 or newer to continue.    end_message  end diff --git a/railties/lib/rails/rubyprof_ext.rb b/railties/lib/rails/rubyprof_ext.rb deleted file mode 100644 index 017eba3a76..0000000000 --- a/railties/lib/rails/rubyprof_ext.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'prof' - -module Prof #:nodoc: -  # Adapted from Shugo Maeda's unprof.rb -  def self.print_profile(results, io = $stderr) -    total = results.detect { |i| -      i.method_class.nil? && i.method_id == :"#toplevel" -    }.total_time -    total = 0.001 if total < 0.001 - -    io.puts "  %%   cumulative   self              self     total" -    io.puts " time   seconds   seconds    calls  ms/call  ms/call  name" - -    sum = 0.0 -    results.each do |r| -      sum += r.self_time - -      name =  if r.method_class.nil? -                r.method_id.to_s -              elsif r.method_class.is_a?(Class) -                "#{r.method_class}##{r.method_id}" -              else -                "#{r.method_class}.#{r.method_id}" -              end -      io.printf "%6.2f %8.3f  %8.3f %8d %8.2f %8.2f  %s\n", -        r.self_time / total * 100, -        sum, -        r.self_time, -        r.count, -        r.self_time * 1000 / r.count, -        r.total_time * 1000 / r.count, -        name -    end -  end -end diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb index 201532d299..9b058a1848 100644 --- a/railties/lib/rails/source_annotation_extractor.rb +++ b/railties/lib/rails/source_annotation_extractor.rb @@ -80,9 +80,8 @@ class SourceAnnotationExtractor    # Returns a hash that maps filenames under +dir+ (recursively) to arrays    # with their annotations. Only files with annotations are included. Files -  # with extension +.builder+, +.rb+, +.erb+, +.haml+, +.slim+, +.css+, -  # +.scss+, +.js+, +.coffee+, +.rake+, +.sass+ and +.less+ -  # are taken into account. +  # with extension +.builder+, +.rb+, +.rake+, +.yml+, +.yaml+, +.ruby+, +  # +.css+, +.js+ and +.erb+ are taken into account.    def find_in(dir)      results = {} diff --git a/railties/lib/rails/tasks.rb b/railties/lib/rails/tasks.rb index af5f2707b1..945fbdb3e2 100644 --- a/railties/lib/rails/tasks.rb +++ b/railties/lib/rails/tasks.rb @@ -1,7 +1,8 @@ +require 'rake' +  # Load Rails Rakefile extensions  %w(    annotations -  documentation    framework    log    middleware diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake deleted file mode 100644 index 8544890553..0000000000 --- a/railties/lib/rails/tasks/documentation.rake +++ /dev/null @@ -1,70 +0,0 @@ -begin -  require 'rdoc/task' -rescue LoadError -  # Rubinius installs RDoc as a gem, and for this interpreter "rdoc/task" is -  # available only if the application bundle includes "rdoc" (normally as a -  # dependency of the "sdoc" gem.) -  # -  # If RDoc is not available it is fine that we do not generate the tasks that -  # depend on it. Just be robust to this gotcha and go on. -else -  require 'rails/api/task' - -  # Monkey-patch to remove redoc'ing and clobber descriptions to cut down on rake -T noise -  class RDocTaskWithoutDescriptions < RDoc::Task -    include ::Rake::DSL - -    def define -      task rdoc_task_name - -      task rerdoc_task_name => [clobber_task_name, rdoc_task_name] - -      task clobber_task_name do -        rm_r rdoc_dir rescue nil -      end - -      task :clobber => [clobber_task_name] - -      directory @rdoc_dir -      task rdoc_task_name => [rdoc_target] -      file rdoc_target => @rdoc_files + [Rake.application.rakefile] do -        rm_r @rdoc_dir rescue nil -        @before_running_rdoc.call if @before_running_rdoc -        args = option_list + @rdoc_files -        if @external -          argstring = args.join(' ') -          sh %{ruby -Ivendor vendor/rd #{argstring}} -        else -          require 'rdoc/rdoc' -          RDoc::RDoc.new.document(args) -        end -      end -      self -    end -  end - -  namespace :doc do -    RDocTaskWithoutDescriptions.new("app") { |rdoc| -      rdoc.rdoc_dir = 'doc/app' -      rdoc.template = ENV['template'] if ENV['template'] -      rdoc.title    = ENV['title'] || "Rails Application Documentation" -      rdoc.options << '--line-numbers' -      rdoc.options << '--charset' << 'utf-8' -      rdoc.rdoc_files.include('README.rdoc') -      rdoc.rdoc_files.include('app/**/*.rb') -      rdoc.rdoc_files.include('lib/**/*.rb') -    } -    Rake::Task['doc:app'].comment = "Generate docs for the app -- also available doc:rails, doc:guides (options: TEMPLATE=/rdoc-template.rb, TITLE=\"Custom Title\")" - -    # desc 'Generate documentation for the Rails framework.' -    Rails::API::AppTask.new('rails') -  end -end - -namespace :doc do -  task :guides do -    rails_gem_dir = Gem::Specification.find_by_name("rails").gem_dir -    require File.expand_path(File.join(rails_gem_dir, "/guides/rails_guides")) -    RailsGuides::Generator.new(Rails.root.join("doc/guides")).generate -  end -end diff --git a/railties/lib/rails/tasks/statistics.rake b/railties/lib/rails/tasks/statistics.rake index ae5a7d2759..735c36eb3a 100644 --- a/railties/lib/rails/tasks/statistics.rake +++ b/railties/lib/rails/tasks/statistics.rake @@ -1,9 +1,10 @@ -# while having global constant is not good, -# many 3rd party tools depend on it, like rspec-rails, cucumber-rails, etc -# so if will be removed - deprecation warning is needed +# While global constants are bad, many 3rd party tools depend on this one (e.g +# rspec-rails & cucumber-rails). So a deprecation warning is needed if we want +# to remove it.  STATS_DIRECTORIES = [    %w(Controllers        app/controllers),    %w(Helpers            app/helpers), +  %w(Jobs               app/jobs),    %w(Models             app/models),    %w(Mailers            app/mailers),    %w(Javascripts        app/assets/javascripts), @@ -13,10 +14,9 @@ STATS_DIRECTORIES = [    %w(Helper\ tests      test/helpers),    %w(Model\ tests       test/models),    %w(Mailer\ tests      test/mailers), +  %w(Job\ tests         test/jobs),    %w(Integration\ tests test/integration), -  %w(Functional\ tests\ (old)  test/functional), -  %w(Unit\ tests \ (old)       test/unit) -].collect do |name, dir|  +].collect do |name, dir|    [ name, "#{File.dirname(Rake.application.rakefile_location)}/#{dir}" ]  end.select { |name, dir| File.directory?(dir) } @@ -24,4 +24,4 @@ desc "Report code statistics (KLOCs, etc) from the application or engine"  task :stats do    require 'rails/code_statistics'    CodeStatistics.new(*STATS_DIRECTORIES).to_s -end
\ No newline at end of file +end diff --git a/railties/lib/rails/tasks/tmp.rake b/railties/lib/rails/tasks/tmp.rake index 116988665f..9162ef234a 100644 --- a/railties/lib/rails/tasks/tmp.rake +++ b/railties/lib/rails/tasks/tmp.rake @@ -1,9 +1,8 @@  namespace :tmp do -  desc "Clear session, cache, and socket files from tmp/ (narrow w/ tmp:sessions:clear, tmp:cache:clear, tmp:sockets:clear)" -  task clear: [ "tmp:sessions:clear",  "tmp:cache:clear", "tmp:sockets:clear"] +  desc "Clear cache and socket files from tmp/ (narrow w/ tmp:cache:clear, tmp:sockets:clear)" +  task clear: ["tmp:cache:clear", "tmp:sockets:clear"] -  tmp_dirs = [ 'tmp/sessions', -               'tmp/cache', +  tmp_dirs = [ 'tmp/cache',                 'tmp/sockets',                 'tmp/pids',                 'tmp/cache/assets/development', @@ -12,16 +11,9 @@ namespace :tmp do    tmp_dirs.each { |d| directory d } -  desc "Creates tmp directories for sessions, cache, sockets, and pids" +  desc "Creates tmp directories for cache, sockets, and pids"    task create: tmp_dirs -  namespace :sessions do -    # desc "Clears all files in tmp/sessions" -    task :clear do -      FileUtils.rm(Dir['tmp/sessions/[^.]*']) -    end -  end -    namespace :cache do      # desc "Clears all files and directories in tmp/cache"      task :clear do diff --git a/railties/lib/rails/templates/rails/mailers/email.html.erb b/railties/lib/rails/templates/rails/mailers/email.html.erb index 977feb922b..0b08a01896 100644 --- a/railties/lib/rails/templates/rails/mailers/email.html.erb +++ b/railties/lib/rails/templates/rails/mailers/email.html.erb @@ -2,6 +2,14 @@  <html><head>  <meta name="viewport" content="width=device-width" />  <style type="text/css"> +  html, body, iframe { +    height: 100%; +  } + +  body { +    margin: 0; +  } +    header {      width: 100%;      padding: 10px 0 0 0; @@ -34,7 +42,6 @@    iframe {      border: 0;      width: 100%; -    height: 800px;    }  </style>  </head> @@ -95,4 +102,4 @@  <iframe seamless name="messageBody" src="?part=<%= Rack::Utils.escape(@part.mime_type) %>"></iframe>  </body> -</html>
\ No newline at end of file +</html> diff --git a/railties/lib/rails/templates/rails/welcome/index.html.erb b/railties/lib/rails/templates/rails/welcome/index.html.erb index eb620caa00..6726c23fc9 100644 --- a/railties/lib/rails/templates/rails/welcome/index.html.erb +++ b/railties/lib/rails/templates/rails/welcome/index.html.erb @@ -19,13 +19,13 @@        }        a  {color: #03c} +        a:hover {          background-color: #03c;          color: white;          text-decoration: none;        } -        #page {          background-color: #f0f0f0;          width: 750px; @@ -57,21 +57,21 @@          padding-right: 30px;        } -        #header {          background-image: url(data:image/png;base64,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);          background-repeat: no-repeat;          background-position: top left;          height: 64px;        } +        #header h1, #header h2 {margin: 0} +        #header h2 {          color: #888;          font-weight: normal;          font-size: 16px;        } -        #about h3 {          margin: 0;          margin-bottom: 10px; @@ -84,18 +84,26 @@          margin-left: -55px;          margin-right: -10px;        } +        #about-content table {          margin-top: 10px;          margin-bottom: 10px;          font-size: 11px;          border-collapse: collapse;        } +        #about-content td {          padding: 10px;          padding-top: 3px;          padding-bottom: 3px;        } -      #about-content td.name  {color: #555} + +      #about-content td.name  { +        font-weight: bold; +        vertical-align: top; +        color: #555; +      } +        #about-content td.value {color: #000}        #about-content ul { @@ -107,21 +115,23 @@          background-color: #fcc;          border: 1px solid #f00;        } +        #about-content.failure p {          margin: 0;          padding: 10px;        } -        #getting-started {          border-top: 1px solid #ccc;          margin-top: 25px;          padding-top: 15px;        } +        #getting-started h1 {          margin: 0;          font-size: 20px;        } +        #getting-started h2 {          margin: 0;          font-size: 14px; @@ -129,40 +139,46 @@          color: #333;          margin-bottom: 25px;        } +        #getting-started ol {          margin-left: 0;          padding-left: 0;        } +        #getting-started li {          font-size: 18px;          color: #888;          margin-bottom: 25px;        } +        #getting-started li h2 {          margin: 0;          font-weight: normal;          font-size: 18px;          color: #333;        } +        #getting-started li p {          color: #555;          font-size: 13px;        } -        #sidebar ul {          margin-left: 0;          padding-left: 0;        } +        #sidebar ul h3 {          margin-top: 25px;          font-size: 16px;          padding-bottom: 10px;          border-bottom: 1px solid #ccc;        } +        #sidebar li {          list-style-type: none;        } +        #sidebar ul.links li {          margin-bottom: 5px;        } @@ -221,7 +237,7 @@            <ol>              <li> -              <h2>Use <code>rails generate</code> to create your models and controllers</h2> +              <h2>Use <code>bin/rails generate</code> to create your models and controllers</h2>                <p>To see all available options, run it without parameters.</p>              </li> diff --git a/railties/lib/rails/test_help.rb b/railties/lib/rails/test_help.rb index c837fadb40..40a1915b54 100644 --- a/railties/lib/rails/test_help.rb +++ b/railties/lib/rails/test_help.rb @@ -21,6 +21,7 @@ if defined?(ActiveRecord::Base)    class ActiveSupport::TestCase      include ActiveRecord::TestFixtures      self.fixture_path = "#{Rails.root}/test/fixtures/" +    self.file_fixture_path = self.fixture_path + "files"    end    ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path diff --git a/railties/lib/rails/test_unit/sub_test_task.rb b/railties/lib/rails/test_unit/sub_test_task.rb index d9bffba4d7..6fa96d2ced 100644 --- a/railties/lib/rails/test_unit/sub_test_task.rb +++ b/railties/lib/rails/test_unit/sub_test_task.rb @@ -7,7 +7,7 @@ module Rails      #      # This class takes a TestInfo class and defines the appropriate rake task      # based on the information, then invokes it. -    class TestCreator +    class TestCreator # :nodoc:        def initialize(info)          @info = info        end @@ -41,7 +41,7 @@ module Rails      # to test files (or can be transformed into test files). Calling <tt>files</tt>      # provides the set of test files and is used when initializing tests after      # a call to <tt>rake test</tt>. -    class TestInfo +    class TestInfo # :nodoc:        def initialize(tasks)          @tasks = tasks          @files = nil diff --git a/railties/lib/rails/test_unit/testing.rake b/railties/lib/rails/test_unit/testing.rake index 285e2ce846..d836c0d6d6 100644 --- a/railties/lib/rails/test_unit/testing.rake +++ b/railties/lib/rails/test_unit/testing.rake @@ -3,32 +3,27 @@ require 'rails/test_unit/sub_test_task'  task default: :test -desc 'Runs test:units, test:functionals, test:generators, test:integration together' +desc "Runs all tests in test folder"  task :test do    Rails::TestTask.test_creator(Rake.application.top_level_tasks).invoke_rake_task  end  namespace :test do    task :prepare do -    # Placeholder task for other Railtie and plugins to enhance. See Active Record for an example. +    # Placeholder task for other Railtie and plugins to enhance. +    # If used with Active Record, this task runs before the database schema is synchronized.    end -  task :run => ['test:units', 'test:functionals', 'test:generators', 'test:integration'] - -  # Inspired by: http://ngauthier.com/2012/02/quick-tests-with-bash.html -  desc "Run tests quickly by merging all types and not resetting db" -  Rails::TestTask.new(:all) do |t| +  Rails::TestTask.new(:run) do |t|      t.pattern = "test/**/*_test.rb"    end -  namespace :all do -    desc "Run tests quickly, but also reset db" -    task :db => %w[db:test:prepare test:all] -  end +  desc "Run tests quickly, but also reset db" +  task :db => %w[db:test:prepare test]    Rails::TestTask.new(single: "test:prepare") -  ["models", "helpers", "controllers", "mailers", "integration"].each do |name| +  ["models", "helpers", "controllers", "mailers", "integration", "jobs"].each do |name|      Rails::TestTask.new(name => "test:prepare") do |t|        t.pattern = "test/#{name}/**/*_test.rb"      end  | 
