Skip to content

Commit b2d88cf

Browse files
Fix failing texts
1 parent a1c8ad6 commit b2d88cf

File tree

10 files changed

+22
-23
lines changed

10 files changed

+22
-23
lines changed

notifications/lib/notifications/api/internal_api.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ defmodule Notifications.Api.InternalApi do
77
use Sentry.Grpc, service: Api.NotificationsApi.Service
88

99
def list(req, _call) do
10-
IO.puts("LIST INTERNAL")
11-
IO.inspect(req)
1210
Notifications.Api.InternalApi.List.run(req)
1311
end
1412

notifications/lib/notifications/api/internal_api/create.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ defmodule Notifications.Api.InternalApi.Create do
99

1010
def run(req) do
1111
org_id = req.metadata.org_id
12+
creator_id = req.metadata.user_id
1213

1314
with {:ok, :valid} <- Validator.validate(req.notification),
14-
{:ok, n} <- create_notification(org_id, req.notification) do
15+
{:ok, n} <- create_notification(org_id, creator_id, req.notification) do
1516
%CreateResponse{notification: Serialization.serialize(n)}
1617
else
1718
{:error, :invalid_argument, message} ->
@@ -27,13 +28,13 @@ defmodule Notifications.Api.InternalApi.Create do
2728
end
2829
end
2930

30-
defp create_notification(org_id, notification) do
31+
defp create_notification(org_id, creator_id, notification) do
3132
Repo.transaction(fn ->
3233
n =
3334
Models.Notification.new(
3435
org_id,
3536
notification.name,
36-
notification.creator_id,
37+
creator_id,
3738
Notifications.Util.Transforms.encode_spec(%{rules: notification.rules})
3839
)
3940

notifications/lib/notifications/api/public_api.ex

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ defmodule Notifications.Api.PublicApi do
1919
end
2020

2121
def create_notification(notification, call) do
22-
IO.puts("CREATE NOTIFICATIONS PUBLIC")
23-
IO.inspect(notification)
2422
{org_id, user_id} = extract_headers(call)
25-
IO.inspect(org_id)
26-
IO.inspect(user_id)
2723

2824
Notifications.Api.PublicApi.Create.run(notification, org_id, user_id)
2925
end

notifications/lib/notifications/api/public_api/create.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ defmodule Notifications.Api.PublicApi.Create do
77
alias Notifications.Util.Validator
88

99
def run(notification, org_id, user_id) do
10-
IO.puts("Create Run public")
11-
IO.inspect(notification)
1210
name = notification.metadata.name
1311

1412
Logger.info("#{inspect(org_id)} #{inspect(user_id)} #{name}")

notifications/test/notifications/api/internal_api/create_test.exs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule Notifications.Api.InternalApi.CreateTest do
44
alias InternalApi.Notifications.RequestMeta
55

66
@org_id Ecto.UUID.generate()
7+
@creator_id Ecto.UUID.generate()
78

89
describe ".run" do
910
test "it creates DB resources" do
@@ -13,7 +14,7 @@ defmodule Notifications.Api.InternalApi.CreateTest do
1314
{:ok, channel} = GRPC.Stub.connect("localhost:50051")
1415

1516
req = %CreateRequest{
16-
metadata: %RequestMeta{org_id: @org_id},
17+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
1718
notification: Support.Factories.Notification.internal_api_model("first-notification")
1819
}
1920

@@ -103,7 +104,7 @@ defmodule Notifications.Api.InternalApi.CreateTest do
103104
{:ok, channel} = GRPC.Stub.connect("localhost:50051")
104105

105106
req = %CreateRequest{
106-
metadata: %RequestMeta{org_id: @org_id},
107+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
107108
notification: Support.Factories.Notification.internal_api_model("first-notification")
108109
}
109110

@@ -150,7 +151,7 @@ defmodule Notifications.Api.InternalApi.CreateTest do
150151
)
151152

152153
req = %CreateRequest{
153-
metadata: %RequestMeta{org_id: @org_id},
154+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
154155
notification: notification
155156
}
156157

@@ -167,7 +168,7 @@ defmodule Notifications.Api.InternalApi.CreateTest do
167168
{:ok, channel} = GRPC.Stub.connect("localhost:50051")
168169

