diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/CHANGELOG.md | 525 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/gem_version.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/app_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/named_base.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/cable.yml | 9 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/secrets.yml | 8 | ||||
-rw-r--r-- | railties/test/application/assets_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 25 | ||||
-rw-r--r-- | railties/test/generators/channel_generator_test.rb | 24 |
10 files changed, 78 insertions, 538 deletions
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md index ed3a3e8527..f3543d5dee 100644 --- a/railties/CHANGELOG.md +++ b/railties/CHANGELOG.md @@ -1,524 +1,7 @@ -## Rails 5.0.0.beta4 (April 27, 2016) ## +## Rails 5.1.0.alpha ## -* Add `config/initializers/to_time_preserves_timezone.rb`, which tells - Active Support to preserve the receiver's timezone when calling `to_time`. - This matches the new behavior that will be part of Ruby 2.4. +* Added a shared section to config/secrets.yml that will be loaded for all environments. - Fixes #24617. + *DHH* - *Andrew White* - -* Make `rails restart` command work with Puma by passing the restart command - which Puma can use to restart rails server. - - *Prathamesh Sonpatki* - -* The application generator writes a new file `config/spring.rb`, which tells - Spring to watch additional common files. - - *Xavier Noria* - -* The tasks in the rails task namespace is deprecated in favor of app namespace. - (e.g. `rails:update` and `rails:template` tasks is renamed to `app:update` and `app:template`.) - - *Ryo Hashimoto* - -* Enable HSTS with IncludeSudomains header for new applications. - - *Egor Homakov*, *Prathamesh Sonpatki* - -## Rails 5.0.0.beta3 (February 24, 2016) ## - -* Alias `rake` with `rails_command` in the Rails Application Templates API - following Rails 5 convention of preferring "rails" to "rake" to run tasks. - - *claudiob* - -* Generate applications with an option to log to STDOUT in production - using the environment variable `RAILS_LOG_TO_STDOUT`. - - *Richard Schneeman* - -* Change fail fast of `bin/rails test` interrupts run on error. - - *Yuji Yaginuma* - -* The application generator supports `--skip-listen` to opt-out of features - that depend on the listen gem. As of this writing they are the evented file - system monitor and the async plugin for spring. - -* The Gemfiles of new applications include spring-watcher-listen on Linux and - Mac OS X (unless `--skip-spring`). - - *Xavier Noria* - -* New applications are generated with the evented file system monitor enabled - on Linux and Mac OS X. - - *Xavier Noria* - -* Add dummy files for apple-touch-icon.png and apple-touch-icon.png. - - See #23427. - - *Alexey Zabelin* - -## Rails 5.0.0.beta2 (February 01, 2016) ## - -* Add `after_bundle` callbacks in Rails plugin templates. Useful for allowing - templates to perform actions that are dependent upon `bundle install`. - - *Ryan Manuel* - -* Bring back `TEST=` env for `rake test` task. - - *Yves Senn* - -* Specify log file names or all logs to clear `rake log:clear` - - Specify which logs to clear when using the `rake log:clear` task, e.g. `rake log:clear LOGS=test,staging` - - Clear all logs from log/*.log e.g. `rake log:clear LOGS=all` - - By default `rake log:clear` clears standard environment log files i.e. 'development,test,production' - - *Pramod Shinde* - -* Fix using `add_source` with a block after using `gem` in a custom generator. - - *Will Fisher* - - -## Rails 5.0.0.beta1 (December 18, 2015) ## - -* Newly generated plugins get a `README.md` in Markdown. - - *Yuji Yaginuma* - -* The generated config file for the development environment includes a new - config line, commented out, showing how to enable the evented file watcher. - - *Xavier Noria* - -* `config.debug_exception_response_format` configures the format used - in responses when errors occur in development mode. - - Set `config.debug_exception_response_format` to render an HTML page with - debug info (using the value `:default`) or render debug info preserving - the response format (using the value `:api`). - - *Jorge Bejar* - -* Fix setting exit status code for rake test tasks. The exit status code - was not set when tests were fired with `rake`. Now, it is being set and it matches - behavior of running tests via `rails` command (`rails test`), so no matter if - `rake test` or `rails test` command is used the exit code will be set. - - *Arkadiusz Fal* - -* Add Command infrastructure to replace rake. - - Also move `rake dev:cache` to new infrastructure. You'll need to use - `rails dev:cache` to toggle development caching from now on. - - *Chuck Callebs* - -* Allow use of `minitest-rails` gem with Rails test runner. - - Fixes #22455. - - *Chris Kottom* - -* Add `bin/test` script to rails plugin. - - `bin/test` can use the same API as `bin/rails test`. - - *Yuji Yaginuma* - -* Make `static_index` part of the `config.public_file_server` config and - call it `config.public_file_server.index_name`. - - *Yuki Nishijima* - -* Deprecate `config.serve_static_files` in favor of `config.public_file_server.enabled`. - - Unifies the static asset options under `config.public_file_server`. - - To upgrade, replace occurrences of: - - ``` - config.serve_static_files = # false or true - ``` - - in your environment files, with: - - ``` - config.public_file_server.enabled = # false or true - ``` - - *Kasper Timm Hansen* - -* Deprecate `config.static_cache_control` in favor of - `config.public_file_server.headers`. - - To upgrade, replace occurrences of: - - ``` - config.static_cache_control = 'public, max-age=60' - ``` - - in your environment files, with: - - ``` - config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=60' - } - ``` - - `config.public_file_server.headers` can set arbitrary headers, sent along when - a response is delivered. - - *Yuki Nishijima* - -* Route generators are now idempotent. - Running generators several times no longer require you to cleanup routes.rb. - - *Thiago Pinto* - -* Allow passing an environment to `config_for`. - - *Simon Eskildsen* - -* Allow `rake stats` to account for rake tasks in lib/tasks. - - *Kevin Deisz* - -* Added javascript to update the URL on mailer previews with the currently - selected email format. Reloading the page now keeps you on your selected - format rather than going back to the default html version. - - *James Kerr* - -* Add fail fast to `bin/rails test`. - - Adding `--fail-fast` or `-f` when running tests will interrupt the run on - the first failure: - - ``` - # Running: - - ................................................S......E - - ArgumentError: Wups! Bet you didn't expect this! - test/models/bunny_test.rb:19:in `block in <class:BunnyTest>' - - bin/rails test test/models/bunny_test.rb:18 - - ....................................F - - This failed - - bin/rails test test/models/bunny_test.rb:14 - - Interrupted. Exiting... - - - Finished in 0.051427s, 1808.3872 runs/s, 1769.4972 assertions/s. - - ``` - - Note that any unexpected errors don't abort the run. - - *Kasper Timm Hansen* - -* Add inline output to `bin/rails test`. - - Any failures or errors (and skips if running in verbose mode) are output - during a test run: - - ``` - # Running: - - .....S..........................................F - - This failed - - bin/rails test test/models/bunny_test.rb:14 - - .................................E - - ArgumentError: Wups! Bet you didn't expect this! - test/models/bunny_test.rb:19:in `block in <class:BunnyTest>' - - bin/rails test test/models/bunny_test.rb:18 - - .................... - - Finished in 0.069708s, 1477.6019 runs/s, 1448.9106 assertions/s. - ``` - - Output can be deferred to after a run with the `--defer-output` option. - - *Kasper Timm Hansen* - -* Fix displaying mailer previews on non local requests when config - `config.action_mailer.show_previews` is set. - - *Wojciech Wnętrzak* - -* `rails server` will now honour the `PORT` environment variable - - *David Cornu* - -* Plugins generated using `rails plugin new` are now generated with the - version number set to 0.1.0. - - *Daniel Morris* - -* `I18n.load_path` is now reloaded under development so there's no need to - restart the server to make new locale files available. Also, I18n will no - longer raise for deleted locale files. - - *Kir Shatrov* - -* Add `bin/update` script to update development environment automatically. - - *Mehmet Emin İNAÇ* - -* Fix STATS_DIRECTORIES already defined warning when running rake from within - the top level directory of an engine that has a test app. - - Fixes #20510. - - *Ersin Akinci* - -* Make enabling or disabling caching in development mode possible with - `rake dev:cache`. - - Running `rake dev:cache` will create or remove tmp/caching-dev.txt. When this - file exists `config.action_controller.perform_caching` will be set to true in - config/environments/development.rb. - - Additionally, a server can be started with either `--dev-caching` or - `--no-dev-caching` included to toggle caching on startup. - - *Jussi Mertanen*, *Chuck Callebs* - -* Add a `--api` option in order to generate plugins that can be added - inside an API application. - - *Robin Dupret* - -* Fix `NoMethodError` when generating a scaffold inside a full engine. - - *Yuji Yaginuma* - -* Adding support for passing a block to the `add_source` action of a custom generator. - - *Mike Dalton*, *Hirofumi Wakasugi* - -* `assert_file` now understands paths with special characters - (eg. `v0.1.4~alpha+nightly`). - - *Diego Carrion* - -* Remove ContentLength middleware from the defaults. If you want it, just - add it as a middleware in your config. - - *Egg McMuffin* - -* Make it possible to customize the executable inside rerun snippets. - - *Yves Senn* - -* Add support for API only apps. - Middleware stack was slimmed down and it has only the needed - middleware for API apps & generators generates the right files, - folders and configurations. - - *Santiago Pastorino*, *Jorge Bejar* - -* Make generated scaffold functional tests work inside engines. - - *Yuji Yaginuma* - -* Generate a `.keep` file in the `tmp` folder by default as many scripts - assume the existence of this folder and most would fail if it is absent. - - See #20299. - - *Yoong Kang Lim*, *Sunny Juneja* - -* `config.static_index` configures directory `index.html` filename - - Set `config.static_index` to serve a static directory index file not named - `index`. E.g. to serve `main.html` instead of `index.html` for directory - requests, set `config.static_index` to `"main"`. - - *Eliot Sykes* - -* `bin/setup` uses built-in rake tasks (`log:clear`, `tmp:clear`). - - *Mohnish Thallavajhula* - -* Fix mailer previews with attachments by using the mail gem's own API to - locate the first part of the correct mime type. - - Fixes #14435. - - *Andrew White* - -* Remove sqlite support from `rails dbconsole`. - - *Andrew White* - -* Rename `railties/bin` to `railties/exe` to match the new Bundler executables - convention. - - *Islam Wazery* - -* Print `bundle install` output in `rails new` as soon as it's available. - - Running `rails new` will now print the output of `bundle install` as - it is available, instead of waiting until all gems finish installing. - - *Max Holder* - -* Respect `pluralize_table_names` when generating fixture file. - - Fixes #19519. - - *Yuji Yaginuma* - -* Add a new-line to the end of route method generated code. - - We need to add a `\n`, because we cannot have two routes - in the same line. - - *arthurnn* - -* Add `rake initializers`. - - This task prints out all defined initializers in the order they are invoked - by Rails. This is helpful for debugging issues related to the initialization - process. - - *Naoto Kaneko* - -* Created rake restart task. Restarts your Rails app by touching the - `tmp/restart.txt`. - - See #18876. - - *Hyonjee Joo* - -* Add `config/initializers/active_record_belongs_to_required_by_default.rb`. - - Newly generated Rails apps have a new initializer called - `active_record_belongs_to_required_by_default.rb` which sets the value of - the configuration option `config.active_record.belongs_to_required_by_default` - to `true` when ActiveRecord is not skipped. - - As a result, new Rails apps require `belongs_to` association on model - to be valid. - - This initializer is *not* added when running `rake rails:update`, so - old apps ported to Rails 5 will work without any change. - - *Josef Šimánek* - -* `delete` operations in configurations are run last in order to eliminate - 'No such middleware' errors when `insert_before` or `insert_after` are added - after the `delete` operation for the middleware being deleted. - - Fixes #16433. - - *Guo Xiang Tan* - -* Newly generated applications get a `README.md` in Markdown. - - *Xavier Noria* - -* Remove the documentation tasks `doc:app`, `doc:rails`, and `doc:guides`. - - *Xavier Noria* - -* Force generated routes to be inserted into `config/routes.rb`. - - *Andrew White* - -* Don't remove all line endings from `config/routes.rb` when revoking scaffold. - - Fixes #15913. - - *Andrew White* - -* Rename `--skip-test-unit` option to `--skip-test` in app generator - - *Melanie Gilman* - -* Add the `method_source` gem to the default Gemfile for apps. - - *Sean Griffin* - -* Drop old test locations from `rake stats`: - - - test/functional - - test/unit - - *Ravil Bayramgalin* - -* Update `rake stats` to correctly count declarative tests - as methods in `_test.rb` files. - - *Ravil Bayramgalin* - -* Remove deprecated `test:all` and `test:all:db` tasks. - - *Rafael Mendonça França* - -* Remove deprecated `Rails::Rack::LogTailer`. - - *Rafael Mendonça França* - -* Remove deprecated `RAILS_CACHE` constant. - - *Rafael Mendonça França* - -* Remove deprecated `serve_static_assets` configuration. - - *Rafael Mendonça França* - -* Use local variables in `_form.html.erb` partial generated by scaffold. - - *Andrew Kozlov* - -* Add `config/initializers/callback_terminator.rb`. - - Newly generated Rails apps have a new initializer called - `callback_terminator.rb` which sets the value of the configuration option - `ActiveSupport.halt_callback_chains_on_return_false` to `false`. - - As a result, new Rails apps do not halt Active Record and Active Model - callback chains when a callback returns `false`; only when they are - explicitly halted with `throw(:abort)`. - - The terminator is *not* added when running `rake rails:update`, so returning - `false` will still work on old apps ported to Rails 5, displaying a - deprecation warning to prompt users to update their code to the new syntax. - - *claudiob* - -* Generated fixtures won't use the id when generated with references attributes. - - *Pablo Olmos de Aguilera Corradini* - -* Add `--skip-action-mailer` option to the app generator. - - *claudiob* - -* Autoload any second level directories called `app/*/concerns`. - - *Alex Robbin* - -Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/railties/CHANGELOG.md) for previous changes. +Please check [5-0-stable](https://github.com/rails/rails/blob/5-0-stable/railties/CHANGELOG.md) for previous changes. diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index ed106c9918..c383de3e06 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -385,11 +385,16 @@ module Rails def secrets @secrets ||= begin secrets = ActiveSupport::OrderedOptions.new - yaml = config.paths["config/secrets"].first + yaml = config.paths["config/secrets"].first + if File.exist?(yaml) require "erb" - all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {} - env_secrets = all_secrets[Rails.env] + + all_secrets = YAML.load(ERB.new(IO.read(yaml)).result) || {} + shared_secrets = all_secrets['shared'] + env_secrets = all_secrets[Rails.env] + + secrets.merge!(shared_secrets.symbolize_keys) if shared_secrets secrets.merge!(env_secrets.symbolize_keys) if env_secrets end diff --git a/railties/lib/rails/gem_version.rb b/railties/lib/rails/gem_version.rb index 08a331bff2..9c49e0655a 100644 --- a/railties/lib/rails/gem_version.rb +++ b/railties/lib/rails/gem_version.rb @@ -6,9 +6,9 @@ module Rails module VERSION MAJOR = 5 - MINOR = 0 + MINOR = 1 TINY = 0 - PRE = "beta4" + PRE = "alpha" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb index 151bf9a879..7aee28c74a 100644 --- a/railties/lib/rails/generators/app_base.rb +++ b/railties/lib/rails/generators/app_base.rb @@ -296,7 +296,7 @@ module Rails return [] if options[:skip_sprockets] gems = [] - gems << GemfileEntry.version('sass-rails', '~> 5.0', + gems << GemfileEntry.github('sass-rails', 'rails/sass-rails', nil, 'Use SCSS for stylesheets') gems << GemfileEntry.version('uglifier', @@ -312,7 +312,7 @@ module Rails end def coffee_gemfile_entry - GemfileEntry.version 'coffee-rails', '~> 4.1.0', 'Use CoffeeScript for .coffee assets and views' + GemfileEntry.github 'coffee-rails', 'rails/coffee-rails', nil, 'Use CoffeeScript for .coffee assets and views' end def javascript_gemfile_entry diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index efbf51ddfb..ee076eb711 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -26,6 +26,10 @@ module Rails super end end + + def js_template(source, destination) + template(source + '.js', destination + '.js') + end end protected diff --git a/railties/lib/rails/generators/rails/app/templates/config/cable.yml b/railties/lib/rails/generators/rails/app/templates/config/cable.yml index aa4e832748..0bbde6f74f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/cable.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/cable.yml @@ -1,10 +1,9 @@ -# Action Cable uses Redis by default to administer connections, channels, and sending/receiving messages over the WebSocket. -production: - adapter: redis - url: redis://localhost:6379/1 - development: adapter: async test: adapter: async + +production: + adapter: redis + url: redis://localhost:6379/1 diff --git a/railties/lib/rails/generators/rails/app/templates/config/secrets.yml b/railties/lib/rails/generators/rails/app/templates/config/secrets.yml index cdea2fd060..8e995a5df1 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/secrets.yml +++ b/railties/lib/rails/generators/rails/app/templates/config/secrets.yml @@ -10,6 +10,13 @@ # Make sure the secrets in this file are kept private # if you're sharing your code publicly. +# Shared secrets are available across all environments. + +shared: + api_key: 123 + +# Environmental secrets are only available for that specific environment. + development: secret_key_base: <%= app_secret %> @@ -18,5 +25,6 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. + production: secret_key_base: <%%= ENV["SECRET_KEY_BASE"] %> diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index e32eea42b7..9e8531b482 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -307,7 +307,7 @@ module ApplicationTests assert_not_equal asset_path, assets["assets"]["application.css"] end - test "precompile appends the md5 hash to files referenced with asset_path and run in production with digest true" do + test "precompile appends the MD5 hash to files referenced with asset_path and run in production with digest true" do app_file "app/assets/images/rails.png", "notactuallyapng" app_file "app/assets/stylesheets/application.css.erb", "p { background-image: url(<%= asset_path('rails.png') %>) }" diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 9f3a9cd232..7ec25aeca1 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -555,6 +555,31 @@ module ApplicationTests assert_equal 'myamazonsecretaccesskey', app.secrets.aws_secret_access_key end + test "shared secrets saved in config/secrets.yml are loaded in app secrets" do + app_file 'config/secrets.yml', <<-YAML + shared: + api_key: 3b7cd727 + YAML + + app 'development' + + assert_equal '3b7cd727', app.secrets.api_key + end + + test "shared secrets will yield to environment specific secrets" do + app_file 'config/secrets.yml', <<-YAML + shared: + api_key: 3b7cd727 + + development: + api_key: abc12345 + YAML + + app 'development' + + assert_equal 'abc12345', app.secrets.api_key + end + test "blank config/secrets.yml does not crash the loading process" do app_file 'config/secrets.yml', <<-YAML YAML diff --git a/railties/test/generators/channel_generator_test.rb b/railties/test/generators/channel_generator_test.rb index d58b54ac24..e3edde681f 100644 --- a/railties/test/generators/channel_generator_test.rb +++ b/railties/test/generators/channel_generator_test.rb @@ -24,8 +24,24 @@ class ChannelGeneratorTest < Rails::Generators::TestCase assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) end - assert_file "app/assets/javascripts/channels/chat.coffee" do |channel| - assert_match(/App.cable.subscriptions.create "ChatChannel"/, channel) + assert_file "app/assets/javascripts/channels/chat.js" do |channel| + assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel) + end + end + + def test_channel_with_multiple_actions_is_created + run_generator ['chat', 'speak', 'mute'] + + assert_file "app/channels/chat_channel.rb" do |channel| + assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) + assert_match(/def speak/, channel) + assert_match(/def mute/, channel) + end + + assert_file "app/assets/javascripts/channels/chat.js" do |channel| + assert_match(/App.chat = App.cable.subscriptions.create\("ChatChannel/, channel) + assert_match(/,\n\n speak/, channel) + assert_match(/,\n\n mute: function\(\) \{\n return this\.perform\('mute'\);\n \}\n\}\);/, channel) end end @@ -36,7 +52,7 @@ class ChannelGeneratorTest < Rails::Generators::TestCase assert_match(/class ChatChannel < ApplicationCable::Channel/, channel) end - assert_no_file "app/assets/javascripts/channels/chat.coffee" + assert_no_file "app/assets/javascripts/channels/chat.js" end def test_cable_js_is_created_if_not_present_already @@ -52,7 +68,7 @@ class ChannelGeneratorTest < Rails::Generators::TestCase run_generator ['chat'], behavior: :revoke assert_no_file "app/channels/chat_channel.rb" - assert_no_file "app/assets/javascripts/channels/chat.coffee" + assert_no_file "app/assets/javascripts/channels/chat.js" assert_file "app/channels/application_cable/channel.rb" assert_file "app/channels/application_cable/connection.rb" |