Skip to content

Phoenix.ConnTest.get/3 should pass params as string values to controller #3605

@nathanl

Description

@nathanl

Environment

  • Elixir version (elixir -v): 1.9.0
  • Phoenix version (mix deps): 1.4.10
  • NodeJS version (node -v): v12.1.0
  • NPM version (npm -v): 6.9.0
  • Operating system: MacOS Mojave

Expected behavior

Phoenix.ConnTest.get("/foo", %{count: 5}) should result in the controller receiving the count param as a string value, reflecting the behavior of curl http://localhost:4000/foo?count=5.

Actual behavior

Phoenix.ConnTest.get("/foo", %{count: 5}) results in the controller receiving the count param as an integer value. It does not appear to be possible for a real HTTP GET to do this.

Impact

Controller code can be written which treats a param as an integer, and even though this will fail in real usage, the tests make it appear to work. When the bug in the application code is discovered and fixed, all tests have to be updated to explicitly pass the param as a string, like Phoenix.ConnTest.get("/foo", %{count: "5"})

Details and Demo

https://github.com/nathanl/param_test

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions