@@ -469,6 +469,18 @@ def test_clear_#{inflection_type}
469
469
RUBY
470
470
end
471
471
472
+ def test_clear_acronyms_resets_to_reusable_state
473
+ ActiveSupport ::Inflector . inflections . clear ( :acronyms )
474
+
475
+ assert_empty ActiveSupport ::Inflector . inflections . acronyms
476
+
477
+ ActiveSupport ::Inflector . inflections do |inflect |
478
+ inflect . acronym "HTML"
479
+ end
480
+
481
+ assert_equal "HTML" , "html" . titleize
482
+ end
483
+
472
484
def test_inflector_locality
473
485
ActiveSupport ::Inflector . inflections ( :es ) do |inflect |
474
486
inflect . plural ( /$/ , "s" )
@@ -512,13 +524,15 @@ def test_clear_all
512
524
inflect . singular ( /(database)s$/i , '\1' )
513
525
inflect . uncountable ( "series" )
514
526
inflect . human ( "col_rpted_bugs" , "Reported bugs" )
527
+ inflect . acronym ( "HTML" )
515
528
516
529
inflect . clear :all
517
530
518
531
assert_empty inflect . plurals
519
532
assert_empty inflect . singulars
520
533
assert_empty inflect . uncountables
521
534
assert_empty inflect . humans
535
+ assert_empty inflect . acronyms
522
536
end
523
537
end
524
538
@@ -529,13 +543,30 @@ def test_clear_with_default
529
543
inflect . singular ( /(database)s$/i , '\1' )
530
544
inflect . uncountable ( "series" )
531
545
inflect . human ( "col_rpted_bugs" , "Reported bugs" )
546
+ inflect . acronym ( "HTML" )
532
547
533
548
inflect . clear
534
549
535
550
assert_empty inflect . plurals
536
551
assert_empty inflect . singulars
537
552
assert_empty inflect . uncountables
538
553
assert_empty inflect . humans
554
+ assert_empty inflect . acronyms
555
+ end
556
+ end
557
+
558
+ def test_clear_all_resets_camelize_and_underscore_regexes
559
+ ActiveSupport ::Inflector . inflections do |inflect |
560
+ # ensure any data is present
561
+ inflect . acronym ( "HTTP" )
562
+ assert_equal "http_s" , "HTTPS" . underscore
563
+ assert_equal "Https" , "https" . camelize
564
+
565
+ inflect . clear :all
566
+
567
+ assert_empty inflect . acronyms
568
+ assert_equal "https" , "HTTPS" . underscore
569
+ assert_equal "Https" , "https" . camelize
539
570
end
540
571
end
541
572
@@ -592,7 +623,7 @@ def test_clear_with_default
592
623
end
593
624
end
594
625
595
- %w ( plurals singulars uncountables humans acronyms ) . each do |scope |
626
+ %i ( plurals singulars uncountables humans ) . each do |scope |
596
627
define_method ( "test_clear_inflections_with_#{ scope } " ) do
597
628
# clear the inflections
598
629
ActiveSupport ::Inflector . inflections do |inflect |
@@ -601,4 +632,11 @@ def test_clear_with_default
601
632
end
602
633
end
603
634
end
635
+
636
+ def test_clear_inflections_with_acronyms
637
+ ActiveSupport ::Inflector . inflections do |inflect |
638
+ inflect . clear ( :acronyms )
639
+ assert_equal ( { } , inflect . acronyms )
640
+ end
641
+ end
604
642
end
0 commit comments