Skip to content
Snippets Groups Projects
Unverified Commit 00fea883 authored by Bryan Maass's avatar Bryan Maass Committed by GitHub
Browse files

handle nil last-updated times by setting :default to epoch (#21456)

* handle unset last-updated times
* magic number -> zoned-time-epoch
* test that slack cache gets filled when
slack-channels-and-usernames-last-update is nil.

- remove a comment
parent e0c3812a
No related branches found
No related tags found
No related merge requests found
......@@ -42,11 +42,14 @@
:visibility :internal
:type :json)
(def ^:private zoned-time-epoch (t/zoned-date-time 1970 1 1 0))
(defsetting slack-channels-and-usernames-last-updated
"The updated-at time for the [[slack-cached-channels-and-usernames]] setting."
:visibility :internal
:cache? false
:type :timestamp)
:type :timestamp
:default zoned-time-epoch)
(defsetting slack-files-channel
(deferred-tru "The name of the channel to which Metabase files should be initially uploaded")
......
......@@ -33,7 +33,8 @@
(is (= [] (slack/slack-cached-channels-and-usernames)))))))
(testing "The Slack files channel setting can be set by an admin, and the leading # is stripped if it is present"
(mt/with-temporary-setting-values [slack-files-channel nil]
(mt/with-temporary-setting-values [slack-files-channel nil
slack-channels-and-usernames-last-updated nil]
(with-redefs [slack/channel-exists? (constantly true)]
(mt/user-http-request :crowberto :put 200 "slack/settings" {:slack-files-channel "fake-channel"})
(is (= "fake-channel" (slack/slack-files-channel)))
......
......@@ -236,3 +236,7 @@
(is (= false (slack/valid-token? "abc")))
(is (= {} (mt/summarize-multipart-email #"Your Slack connection stopped working.")))
(is (slack/slack-token-valid?)))))))))
(deftest slack-cache-updated-at-nil
(tu/with-temporary-setting-values [slack-channels-and-usernames-last-updated nil]
(is (= (var-get #'slack/zoned-time-epoch) (slack/slack-channels-and-usernames-last-updated)))))
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