aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/configuration_test.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test/application/configuration_test.rb')
-rw-r--r--railties/test/application/configuration_test.rb78
1 files changed, 68 insertions, 10 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb
index 983ea5c3e6..9f62ca8eb8 100644
--- a/railties/test/application/configuration_test.rb
+++ b/railties/test/application/configuration_test.rb
@@ -1130,7 +1130,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters
@@ -1141,7 +1141,7 @@ module ApplicationTests
test "config.action_controller.always_permitted_parameters are: controller, action by default" do
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal %w(controller action), ActionController::Parameters.always_permitted_parameters
end
@@ -1153,7 +1153,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal %w( controller action format ), ActionController::Parameters.always_permitted_parameters
end
@@ -1177,7 +1177,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters
@@ -1188,7 +1188,7 @@ module ApplicationTests
test "config.action_controller.action_on_unpermitted_parameters is :log by default on development" do
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters
end
@@ -1196,7 +1196,7 @@ module ApplicationTests
test "config.action_controller.action_on_unpermitted_parameters is :log by default on test" do
app "test"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal :log, ActionController::Parameters.action_on_unpermitted_parameters
end
@@ -1204,11 +1204,18 @@ module ApplicationTests
test "config.action_controller.action_on_unpermitted_parameters is false by default on production" do
app "production"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal false, ActionController::Parameters.action_on_unpermitted_parameters
end
+ test "config.action_controller.default_protect_from_forgery is true by default" do
+ app "development"
+
+ assert_equal true, ActionController::Base.default_protect_from_forgery
+ assert_includes ActionController::Base.__callbacks[:process_action].map(&:filter), :verify_authenticity_token
+ end
+
test "config.action_controller.permit_all_parameters can be configured in an initializer" do
app_file "config/initializers/permit_all_parameters.rb", <<-RUBY
Rails.application.config.action_controller.permit_all_parameters = true
@@ -1216,7 +1223,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal true, ActionController::Parameters.permit_all_parameters
end
@@ -1227,7 +1234,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal [], ActionController::Parameters.always_permitted_parameters
end
@@ -1238,7 +1245,7 @@ module ApplicationTests
app "development"
- ActionController::Base.object_id # force lazy load hooks to run
+ force_lazy_load_hooks { ActionController::Base }
assert_equal :raise, ActionController::Parameters.action_on_unpermitted_parameters
end
@@ -1578,6 +1585,52 @@ module ApplicationTests
assert_equal({}, Rails.application.config.my_custom_config)
end
+ test "default SQLite3Adapter.represent_boolean_as_integer for 5.1 is false" do
+ remove_from_config '.*config\.load_defaults.*\n'
+ add_to_top_of_config <<-RUBY
+ config.load_defaults 5.1
+ RUBY
+ app_file "app/models/post.rb", <<-RUBY
+ class Post < ActiveRecord::Base
+ end
+ RUBY
+
+ app "development"
+ force_lazy_load_hooks { Post }
+
+ assert_not ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer
+ end
+
+ test "default SQLite3Adapter.represent_boolean_as_integer for new installs is true" do
+ app_file "app/models/post.rb", <<-RUBY
+ class Post < ActiveRecord::Base
+ end
+ RUBY
+
+ app "development"
+ force_lazy_load_hooks { Post }
+
+ assert ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer
+ end
+
+ test "represent_boolean_as_integer should be able to set via config.active_record.sqlite3.represent_boolean_as_integer" do
+ remove_from_config '.*config\.load_defaults.*\n'
+
+ app_file "config/initializers/new_framework_defaults_5_2.rb", <<-RUBY
+ Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
+ RUBY
+
+ app_file "app/models/post.rb", <<-RUBY
+ class Post < ActiveRecord::Base
+ end
+ RUBY
+
+ app "development"
+ force_lazy_load_hooks { Post }
+
+ assert ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer
+ end
+
test "config_for containing ERB tags should evaluate" do
app_file "config/custom.yml", <<-RUBY
development:
@@ -1684,5 +1737,10 @@ module ApplicationTests
assert_equal 301, last_response.status
assert_equal "https://example.org/", last_response.location
end
+
+ private
+ def force_lazy_load_hooks
+ yield # Tasty clarifying sugar, homie! We only need to reference a constant to load it.
+ end
end
end