diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/commands/dbconsole.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/migration/USAGE | 13 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 48 |
4 files changed, 63 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 78580b220c..4497ef61df 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -37,7 +37,7 @@ module Rails private def available_environments - Dir[Rails.root.join('config', 'environments', '*.rb')].map { |fname| File.basename(fname, '.*') } + Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') } end end diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 2d1e2d6a45..5914c9e4ae 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -147,7 +147,7 @@ module Rails end def available_environments - Dir[Rails.root.join('config', 'environments', '*.rb')].map { |fname| File.basename(fname, '.*') } + Dir['config/environments/*.rb'].map { |fname| File.basename(fname, '.*') } end def find_cmd_and_exec(commands, *args) diff --git a/railties/lib/rails/generators/rails/migration/USAGE b/railties/lib/rails/generators/rails/migration/USAGE index f340ed97f2..baf3d9894f 100644 --- a/railties/lib/rails/generators/rails/migration/USAGE +++ b/railties/lib/rails/generators/rails/migration/USAGE @@ -20,3 +20,16 @@ Example: add_column :posts, :title, :string add_column :posts, :body, :text add_column :posts, :published, :boolean + +Migration names containing JoinTable will generate join tables for use with +has_and_belongs_to_many associations. + +Example: + `rails g migration CreateMediaJoinTable artists musics:uniq` + + will create the migration + + create_join_table :artists, :musics do |t| + # t.index [:artist_id, :music_id] + t.index [:music_id, :artist_id], unique: true + end diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 920798c930..e41b21e21a 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -567,6 +567,54 @@ module ApplicationTests assert_equal 'permitted', last_response.body end + test "config.action_controller.raise_on_unpermitted_parameters = true" do + app_file 'app/controllers/posts_controller.rb', <<-RUBY + class PostsController < ActionController::Base + def create + render text: params.require(:post).permit(:name) + end + end + RUBY + + add_to_config <<-RUBY + routes.prepend do + resources :posts + end + config.action_controller.raise_on_unpermitted_parameters = true + RUBY + + require "#{app_path}/config/environment" + + assert_equal true, ActionController::Parameters.raise_on_unpermitted_parameters + + post "/posts", {post: {"title" =>"zomg"}} + assert_match "We're sorry, but something went wrong", last_response.body + end + + test "config.action_controller.raise_on_unpermitted_parameters is true by default on development" do + ENV["RAILS_ENV"] = "development" + + require "#{app_path}/config/environment" + + assert_equal true, ActionController::Parameters.raise_on_unpermitted_parameters + end + + test "config.action_controller.raise_on_unpermitted_parameters is true by defaul on test" do + ENV["RAILS_ENV"] = "test" + + require "#{app_path}/config/environment" + + assert_equal true, ActionController::Parameters.raise_on_unpermitted_parameters + end + + test "config.action_controller.raise_on_unpermitted_parameters is false by default on production" do + ENV["RAILS_ENV"] = "production" + + require "#{app_path}/config/environment" + + assert_equal false, ActionController::Parameters.raise_on_unpermitted_parameters + end + test "config.action_dispatch.ignore_accept_header" do make_basic_app do |app| app.config.action_dispatch.ignore_accept_header = true |