@@ -469,6 +469,18 @@ def test_clear_#{inflection_type}
469469 RUBY
470470 end
471471
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+
472484 def test_inflector_locality
473485 ActiveSupport ::Inflector . inflections ( :es ) do |inflect |
474486 inflect . plural ( /$/ , "s" )
@@ -512,13 +524,15 @@ def test_clear_all
512524 inflect . singular ( /(database)s$/i , '\1' )
513525 inflect . uncountable ( "series" )
514526 inflect . human ( "col_rpted_bugs" , "Reported bugs" )
527+ inflect . acronym ( "HTML" )
515528
516529 inflect . clear :all
517530
518531 assert_empty inflect . plurals
519532 assert_empty inflect . singulars
520533 assert_empty inflect . uncountables
521534 assert_empty inflect . humans
535+ assert_empty inflect . acronyms
522536 end
523537 end
524538
@@ -529,13 +543,30 @@ def test_clear_with_default
529543 inflect . singular ( /(database)s$/i , '\1' )
530544 inflect . uncountable ( "series" )
531545 inflect . human ( "col_rpted_bugs" , "Reported bugs" )
546+ inflect . acronym ( "HTML" )
532547
533548 inflect . clear
534549
535550 assert_empty inflect . plurals
536551 assert_empty inflect . singulars
537552 assert_empty inflect . uncountables
538553 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
539570 end
540571 end
541572
@@ -592,7 +623,7 @@ def test_clear_with_default
592623 end
593624 end
594625
595- %w ( plurals singulars uncountables humans acronyms ) . each do |scope |
626+ %i ( plurals singulars uncountables humans ) . each do |scope |
596627 define_method ( "test_clear_inflections_with_#{ scope } " ) do
597628 # clear the inflections
598629 ActiveSupport ::Inflector . inflections do |inflect |
@@ -601,4 +632,11 @@ def test_clear_with_default
601632 end
602633 end
603634 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
604642end
0 commit comments