Skip to content

Commit

Permalink
Fix update_config
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed committed Feb 4, 2021
1 parent 5e8fdb9 commit 78d13d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/absinthe/plug.ex
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,12 @@ defmodule Absinthe.Plug do
end
end

defp update_config(conn, config) do
@doc false
def update_config(conn, config) do
config
|> update_config(:pubsub, conn)
|> update_config(:raw_options, conn)
|> update_config(:init_options, conn)
|> update_config(:pubsub, conn)
end

defp update_config(config, :pubsub, conn) do
Expand Down
13 changes: 13 additions & 0 deletions test/lib/absinthe/plug_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,19 @@ defmodule Absinthe.PlugTest do
assert %{"errors" => [%{"message" => "No query!!"}]} = resp_body
assert {"content-type", "text/who-knows; charset=utf-8"} in resp_headers
end

test "don't wipe out pubsub" do
config = Absinthe.Plug.init(schema: TestSchema, context: %{user_id: 1})

conn =
conn(:post, "/")
|> Absinthe.Plug.put_options(pubsub: PubSub)

updated_config = Absinthe.Plug.update_config(conn, config)

assert updated_config.context.pubsub == PubSub
assert updated_config.context.user_id == 1
end
end

describe "assign_context/2" do
Expand Down

0 comments on commit 78d13d1

Please sign in to comment.