Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
2172bc2b
Unverified
Commit
2172bc2b
authored
6 years ago
by
Sameer Al-Sakran
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8244 from metabase/pulse-send-fails-on-revisit
Update `/pulse/test` to accept HybridCards
parents
397c4748
c74c27d5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/metabase/api/pulse.clj
+7
-5
7 additions, 5 deletions
src/metabase/api/pulse.clj
test/metabase/api/pulse_test.clj
+35
-0
35 additions, 0 deletions
test/metabase/api/pulse_test.clj
with
42 additions
and
5 deletions
src/metabase/api/pulse.clj
+
7
−
5
View file @
2172bc2b
...
...
@@ -180,11 +180,13 @@
(
api/defendpoint
POST
"/test"
"Test send an unsaved pulse."
[
:as
{{
:keys
[
name
cards
channels
skip_if_empty
]
:as
body
}
:body
}]
{
name
su/NonBlankString
cards
(
su/non-empty
[
pulse/CardRef
])
channels
(
su/non-empty
[
su/Map
])
skip_if_empty
s/Bool
}
[
:as
{{
:keys
[
name
cards
channels
skip_if_empty
collection_id
collection_position
]
:as
body
}
:body
}]
{
name
su/NonBlankString
cards
(
su/non-empty
[
pulse/CoercibleToCardRef
])
channels
(
su/non-empty
[
su/Map
])
skip_if_empty
(
s/maybe
s/Bool
)
collection_id
(
s/maybe
su/IntGreaterThanZero
)
collection_position
(
s/maybe
su/IntGreaterThanZero
)}
(
check-card-read-permissions
cards
)
(
p/send-pulse!
body
)
{
:ok
true
})
...
...
This diff is collapsed.
Click to expand it.
test/metabase/api/pulse_test.clj
+
35
−
0
View file @
2172bc2b
...
...
@@ -882,3 +882,38 @@
:emails
(
et/regex-email-bodies
#
"Daily Sad Toucans"
)))))))))
;; This test follows a flow that the user/UI would follow by first creating a pulse, then making a small change to
;; that pulse and testing it. The primary purpose of this test is to ensure tha the pulse/test endpoint accepts data
;; of the same format that the pulse GET returns
(
tt/expect-with-temp
[
Card
[
card-1
]
Card
[
card-2
]]
{
:response
{
:ok
true
}
:emails
(
et/email-to
:rasta
{
:subject
"Pulse: A Pulse"
:body
{
"A Pulse"
true
}})}
(
card-api-test/with-cards-in-readable-collection
[
card-1
card-2
]
(
et/with-fake-inbox
(
tu/with-model-cleanup
[
Pulse
]
(
tt/with-temp
Collection
[
collection
]
(
perms/grant-collection-readwrite-permissions!
(
perms-group/all-users
)
collection
)
;; First create the pulse
(
let
[{
pulse-id
:id
}
((
user->client
:rasta
)
:post
200
"pulse"
{
:name
"A Pulse"
:collection_id
(
u/get-id
collection
)
:skip_if_empty
false
:cards
[{
:id
(
u/get-id
card-1
)
:include_csv
false
:include_xls
false
}
{
:id
(
u/get-id
card-2
)
:include_csv
false
:include_xls
false
}]
:channels
[(
assoc
daily-email-channel
:recipients
[(
fetch-user
:rasta
)
(
fetch-user
:crowberto
)])]})
;; Retrieve the pulse via GET
result
((
user->client
:rasta
)
:get
200
(
str
"pulse/"
pulse-id
))
;; Change our fetched copy of the pulse to only have Rasta for the recipients
email-channel
(
assoc
(
->
result
:channels
first
)
:recipients
[(
fetch-user
:rasta
)])]
;; Don't update the pulse, but test the pulse with the updated recipients
{
:response
((
user->client
:rasta
)
:post
200
"pulse/test"
(
assoc
result
:channels
[
email-channel
]))
:emails
(
et/regex-email-bodies
#
"A Pulse"
)}))))))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment