 
  		        scottswezey
Testing Elixir: logic error in code sample: with_authenticated_user/1 (Page 25)
The with_authenticated_user/1 code sample on PDF page 25 in B2.0 returns the user object, and not the authenticated_user object as I expect it should. Leaving the code as-is would probably be considered a logic error in a real application, and may be confusing to some readers of the book.
Current code:
def with_authenticated_user(context) do
    user = User.create(%{name: "Bob Robertson"})
    authenticated_user = TestHelper.authenticate(user)
    Map.put(context, :authenticated_user, user) # Error here
end
Fixed code:
def with_authenticated_user(context) do
    user = User.create(%{name: "Bob Robertson"})
    authenticated_user = TestHelper.authenticate(user)
    Map.put(context, :authenticated_user, authenticated_user) # Fixed
end
Marked As Solved
 
		        idlehands
@scottswezey As we are prepping for production, I finally made this fix. Thanks again for catching it. It was a great call out. Alas, the sample code probably won’t be updated until the book is finalized.
Also Liked
 
		        scottswezey
This error is still present in B3.0.
 
		        idlehands
Thanks! I’m sorry we missed this in the last release. The errata system currently leaves a bit to be desired. We will make sure the code is updated for the next beta.
 
		        idlehands
I lied. But it will be updated by the time we roll out the final. Sorry… been a bit overwhelmed.
Popular Pragmatic Bookshelf topics
                         
                      
                       
           
           
           
           
           
           
           
           
           
          Other popular topics
                         
                      
                       
           
           
           
           
           
           
           
           
           
          Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /rails
- /js
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /emacs
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /zig
- /deepseek
- /scala
- /lisp
- /textmate
- /sublime-text
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /django
- /revery
- /deno
- /ubuntu
- /spring
- /nodejs
- /manjaro
- /diversity
- /lua
- /julia
- /slackware
- /c
 
    





