Repository: phoenixframework/phoenix
Pull request #2666 (2017-12-12 08:54:59)

Remove -y option from mix phx.new command
That option gives an error message:

```
** (Mix) Invalid option: -y
```


Patch:
diff --git a/guides/docs/controllers.md b/guides/docs/controllers.md
index c9d052a8a..2c9c801ae 100644
--- a/guides/docs/controllers.md
+++ b/guides/docs/controllers.md
@@ -549,6 +549,7 @@ Let's say we have a `show` action which uses `with` to fetch a blog post and the
 defmodule HelloWeb.MyController do
   use Phoenix.Controller
   alias Hello.{Authorizer, Blog}
+  alias HelloWeb.ErrorView
 
   def show(conn, %{"id" => id}, current_user) do
     with {:ok, post} <- Blog.fetch_post(id),
diff --git a/lib/mix/tasks/phx.gen.html.ex b/lib/mix/tasks/phx.gen.html.ex
index 2c72bd941..692137703 100644
--- a/lib/mix/tasks/phx.gen.html.ex
+++ b/lib/mix/tasks/phx.gen.html.ex
@@ -182,8 +182,6 @@ defmodule Mix.Tasks.Phx.Gen.Html do
 
   defp inputs(%Schema{} = schema) do
     Enum.map(schema.attrs, fn
-      {_, {:array, _}} ->
-        {nil, nil, nil}
       {_, {:references, _}} ->
         {nil, nil, nil}
       {key, :integer} ->
@@ -204,6 +202,10 @@ defmodule Mix.Tasks.Phx.Gen.Html do
         {label(key), ~s(<%= datetime_select f, #{inspect(key)}, class: "form-control" %>), error(key)}
       {key, :naive_datetime} ->
         {label(key), ~s(<%= datetime_select f, #{inspect(key)}, class: "form-control" %>), error(key)}
+      {key, {:array, :integer}} ->
+        {label(key), ~s(<%= multiple_select f, #{inspect(key)}, ["1": 1, "2": 2], class: "form-control" %>), error(key)}
+      {key, {:array, _}} ->
+        {label(key), ~s(<%= multiple_select f, #{inspect(key)}, ["Option 1": "option1", "Option 2": "option2"], class: "form-control" %>), error(key)}
       {key, _}  ->
         {label(key), ~s(<%= text_input f, #{inspect(key)}, class: "form-control" %>), error(key)}
     end)


Test patch:
diff --git a/guides/docs/testing/testing_controllers.md b/guides/docs/testing/testing_controllers.md
index c7a994b7f..13a8a60bf 100644
--- a/guides/docs/testing/testing_controllers.md
+++ b/guides/docs/testing/testing_controllers.md
@@ -17,7 +17,7 @@ However, *don't* actually run this command. Instead, we're going to explore test
 If you haven't already done so, first create a blank project by running:
 
 ```console
-$ mix phx.new hello -y
+$ mix phx.new hello
 ```
 
 Change into the newly-created `hello` directory, configure your database in `config/dev.exs` and then run:
@@ -134,9 +134,10 @@ defmodule HelloWeb.UserControllerTest do
     # create users local to this database connection and test
     [{:ok, user1},{:ok, user2}] = Enum.map(users, &Accounts.create_user(&1))
 
-    response = conn
-    |> get(user_path(conn, :index))
-    |> json_response(200)
+    response =
+      conn
+      |> get(user_path(conn, :index))
+      |> json_response(200)
 
     expected = %{
       "data" => [
@@ -264,11 +265,12 @@ Our first `show/2` test result is, as expected, not implemented. Let's build a t
 test "Responds with user info if the user is found", %{conn: conn} do
   {:ok, user} = Accounts.create_user(%{name: "John", email: "john@example.com", password: "john pass"})
 
-  response = conn
-  |> get(user_path(conn, :show, user.id))
-  |> json_response(200)
+  response =
+    conn
+    |> get(user_path(conn, :show, user.id))
+    |> json_response(200)
 
-  expected = %{ "data" => %{"email" => user.email, "name" => user.name} }
+  expected = %{"data" => %{"email" => user.email, "name" => user.name}}
 
   assert response == expected
 end
@@ -298,11 +300,12 @@ describe "show/2" do
   setup [:create_user]
   test "Responds with user info if the user is found", %{conn: conn, user: user} do
 
-    response = conn
-    |> get(user_path(conn, :show, user.id))
-    |> json_response(200)
+    response =
+      conn
+      |> get(user_path(conn, :show, user.id))
+      |> json_response(200)
 
-    expected = %{ "data" => %{"email" => user.email, "name" => user.name} }
+    expected = %{"data" => %{"email" => user.email, "name" => user.name}}
 
     assert response == expected
   end
@@ -319,11 +322,12 @@ Finally, let's change our `index/2` test to also use the new `create_user` funct
     setup [:create_user]
     test "index/2 responds with all Users", %{conn: conn, user: user} do
 
-      response = conn
-      |> get(user_path(conn, :index))
-      |> json_response(200)
+      response =
+        conn
+        |> get(user_path(conn, :index))
+        |> json_response(200)
 
-      expected = %{ "data" => [%{ "name" => user.name, "email" => user.email }] }
+      expected = %{"data" => [%{"name" => user.name, "email" => user.email}]}
 
       assert response == expected
     end
@@ -394,7 +398,7 @@ test "Responds with a message indicating user not found", %{conn:  conn} do
     |> get(user_path(conn, :show, -1 ))
     |> json_response(404)
 
-  expected = %{ "errors" => "User not found." }
+  expected = %{"errors" => "User not found."}
 
   assert response == expected
 end
@@ -406,7 +410,7 @@ Our controller action needs to handle the error thrown by Ecto. We have two choi
 
 ```elixir
 @doc """
-Gets a single `%User{}` from the data store  where the primary key matches the
+Gets a single `%User{}` from the data store where the primary key matches the
 given id.
 
 Returns `nil` if no result was found.
@@ -431,7 +435,7 @@ def show(conn, %{"id" => id}) do
     nil ->
       conn
       |> put_status(:not_found)
-      |> json(%{error: "User not found"})
+      |> json(%{errors: "User not found."})
     user ->
       render(conn, "show.json", user: user)
   end
diff --git a/lib/phoenix/test/conn_test.ex b/lib/phoenix/test/conn_test.ex
index 67a290d24..926627009 100644
--- a/lib/phoenix/test/conn_test.ex
+++ b/lib/phoenix/test/conn_test.ex
@@ -134,7 +134,7 @@ defmodule Phoenix.ConnTest do
   This is useful when a specific connection is required
   for testing a plug or a particular function.
   """
-  @spec build_conn(atom | binary, binary, binary | list | map) :: Conn.t
+  @spec build_conn(atom | binary, binary, binary | list | map | nil) :: Conn.t
   def build_conn(method, path, params_or_body \\ nil) do
     Plug.Adapters.Test.Conn.conn(%Conn{}, method, path, params_or_body)
     |> Conn.put_private(:plug_skip_csrf_protection, true)
@@ -144,7 +144,7 @@ defmodule Phoenix.ConnTest do
   @doc """
   Deprecated version of conn/3. Use build_conn/3 instead
   """
-  @spec conn(atom | binary, binary, binary | list | map) :: Conn.t
+  @spec conn(atom | binary, binary, binary | list | map | nil) :: Conn.t
   def conn(method, path, params_or_body \\ nil) do
     IO.write :stderr, """
     warning: using conn/3 to build a connection is deprecated. Use build_conn/3 instead.
diff --git a/test/mix/tasks/phx.gen.html_test.exs b/test/mix/tasks/phx.gen.html_test.exs
index e79a1c68a..5c4d3292d 100644
--- a/test/mix/tasks/phx.gen.html_test.exs
+++ b/test/mix/tasks/phx.gen.html_test.exs
@@ -108,6 +108,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= text_input f, :title, class: "form-control" %>)
         assert file =~ ~s(<%= number_input f, :votes, class: "form-control" %>)
         assert file =~ ~s(<%= number_input f, :cost, step: "any", class: "form-control" %>)
+        assert file =~ ~s(<%= multiple_select f, :tags, ["Option 1": "option1", "Option 2": "option2"], class: "form-control" %>)
         assert file =~ ~s(<%= checkbox f, :popular, class: "checkbox" %>)
         assert file =~ ~s(<%= datetime_select f, :drafted_at, class: "form-control" %>)
         assert file =~ ~s(<%= datetime_select f, :published_at, class: "form-control" %>)
@@ -119,6 +120,7 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= label f, :title, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :votes, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :cost, class: "control-label" %>)
+        assert file =~ ~s(<%= label f, :tags, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :popular, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :drafted_at, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :published_at, class: "control-label" %>)
@@ -127,7 +129,6 @@ defmodule Mix.Tasks.Phx.Gen.HtmlTest do
         assert file =~ ~s(<%= label f, :alarm, class: "control-label" %>)
         assert file =~ ~s(<%= label f, :secret, class: "control-label" %>)
 
-        refute file =~ ":tags"
         refute file =~ ~s(<%= label f, :user_id)
         refute file =~ ~s(<%= number_input f, :user_id)
       end