Skip to content

Commit

Permalink
Update tests, move updating candidate on detection submission to its …
Browse files Browse the repository at this point in the history
…own action
  • Loading branch information
skanderm committed Jul 2, 2024
1 parent fb4b929 commit 480aab1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
13 changes: 12 additions & 1 deletion server/lib/orcasite/radio/detection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ defmodule Orcasite.Radio.Detection do
authorize_if always()
end

bypass action(:update_candidate) do
authorize_if always()
end

policy changing_attributes([:visible]) do
authorize_if actor_attribute_equals(:moderator, true)
end
Expand Down Expand Up @@ -131,6 +135,13 @@ defmodule Orcasite.Radio.Detection do
change manage_relationship(:candidate, type: :append)
end

update :update_candidate do
argument :candidate, :map
require_atomic? false

change manage_relationship(:candidate, type: :append)
end

update :set_visible do
accept [:visible]
require_atomic? false
Expand Down Expand Up @@ -254,7 +265,7 @@ defmodule Orcasite.Radio.Detection do
end

detection
|> Ash.Changeset.for_update(:update, %{candidate: candidate})
|> Ash.Changeset.for_update(:update_candidate, %{candidate: candidate})
|> Ash.update()
end)
|> Ash.Changeset.after_action(fn changeset, detection ->
Expand Down
2 changes: 1 addition & 1 deletion server/lib/orcasite/radio/workers/link_feed_stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Orcasite.Radio.Workers.LinkFeedStream do
]

@impl Oban.Worker
def perform(%Oban.Job{args: %{"feed_stream_id" => nil} = args}) do
def perform(%Oban.Job{args: %{"feed_stream_id" => nil}}) do
:ok
end

Expand Down
2 changes: 1 addition & 1 deletion server/test/orcasite_web/graphql/moderator_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule OrcasiteWeb.ModeratorTest do
slug: "orcasound-lab"
}
)
|> Ash.create!()
|> Ash.create!(authorize?: false)

detection =
Orcasite.Radio.Detection.submit_detection(%{
Expand Down
2 changes: 1 addition & 1 deletion server/test/orcasite_web/graphql/radio_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule OrcasiteWeb.RadioTest do
slug: "orcasound-lab"
}
)
|> Ash.create!()
|> Ash.create!(authorize?: false)

[feed: feed]
end
Expand Down

0 comments on commit 480aab1

Please sign in to comment.