aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authoryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-19 17:20:41 +0900
committeryuuji.yaginuma <yuuji.yaginuma@gmail.com>2017-03-19 21:19:09 +0900
commit53e6fe96b5664e92ee6cd64d08681254fc816f44 (patch)
tree495b473a1629669295f4fd4bb07d2aeb16a2ad80 /railties
parent9cc2f50f9cc3191fd796af68d09826c67c02a572 (diff)
downloadrails-53e6fe96b5664e92ee6cd64d08681254fc816f44.tar.gz
rails-53e6fe96b5664e92ee6cd64d08681254fc816f44.tar.bz2
rails-53e6fe96b5664e92ee6cd64d08681254fc816f44.zip
Correctly check whether key is defined in configuration
It can not check correctly with `defined?` ```ruby irb(main):001:0> Rails.application.config.active_record => {:maintain_test_schema=>true, :belongs_to_required_by_default=>true} irb(main):002:0> defined?(Rails.application.config.active_record) => nil ``` Follow up to #28469
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/application/configuration.rb6
-rw-r--r--railties/test/generators/app_generator_test.rb12
-rw-r--r--railties/test/railties/mounted_engine_test.rb2
3 files changed, 16 insertions, 4 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 027207bbb2..819e801740 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -58,14 +58,14 @@ module Rails
def load_defaults(target_version)
case target_version.to_s
when "5.0"
- if defined?(action_controller)
+ if respond_to?(:action_controller)
action_controller.per_form_csrf_tokens = true
action_controller.forgery_protection_origin_check = true
end
ActiveSupport.to_time_preserves_timezone = true
- if defined?(active_record)
+ if respond_to?(:active_record)
active_record.belongs_to_required_by_default = true
end
@@ -74,7 +74,7 @@ module Rails
when "5.1"
load_defaults "5.0"
- if defined?(assets)
+ if respond_to?(:assets)
assets.unknown_asset_fallback = false
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 281376cdee..ac43e8d22d 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -160,6 +160,18 @@ class AppGeneratorTest < Rails::Generators::TestCase
assert_no_file "config/initializers/new_framework_defaults_5_1.rb"
end
+ def test_new_application_load_defaults
+ app_root = File.join(destination_root, "myfirstapp")
+ run_generator [app_root]
+ output = nil
+
+ Dir.chdir(app_root) do
+ output = `./bin/rails r "puts Rails.application.config.assets.unknown_asset_fallback"`
+ end
+
+ assert_equal "false\n", output
+ end
+
def test_app_update_keep_the_cookie_serializer_if_it_is_already_configured
app_root = File.join(destination_root, "myapp")
run_generator [app_root]
diff --git a/railties/test/railties/mounted_engine_test.rb b/railties/test/railties/mounted_engine_test.rb
index 5838d0d7e7..6639e55382 100644
--- a/railties/test/railties/mounted_engine_test.rb
+++ b/railties/test/railties/mounted_engine_test.rb
@@ -141,7 +141,7 @@ module ApplicationTests
end
def engine_asset_path
- render inline: "<%= asset_path 'images/foo.png' %>"
+ render inline: "<%= asset_path 'images/foo.png', skip_pipeline: true %>"
end
end
end