I'm new to Elixir and Phoenix and I'm trying to create a web service to compliment my web site. To start with, I just want to test my new data structure by importing some data from a json file. I thought I'd do this with a test. I've read through the basic guides (including the testing section), but I haven't been able to find anything on testing an api call.
From the code below, I get the following error when I run mix test
:
** (ArgumentError) flash not fetched, call fetch_flash/2
This fails on the line that makes the call and returns the connection. I'm assuming that I'm using the wrong call/missing something? Is there documentation that I've missed, or can somebody point me to a good example?
Here's a snippet from my router.ex
:
scope "/", ContactsApp do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
resources "/contacts", ContactsController
end
# Other scopes may use custom stacks.
scope "/api", ContactsApp do
pipe_through :api
get "/import", ContactsController, :import
end
For the time being, all I've done is copy the ContactsController.Create
method and called it ContactsController.Import
. I also copied the "creates resource and redirects when data is valid" test and used :import
instead of :create
Aucun commentaire:
Enregistrer un commentaire