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

update our predicate function `field-should-have-field-values?` to include a...

update our predicate function `field-should-have-field-values?` to include a check that the field is not one of our Date/DateTime/Time field types.
parent 09775d52
No related merge requests found
......@@ -33,6 +33,7 @@
(contains? field :base_type)
(contains? field :special_type)]}
(and (not= (keyword field_type) :sensitive)
(not (contains? #{:DateField :DateTimeField :TimeField} (keyword base_type)))
(or (contains? #{:category :city :state :country} (keyword special_type))
(= (keyword base_type) :BooleanField))))
......
......@@ -5,6 +5,63 @@
[field-values :refer :all])
[metabase.test.data :refer :all]))
;; field-should-have-field-values?
;; sensitive fields should always be excluded
(expect false (field-should-have-field-values? {:base_type :BooleanField
:special_type :category
:field_type :sensitive}))
;; date/time based fields should always be excluded
(expect false (field-should-have-field-values? {:base_type :DateField
:special_type :category
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :DateTimeField
:special_type :category
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :TimeField
:special_type :category
:field_type :dimension}))
;; most special types should be excluded
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :image
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :id
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :fk
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :latitude
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :number
:field_type :dimension}))
(expect false (field-should-have-field-values? {:base_type :CharField
:special_type :timestamp_milliseconds
:field_type :dimension}))
;; boolean fields + category/city/state/country fields are g2g
(expect true (field-should-have-field-values? {:base_type :BooleanField
:special_type :number
:field_type :dimension}))
(expect true (field-should-have-field-values? {:base_type :CharField
:special_type :category
:field_type :dimension}))
(expect true (field-should-have-field-values? {:base_type :TextField
:special_type :city
:field_type :dimension}))
(expect true (field-should-have-field-values? {:base_type :TextField
:special_type :state
:field_type :dimension}))
(expect true (field-should-have-field-values? {:base_type :TextField
:special_type :country
:field_type :dimension}))
;; NOT field_type = senstive
;; NOT base_type = date, datetime, time
;; (required) special_type = category, city, state, country OR base_type = boolean
;; Check that setting a Field's special_type to :category will cause a corresponding FieldValues to be created asynchronously
(expect
[nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment