FIX: Make `getCategoryIdByName` theme migration helper case insensitive (#26878)
This commit is contained in:
parent
e607dd3767
commit
b6f6852bba
|
@ -13,7 +13,7 @@ class ThemeSettingsMigrationsRunner
|
|||
# @return [Integer|nil] The id of the category with the given name or nil if a category does not exist for the given
|
||||
# name.
|
||||
def get_category_id_by_name(category_name)
|
||||
Category.where(name_lower: category_name).pick(:id)
|
||||
Category.where("name_lower = LOWER(?)", category_name).pick(:id)
|
||||
end
|
||||
|
||||
# @param [String] URL string to check if it is a valid absolute URL, path or anchor.
|
||||
|
|
|
@ -356,14 +356,14 @@ describe ThemeSettingsMigrationsRunner do
|
|||
end
|
||||
|
||||
it "attaches the getCategoryIdByName() function to the context of the migrations" do
|
||||
category = Fabricate(:category, name: "some-category")
|
||||
category = Fabricate(:category, name: "Some Category Name")
|
||||
|
||||
theme.update_setting(:integer_setting, -10)
|
||||
theme.save!
|
||||
|
||||
migration_field.update!(value: <<~JS)
|
||||
export default function migrate(settings, helpers) {
|
||||
const categoryId = helpers.getCategoryIdByName("some-category");
|
||||
const categoryId = helpers.getCategoryIdByName("some CatEgory Name");
|
||||
settings.set("integer_setting", categoryId);
|
||||
return settings;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue