I’m trying to test a file upload in my controller test. I’m using the approach you recommended:
but I keep getting the following error:
** (ArgumentError) structs expect an :id key when converting to_param or a custom
implementation of the Phoenix.Param protocol (read Phoenix.Param docs for more information),
got: %Plug.Upload{content_type: nil, filename: "fantasy_team_csv_table.csv", path:
"test/fixtures/fantasy_team_csv_table.csv"}
Here is my code:
file_path = "test/fixtures/fantasy_team_csv_table.csv"
params = %{
"table" => "FantasyTeam",
"spreadsheet" => %Plug.Upload{path: file_path, filename: "fantasy_team_csv_table.csv"}
}
conn = post(conn, table_upload_path(conn, :create, table_upload: params))
I read the Phoenix.Params docs, but couldn’t figure out how to fix the error from the docs. Any ideas how to fix it? Thanks!


















