Repository: phoenixframework/phoenix
Pull request #3593 (2019-10-25 07:23:58)

Delete struct duplicate field 'route'


Patch:
diff --git a/lib/phoenix/router/helpers.ex b/lib/phoenix/router/helpers.ex
index 0cb323b96..fd305e824 100644
--- a/lib/phoenix/router/helpers.ex
+++ b/lib/phoenix/router/helpers.ex
@@ -116,23 +116,23 @@ defmodule Phoenix.Router.Helpers do
 
     defhelper = quote @anno do
       defhelper = fn helper, vars, opts, bins, segs ->
-        def unquote(:"#{helper}_path")(conn_or_endpoint, unquote(opts), unquote_splicing(vars)) do
-          unquote(:"#{helper}_path")(conn_or_endpoint, unquote(opts), unquote_splicing(vars), [])
+        def unquote(:"#{helper}_path")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars)) do
+          unquote(:"#{helper}_path")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars), [])
         end
 
-        def unquote(:"#{helper}_path")(conn_or_endpoint, unquote(opts), unquote_splicing(vars), params)
+        def unquote(:"#{helper}_path")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars), params)
             when is_list(params) or is_map(params) do
           path(conn_or_endpoint, segments(unquote(segs), params, unquote(bins),
-                {unquote(helper), unquote(opts), unquote(Enum.map(vars, &Macro.to_string/1))}))
+                {unquote(helper), unquote(Macro.escape(opts)), unquote(Enum.map(vars, &Macro.to_string/1))}))
         end
 
-        def unquote(:"#{helper}_url")(conn_or_endpoint, unquote(opts), unquote_splicing(vars)) do
-          unquote(:"#{helper}_url")(conn_or_endpoint, unquote(opts), unquote_splicing(vars), [])
+        def unquote(:"#{helper}_url")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars)) do
+          unquote(:"#{helper}_url")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars), [])
         end
 
-        def unquote(:"#{helper}_url")(conn_or_endpoint, unquote(opts), unquote_splicing(vars), params)
+        def unquote(:"#{helper}_url")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars), params)
             when is_list(params) or is_map(params) do
-          url(conn_or_endpoint) <> unquote(:"#{helper}_path")(conn_or_endpoint, unquote(opts), unquote_splicing(vars), params)
+          url(conn_or_endpoint) <> unquote(:"#{helper}_path")(conn_or_endpoint, unquote(Macro.escape(opts)), unquote_splicing(vars), params)
         end
       end
     end
@@ -166,7 +166,7 @@ defmodule Phoenix.Router.Helpers do
 
         defp raise_route_error(unquote(helper), suffix, arity, action, params) do
           Phoenix.Router.Helpers.raise_route_error(__MODULE__, "#{unquote(helper)}_#{suffix}",
-                                                   arity, action, unquote(routes), params)
+                                                   arity, action, unquote(Macro.escape(routes)), params)
         end
       end
     end
@@ -297,7 +297,7 @@ defmodule Phoenix.Router.Helpers do
       defhelper.(
         unquote(helper),
         unquote(Macro.escape(vars)),
-        unquote(opts),
+        unquote(Macro.escape(opts)),
         unquote(Macro.escape(bins)),
         unquote(Macro.escape(segs))
       )
diff --git a/lib/phoenix/router/resource.ex b/lib/phoenix/router/resource.ex
index 043d2ddf3..ca90feb51 100644
--- a/lib/phoenix/router/resource.ex
+++ b/lib/phoenix/router/resource.ex
@@ -21,7 +21,7 @@ defmodule Phoenix.Router.Resource do
     * `:collection` - the context for collection routes
 
   """
-  defstruct [:path, :actions, :param, :route, :controller, :route, :member, :collection, :singleton]
+  defstruct [:path, :actions, :param, :route, :controller, :member, :collection, :singleton]
   @type t :: %Resource{}
 
   @doc """
diff --git a/lib/phoenix/socket.ex b/lib/phoenix/socket.ex
index 4525b2690..1bb1e5de1 100644
--- a/lib/phoenix/socket.ex
+++ b/lib/phoenix/socket.ex
@@ -108,7 +108,7 @@ defmodule Phoenix.Socket do
   the original message. Both data-types also include a join_ref that
   uniquely identifes the currently joined channel.
 
-  The `Phoenix.Socket` implementation may also sent special messages
+  The `Phoenix.Socket` implementation may also send special messages
   and replies:
 
     * `"phx_error"` - in case of errors, such as a channel process


Test patch:
diff --git a/test/phoenix/router/helpers_test.exs b/test/phoenix/router/helpers_test.exs
index 48dc86c40..51964c65d 100644
--- a/test/phoenix/router/helpers_test.exs
+++ b/test/phoenix/router/helpers_test.exs
@@ -5,7 +5,8 @@ modules = [
   CommentController,
   FileController,
   ProductController,
-  Admin.MessageController
+  Admin.MessageController,
+  SubPlug
 ]
 
 for module <- modules do
@@ -57,6 +58,8 @@ defmodule Phoenix.Router.HelpersTest do
     get "/products", ProductController, :show
     get "/products/:id/:sort", ProductController, :show
     get "/products/:id/:sort/:page", ProductController, :show
+
+    get "/mfa_path", SubPlug, func: {M, :f, [10]}
   end
 
   # Emulate regular endpoint functions
@@ -388,6 +391,10 @@ defmodule Phoenix.Router.HelpersTest do
     assert Helpers.admin_message_path(__MODULE__, :show, 1) == "/admin/new/messages/1"
   end
 
+  test "can pass an {m, f, a} tuple as a plug argument" do
+    assert Helpers.sub_plug_path(__MODULE__, func: {M, :f, [10]}) == "/mfa_path"
+  end
+
   ## Others
 
   defp conn_with_endpoint do