Skip to content
Snippets Groups Projects
Unverified Commit 0ea86ea6 authored by adam-james's avatar adam-james Committed by GitHub
Browse files

Dashboard width revision message should handle nil (#39710)

* Revision Diff Should handle `nil` Dashboard Width

Even though there shouldn't be `nil` values in dashboard.width, because the migration populates w/ the default value
of `full`, it is still true that because of the version before the migration, revisions  can have `nil` for the width
value. The diff string impl didn't consider this, causing an NPE with `(name nil)`.

* Use :guard to prevent nil values from matching

* Add test checking that dashboard width change is described correctly
parent 8a4e14cd
No related branches found
No related tags found
No related merge requests found
......@@ -89,8 +89,10 @@
[:result_metadata _ _]
(deferred-tru "edited the metadata")
[:width _ _]
(deferred-tru "changed the width setting from {0} to {1}" (name v1) (name v2))
[:width v1 v2]
(if (and v1 v2)
(deferred-tru "changed the width setting from {0} to {1}" (name v1) (name v2))
(deferred-tru "changed the width setting"))
;; whenever database_id, query_type, table_id changed,
;; the dataset_query will changed so we don't need a description for this
......
......@@ -310,6 +310,28 @@
(map #(select-keys % [:description :has_multiple_changes])
(mt/user-http-request :crowberto :get 200 "revision" :entity "dashboard" :id dashboard-id)))))))
(deftest dashboard-width-revision-diff-test
(testing "The Dashboard's revision history correctly reports dashboard width changes (#38910)"
(t2.with-temp/with-temp
[Dashboard {dashboard-id :id :as dash} {:name "A dashboard"}
Revision _ {:model "Dashboard"
:model_id dashboard-id
:user_id (mt/user->id :crowberto)
:object (assoc dash :width nil)}
Revision _ {:model "Dashboard"
:model_id dashboard-id
:user_id (mt/user->id :crowberto)
:object (assoc dash :width "full")}
Revision _ {:model "Dashboard"
:model_id dashboard-id
:user_id (mt/user->id :crowberto)
:object (assoc dash :width "fixed")}]
(is (= ["changed the width setting from full to fixed."
"changed the width setting."
"modified this."]
(map :description
(mt/user-http-request :crowberto :get 200 "revision" :entity "dashboard" :id dashboard-id)))))))
(deftest card-revision-description-test
(testing "revision description for card are generated correctly"
(t2.with-temp/with-temp
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment