diff --git a/src/metabase/api/card.clj b/src/metabase/api/card.clj index 07455a4eb17c9002a1c57785fce90fb6c9494846..eecfa46ee6eed36c12762ed7a005dd13d62b4315 100644 --- a/src/metabase/api/card.clj +++ b/src/metabase/api/card.clj @@ -429,9 +429,9 @@ ;; `collection_id` and `description` can be `nil` (in order to unset them). Other values should only be ;; modified if they're passed in as non-nil (u/select-keys-when card-updates - :present #{:collection_id :collection_position :description} + :present #{:collection_id :collection_position :description :cache_ttl} :non-nil #{:dataset_query :display :name :visualization_settings :archived :enable_embedding - :embedding_params :result_metadata :cache_ttl}))) + :embedding_params :result_metadata}))) ;; Fetch the updated Card from the DB (let [card (Card id)] (delete-alerts-if-needed! card-before-update card) diff --git a/src/metabase/api/dashboard.clj b/src/metabase/api/dashboard.clj index 682269a100164ff51513dbf4ba1cf74f900cbcfd..dacd0fc1db3ca75b5cdae4f3a7d5bbc55613f1cd 100644 --- a/src/metabase/api/dashboard.clj +++ b/src/metabase/api/dashboard.clj @@ -301,9 +301,9 @@ ;; description, position, collection_id, and collection_position are allowed to be `nil`. ;; Everything else must be non-nil (u/select-keys-when dash-updates - :present #{:description :position :collection_id :collection_position} + :present #{:description :position :collection_id :collection_position :cache_ttl} :non-nil #{:name :parameters :caveats :points_of_interest :show_in_getting_started :enable_embedding - :embedding_params :archived :cache_ttl}))))) + :embedding_params :archived}))))) ;; now publish an event and return the updated Dashboard (let [dashboard (Dashboard id)] (events/publish-event! :dashboard-update (assoc dashboard :actor_id api/*current-user-id*)) diff --git a/test/metabase/api/card_test.clj b/test/metabase/api/card_test.clj index c1aa7108a5e3ad811733b3d5e3363bd83d4042d5..4f89416614ea7d6861123562b5a7c3fa8c1af136 100644 --- a/test/metabase/api/card_test.clj +++ b/test/metabase/api/card_test.clj @@ -409,8 +409,15 @@ :put 202 (str "card/" (u/the-id card)) - {:cache_ttl 1234})))))))) - + {:cache_ttl 1234})))))) + (testing "nilling out cache ttl works" + (mt/with-temp Card [card] + (is (= nil + (do + (mt/user-http-request :rasta :put 202 (str "card/" (u/the-id card)) {:cache_ttl 1234}) + (mt/user-http-request :rasta :put 202 (str "card/" (u/the-id card)) {:cache_ttl nil}) + (:cache_ttl (mt/user-http-request :rasta :get 200 (str "card/" (u/the-id card)))) + ))))))) (defn- fingerprint-integers->doubles "Converts the min/max fingerprint values to doubles so simulate how the FE will change the metadata when POSTing a