Skip to content
Snippets Groups Projects
Commit 19092683 authored by Cam Saül's avatar Cam Saül
Browse files

Tests for unsetting Card/Dashboard description

parent f003927e
No related branches found
No related tags found
No related merge requests found
......@@ -259,12 +259,17 @@
(check-superuser))
;; ok, now save the Card
(db/update! Card id
(merge (when (contains? body :collection_id)
{:collection_id collection_id})
(into {} (for [k [:dataset_query :description :display :name :visualization_settings :archived :enable_embedding :embedding_params]
:let [v (k body)]
:when (not (nil? v))]
{k v}))))
(merge
;; `collection_id` and `description` can be `nil` (in order to unset them)
(when (contains? body :collection_id)
{:collection_id collection_id})
(when (contains? body :description)
{:description description})
;; other values should only be modified if they're passed in as non-nil
(into {} (for [k [:dataset_query :display :name :visualization_settings :archived :enable_embedding :embedding_params]
:let [v (k body)]
:when (not (nil? v))]
{k v}))))
(let [event (cond
;; card was archived
(and archived
......
......@@ -88,23 +88,24 @@
:creator_id user-id)
(events/publish-event! :dashboard-create)))
(defn update-dashboard!
"Update a `Dashboard`"
[{:keys [id name description parameters caveats points_of_interest show_in_getting_started enable_embedding embedding_params], :as dashboard} user-id]
[dashboard user-id]
{:pre [(map? dashboard)
(integer? id)
(u/maybe? u/sequence-of-maps? parameters)
(u/maybe? u/sequence-of-maps? (:parameters dashboard))
(integer? user-id)]}
(db/update-non-nil-keys! Dashboard id
:description description
:name name
:parameters parameters
:caveats caveats
:points_of_interest points_of_interest
:enable_embedding enable_embedding
:embedding_params embedding_params
:show_in_getting_started show_in_getting_started)
(u/prog1 (Dashboard id)
(db/update! Dashboard (u/get-id dashboard)
(merge
;; description is allowed to be `nil`
(when (contains? dashboard :description)
{:description (:description dashboard)})
;; only set everything else if its non-nil
(into {} (for [k [:name :parameters :caveats :points_of_interest :show_in_getting_started :enable_embedding :embedding_params]
:when (k dashboard)]
{k (k dashboard)}))))
(u/prog1 (Dashboard (u/get-id dashboard))
(events/publish-event! :dashboard-update (assoc <> :actor_id user-id))))
......
......@@ -247,6 +247,13 @@
(set-archived! true)
(set-archived! false)])))
;; Can we clear the description of a Card? (#4738)
(expect
nil
(with-temp-card [card {:description "What a nice Card"}]
((user->client :rasta) :put 200 (str "card/" (u/get-id card)) {:description nil})
(db/select-one-field :description Card :id (u/get-id card))))
;; Can we update a card's embedding_params?
(expect
{:abc "enabled"}
......
......@@ -159,6 +159,13 @@
:creator_id (user->id :trashbird)})
(Dashboard dashboard-id)])))
;; Can we clear the description of a Dashboard? (#4738)
(expect
nil
(tt/with-temp Dashboard [dashboard {:description "What a nice Dashboard"}]
((user->client :rasta) :put 200 (str "dashboard/" (u/get-id dashboard)) {:description nil})
(db/select-one-field :description Dashboard :id (u/get-id dashboard))))
;; ## DELETE /api/dashboard/:id
(expect
......
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