Skip to content
Snippets Groups Projects
Commit 545ec1a3 authored by Allen Gilliland's avatar Allen Gilliland
Browse files

fixes #735 null pointer issue.

parent 942b2a19
Branches
Tags
No related merge requests found
......@@ -31,9 +31,10 @@
(name->human-readable-name \"admin_users\") -> \"Admin Users\""
[^String n]
(when (seq n)
(when-let [n (some-> n
(s/replace #"(?:-|_id)$" "") ; strip off any trailing _id or -id suffix
(s/split #"_|-"))] ; explode string on underscores and hyphens
(when-let [n (->> (some-> n
(s/replace #"(?:-|_id)$" "") ; strip off any trailing _id or -id suffix
(s/split #"_|-"))
(filterv not-empty)) ] ; explode string on underscores and hyphens
(->> (for [[first-letter & rest-letters] n] ; for each part of the string,
(apply str (s/upper-case first-letter) (map s/lower-case rest-letters))) ; upcase the first char and downcase the rest
(interpose " ") ; add a space between each part
......
(ns metabase.models.common-test
(:require [expectations :refer :all]
[metabase.db :refer :all]
[metabase.models.common :refer [name->human-readable-name]]
[metabase.test.data :refer :all]))
;; testing on `(name->human-readable-name)`
(expect nil (name->human-readable-name nil))
(expect nil (name->human-readable-name ""))
(expect "" (name->human-readable-name "_"))
(expect "" (name->human-readable-name "-"))
(expect "Agent Invite Migration" (name->human-readable-name "_agent_invite_migration"))
(expect "Agent Invite Migration" (name->human-readable-name "-agent-invite-migration"))
(expect "Foobar" (name->human-readable-name "fooBar"))
(expect "Foo Bar" (name->human-readable-name "foo-bar"))
(expect "Foo Bar" (name->human-readable-name "foo_bar"))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment