Skip to content

Commit 4a94f4a

Browse files
authored
Merge pull request rails#45451 from jonathanhefner/allow_deprecated_singular_associations_name-default-tests
Fix `allow_deprecated_singular_associations_name` framework default
2 parents 1d67200 + 369afa6 commit 4a94f4a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_7_1.rb.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@
4646
# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true
4747

4848
# Disable deprecated singular associations names
49-
# Rails.application.config.active_record.allow_deprecated_singular_associations_name = true
49+
# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false

railties/test/application/configuration_test.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,6 +2383,32 @@ def index
23832383
assert_equal true, ActiveRecord.verify_foreign_keys_for_fixtures
23842384
end
23852385

2386+
test "ActiveRecord.allow_deprecated_singular_associations_name is false by default for new apps" do
2387+
app "development"
2388+
2389+
assert_equal false, ActiveRecord.allow_deprecated_singular_associations_name
2390+
end
2391+
2392+
test "ActiveRecord.allow_deprecated_singular_associations_name is true by default for upgraded apps" do
2393+
remove_from_config '.*config\.load_defaults.*\n'
2394+
2395+
app "development"
2396+
2397+
assert_equal true, ActiveRecord.allow_deprecated_singular_associations_name
2398+
end
2399+
2400+
test "ActiveRecord.allow_deprecated_singular_associations_name can be configured via config.active_record.allow_deprecated_singular_associations_name" do
2401+
remove_from_config '.*config\.load_defaults.*\n'
2402+
2403+
app_file "config/initializers/new_framework_defaults_7_1.rb", <<-RUBY
2404+
Rails.application.config.active_record.allow_deprecated_singular_associations_name = false
2405+
RUBY
2406+
2407+
app "development"
2408+
2409+
assert_equal false, ActiveRecord.allow_deprecated_singular_associations_name
2410+
end
2411+
23862412
test "ActiveRecord::Base.run_commit_callbacks_on_first_saved_instances_in_transaction is false by default for new apps" do
23872413
app "development"
23882414

0 commit comments

Comments
 (0)