File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ def enum(definitions)
202
202
suffix = "_#{ enum_suffix } "
203
203
end
204
204
205
- method_friendly_label = label . to_s . gsub ( /\W +/ , "_" )
205
+ method_friendly_label = label . to_s . gsub ( /[ \W &&[:ascii:]] +/ , "_" )
206
206
value_method_name = "#{ prefix } #{ method_friendly_label } #{ suffix } "
207
207
value_method_names << value_method_name
208
208
enum_values [ label ] = value
Original file line number Diff line number Diff line change @@ -646,6 +646,17 @@ def self.name; "Book"; end
646
646
assert_not_predicate computer , :extendedGold?
647
647
end
648
648
649
+ test "unicode characters for enum names" do
650
+ klass = Class . new ( ActiveRecord ::Base ) do
651
+ self . table_name = "books"
652
+ enum language : [ :🇺🇸 , :🇪🇸 , :🇫🇷 ]
653
+ end
654
+
655
+ book = klass . 🇺🇸 . build
656
+ assert_predicate book , :🇺🇸?
657
+ assert_not_predicate book , :🇪🇸?
658
+ end
659
+
649
660
test "enum logs a warning if auto-generated negative scopes would clash with other enum names" do
650
661
old_logger = ActiveRecord ::Base . logger
651
662
logger = ActiveSupport ::LogSubscriber ::TestHelper ::MockLogger . new
You can’t perform that action at this time.
0 commit comments