169170
req = %CreateRequest{
170-
metadata: %RequestMeta{org_id: @org_id},
171+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
171172
notification: Support.Factories.Notification.internal_api_model("first-notification")
172173
}
173174

notifications/test/notifications/api/internal_api/describe_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule Notifications.Api.InternalApi.DescribeTest do
22
use Notifications.DataCase
33

44
@org_id Ecto.UUID.generate()
5+
@creator_id Ecto.UUID.generate()
56

67
alias InternalApi.Notifications.NotificationsApi.Stub
78
alias InternalApi.Notifications.DescribeRequest
@@ -29,7 +30,7 @@ defmodule Notifications.Api.InternalApi.DescribeTest do
2930
{:ok, channel} = GRPC.Stub.connect("localhost:50051")
3031

3132
req1 = %CreateRequest{
32-
metadata: %RequestMeta{org_id: @org_id},
33+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
3334
notification: Support.Factories.Notification.internal_api_model("first")
3435
}
3536

notifications/test/notifications/api/internal_api/destroy_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ defmodule Notifications.Api.InternalApi.DestroyTest do
77
alias InternalApi.Notifications.RequestMeta
88

99
@org_id Ecto.UUID.generate()
10+
@creator_id Ecto.UUID.generate()
1011

1112
alias Notifications.Models
1213

@@ -30,7 +31,7 @@ defmodule Notifications.Api.InternalApi.DestroyTest do
3031

3132
{:ok, _} =
3233
Stub.create(channel, %CreateRequest{
33-
metadata: %RequestMeta{org_id: @org_id},
34+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
3435
notification: req
3536
})
3637

notifications/test/notifications/api/internal_api/list_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule Notifications.Api.InternalApi.ListTest do
22
use Notifications.DataCase
33

44
@org_id Ecto.UUID.generate()
5+
@creator_id Ecto.UUID.generate()
56

67
describe ".run" do
78
test "it gets the resources" do
@@ -14,7 +15,7 @@ defmodule Notifications.Api.InternalApi.ListTest do
1415

1516
Enum.each(1..5, fn index ->
1617
req = %CreateRequest{
17-
metadata: %RequestMeta{org_id: @org_id},
18+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
1819
notification: Support.Factories.Notification.internal_api_model("first-#{index}")
1920
}
2021

notifications/test/notifications/api/internal_api/update_test.exs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
22
use Notifications.DataCase
33

44
@org_id Ecto.UUID.generate()
5+
@creator_id Ecto.UUID.generate()
56

67
alias InternalApi.Notifications.NotificationsApi.Stub
78
alias InternalApi.Notifications.UpdateRequest
@@ -35,7 +36,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
3536

3637
{:ok, _} =
3738
Stub.create(channel, %CreateRequest{
38-
metadata: %RequestMeta{org_id: @org_id},
39+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
3940
notification: notification
4041
})
4142

@@ -134,7 +135,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
134135

135136
{:ok, _} =
136137
Stub.create(channel, %CreateRequest{
137-
metadata: %RequestMeta{org_id: @org_id},
138+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
138139
notification: notification
139140
})
140141

@@ -161,7 +162,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
161162

162163
{:ok, _} =
163164
Stub.create(channel, %CreateRequest{
164-
metadata: %RequestMeta{org_id: @org_id},
165+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
165166
notification: notification
166167
})
167168

@@ -216,7 +217,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
216217
Stub.create(
217218
channel,
218219
%CreateRequest{
219-
metadata: %RequestMeta{org_id: @org_id},
220+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
220221
notification: Support.Factories.Notification.internal_api_model("first-notification")
221222
}
222223
)
@@ -225,7 +226,7 @@ defmodule Notifications.Api.InternalApi.UpdateTest do
225226
Stub.create(
226227
channel,
227228
%CreateRequest{
228-
metadata: %RequestMeta{org_id: @org_id},
229+
metadata: %RequestMeta{org_id: @org_id, user_id: @creator_id},
229230
notification: Support.Factories.Notification.internal_api_model("second-notification")
230231
}
231232
)

notifications/test/notifications/api/public_api/create_test.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ defmodule Notifications.Api.PublicApi.CreateTest do
4040
n = Repo.preload(n, :rules)
4141

4242
assert n.name == "first-notification"
43+
assert n.creator_id == @user_id
4344
assert length(n.rules) == 1
4445

4546
rule = hd(n.rules)

0 commit comments

Comments
 (0)