Skip to content

Commit

Permalink
last test fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Apr 25, 2024
1 parent cbeecf8 commit 6204ee0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
7 changes: 5 additions & 2 deletions lib/radiator/outline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ defmodule Radiator.Outline do
"""
def update_node_content(node_id, content) do
case NodeRepository.get_node(node_id) do
nil -> {:error, :not_found}
node -> node
nil ->
{:error, :not_found}

node ->
node
|> Node.update_content_changeset(%{content: content})
|> Repo.update()
end
Expand Down
1 change: 0 additions & 1 deletion lib/radiator/outline/event/node_content_changed_event.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule Radiator.Outline.Event.NodeContentChangedEvent do
@moduledoc false


defstruct [:event_id, :node]
end
1 change: 1 addition & 0 deletions test/radiator/outline/node_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule Radiator.Outline.NodeTest do
episode = PodcastFixtures.episode_fixture()

uuid = Ecto.UUID.generate()

attributes = %{
"uuid" => uuid,
"episode_id" => episode.id,
Expand Down
17 changes: 7 additions & 10 deletions test/radiator_web/live/episode_live_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,16 @@ defmodule RadiatorWeb.EpisodeLiveTest do

node = node_fixture(%{episode_id: episode.id})

params =
node
|> Map.from_struct()
|> Map.put(:content, "update node content")
update_attrs = %{
content: "update node content",
event_id: Ecto.UUID.generate()
}

params = node |> Map.from_struct() |> Map.merge(update_attrs)
assert live |> render_hook(:update_node, params)

updated_node =
NodeRepository.list_nodes()
|> Enum.find(&(&1.content == "update node content"))

assert updated_node.uuid == params.uuid
assert updated_node.content == params.content
updated_node = NodeRepository.get_node!(node.uuid)
assert updated_node.content == update_attrs.content
end

test "delete node", %{conn: conn, show: show, episode: episode} do
Expand Down

0 comments on commit 6204ee0

Please sign in to comment.