Skip to content

Commit 39a7834

Browse files
committed
assert mail job enqueued
1 parent f408123 commit 39a7834

File tree

8 files changed

+31
-10
lines changed

8 files changed

+31
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
You have been rewarded a bounty on Algora!
1+
🎉 <%= bounty.amount %> bounty awarded by <%= bounty.creator.display_name %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<%= bounty.creator.display_name %> awarded you a Bounty for <% bounty.amount %>
1+
Congratulations, you've been awarded a bounty by <%= bounty.creator.display_name %>!
22

33
<%= Algora.Activities.external_url(activity) %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
New bounty posted to Algora
1+
<%= bounty.amount %> bounty posted by <%= bounty.creator.display_name %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
A Bounty for <%= bounty.amount %> was added to <%= bounty.ticket.repository.name %>
1+
A new bounty has been posted by <%= bounty.creator.display_name %>
22

33
<%= Algora.Activities.external_url(activity) %>

lib/algora/activities/views/claim_approved.txt.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A claim for <%= claim.bounty.amount %> was accepted for <%= claim.bounty.ticket.repository.name %>
1+
A claim for the issue "<%= claim.target.title %>" was accepted.
22

33
<%= claim.url %>
44

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
A claim for <%= claim.bounty.ticket.repository.name %> has been submitted
1+
A claim for the issue "<%= claim.target.title %>" was submitted.
2+
3+
<%= claim.url %>
24

35
<%= Algora.Activities.external_url(activity) %>

lib/algora/bounties/schemas/bounty.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ defmodule Algora.Bounties.Bounty do
2020
timestamps()
2121
end
2222

23+
def preload(id) do
24+
from a in __MODULE__,
25+
preload: [:ticket, :owner, :creator],
26+
where: a.id == ^id
27+
end
28+
2329
def changeset(bounty, attrs) do
2430
bounty
2531
|> cast(attrs, [:amount, :ticket_id, :owner_id, :creator_id])

test/algora/bounties_test.exs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ defmodule Algora.BountiesTest do
55
import Algora.Factory
66
import Money.Sigil
77

8+
alias Algora.Activities.Notifier
9+
alias Algora.Activities.SendEmail
10+
alias Algora.Activities.Views
11+
812
def setup_github_mocks(_context) do
913
import Algora.Mocks.GithubMock
1014

@@ -96,12 +100,21 @@ defmodule Algora.BountiesTest do
96100
assert_activity_names_for_user(creator.id, [:bounty_posted, :bounty_awarded, :tip_awarded])
97101
assert_activity_names_for_user(recipient.id, [:claim_submitted, :tip_awarded])
98102

99-
assert [_bounty, _claim, _awarded, activity] = Enum.reverse(Algora.Activities.all())
100-
assert "tip_activities" == activity.assoc_name
101-
assert activity.notify_users == [recipient.id]
102-
assert activity = Algora.Activities.get_with_preloaded_assoc(activity.assoc_name, activity.id)
103+
assert [bounty, claim, awarded, tip] = Enum.reverse(Algora.Activities.all())
104+
assert "tip_activities" == tip.assoc_name
105+
assert tip.notify_users == [recipient.id]
106+
assert activity = Algora.Activities.get_with_preloaded_assoc(tip.assoc_name, tip.id)
103107
assert activity.assoc.__meta__.schema == Algora.Bounties.Tip
104108
assert activity.assoc.creator.id == creator.id
109+
110+
assert_enqueued(worker: Notifier, args: %{"activity_id" => bounty.id})
111+
refute_enqueued(worker: SendEmail, args: %{"activity_id" => bounty.id})
112+
113+
Enum.map(all_enqueued(worker: Notifier), fn job ->
114+
perform_job(Notifier, job.args)
115+
end)
116+
117+
assert_enqueued(worker: SendEmail, args: %{"activity_id" => bounty.id})
105118
end
106119

107120
test "query" do

0 commit comments

Comments
 (0)