Repository: phoenixframework/phoenix
Pull request #3315 (2019-03-13 01:48:13)

Update css-loader to ^2.1.1
I was having a problem in my Phoenix project, that the `@import`'s of my CSS file was not following the given order, so updating `css-loader` to the latest version just fixed it.


Patch:
diff --git a/README.md b/README.md
index ac62e3383..b572f66b9 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 ![phoenix logo](https://raw.githubusercontent.com/phoenixframework/phoenix/master/priv/static/phoenix.png)
 > ### Productive. Reliable. Fast.
-> A productive web framework that does not compromise speed and maintainability.
+> A productive web framework that does not compromise speed or maintainability.
 
 [![Build Status](https://api.travis-ci.org/phoenixframework/phoenix.svg?branch=master)](https://travis-ci.org/phoenixframework/phoenix)
 [![Inline docs](http://inch-ci.org/github/phoenixframework/phoenix.svg)](http://inch-ci.org/github/phoenixframework/phoenix)
diff --git a/assets/js/phoenix.js b/assets/js/phoenix.js
index 4cbb866ea..2bc742947 100644
--- a/assets/js/phoenix.js
+++ b/assets/js/phoenix.js
@@ -773,6 +773,9 @@ export class Socket {
   /**
    *
    * @param {Object} params - The params to send when connecting, for example `{user_id: userToken}`
+   *
+   * Passing params to connect is deprecated; pass them in the Socket constructor instead:
+   * `new Socket("/socket", {params: {user_id: userToken}})`.
    */
   connect(params){
     if(params){
diff --git a/guides/views.md b/guides/views.md
index 3c0bd6e5d..787341c70 100644
--- a/guides/views.md
+++ b/guides/views.md
@@ -75,7 +75,7 @@ Let's open up the `lib/hello_web/templates/page/index.html.eex` and locate this
 ```html
 <section class="phx-hero">
   <h1><%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
-  <p>A productive web framework that<br/>does not compromise speed and maintainability.</p>
+  <p>A productive web framework that<br/>does not compromise speed or maintainability.</p>
 </section>
 ```
 
@@ -84,7 +84,7 @@ Then let's add a line with a link back to the same page. (The objective is to se
 ```html
 <section class="phx-hero">
   <h1><%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
-  <p>A productive web framework that<br/>does not compromise speed and maintainability.</p>
+  <p>A productive web framework that<br/>does not compromise speed or maintainability.</p>
   <p><a href="<%= Routes.page_path(@conn, :index) %>">Link back to this page</a></p>
 </section>
 ```
diff --git a/installer/templates/phx_assets/webpack/package.json b/installer/templates/phx_assets/webpack/package.json
index 7be6b8ac0..e5d0f5147 100644
--- a/installer/templates/phx_assets/webpack/package.json
+++ b/installer/templates/phx_assets/webpack/package.json
@@ -15,7 +15,7 @@
     "@babel/preset-env": "^7.0.0",
     "babel-loader": "^8.0.0",
     "copy-webpack-plugin": "^4.5.0",
-    "css-loader": "^0.28.10",
+    "css-loader": "^2.1.1",
     "mini-css-extract-plugin": "^0.4.0",
     "optimize-css-assets-webpack-plugin": "^4.0.0",
     "terser-webpack-plugin": "^1.1.0",
diff --git a/installer/templates/phx_single/config/prod.exs b/installer/templates/phx_single/config/prod.exs
index 375acea39..d767c2675 100644
--- a/installer/templates/phx_single/config/prod.exs
+++ b/installer/templates/phx_single/config/prod.exs
@@ -22,7 +22,7 @@ config :logger, level: :info
 # To get SSL working, you will need to add the `https` key
 # to the previous section and set your `:url` port to 443:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>,
+#     config :<%= web_app_name %>, <%= endpoint_module %>,
 #       ...
 #       url: [host: "example.com", port: 443],
 #       https: [
@@ -46,7 +46,7 @@ config :logger, level: :info
 # We also recommend setting `force_ssl` in your endpoint, ensuring
 # no data is ever sent via http, always redirecting to https:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>,
+#     config :<%= web_app_name %>, <%= endpoint_module %>,
 #       force_ssl: [hsts: true]
 #
 # Check `Plug.SSL` for all available options in `force_ssl`.
@@ -61,7 +61,7 @@ config :logger, level: :info
 # Alternatively, you can configure exactly which server to
 # start per endpoint:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>, server: true
+#     config :<%= web_app_name %>, <%= endpoint_module %>, server: true
 #
 # Note you can't rely on `System.get_env/1` when using releases.
 # See the releases documentation accordingly.
diff --git a/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs b/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
index 2c32b6807..67688df68 100644
--- a/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
+++ b/installer/templates/phx_umbrella/apps/app_name_web/config/prod.exs
@@ -23,7 +23,7 @@ config :<%= web_app_name %>, <%= endpoint_module %>,
 # To get SSL working, you will need to add the `https` key
 # to the previous section and set your `:url` port to 443:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>,
+#     config :<%= web_app_name %>, <%= endpoint_module %>,
 #       ...
 #       url: [host: "example.com", port: 443],
 #       https: [
@@ -47,7 +47,7 @@ config :<%= web_app_name %>, <%= endpoint_module %>,
 # We also recommend setting `force_ssl` in your endpoint, ensuring
 # no data is ever sent via http, always redirecting to https:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>,
+#     config :<%= web_app_name %>, <%= endpoint_module %>,
 #       force_ssl: [hsts: true]
 #
 # Check `Plug.SSL` for all available options in `force_ssl`.
@@ -62,7 +62,7 @@ config :<%= web_app_name %>, <%= endpoint_module %>,
 # Alternatively, you can configure exactly which server to
 # start per endpoint:
 #
-#     config :<%= app_name %>, <%= endpoint_module %>, server: true
+#     config :<%= web_app_name %>, <%= endpoint_module %>, server: true
 #
 # Note you can't rely on `System.get_env/1` when using releases.
 # See the releases documentation accordingly.
diff --git a/installer/templates/phx_web/templates/page/index.html.eex b/installer/templates/phx_web/templates/page/index.html.eex
index 9953a4584..07a2ae6bd 100644
--- a/installer/templates/phx_web/templates/page/index.html.eex
+++ b/installer/templates/phx_web/templates/page/index.html.eex
@@ -1,6 +1,6 @@
 <section class="phx-hero">
   <h1><%%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
-  <p>A productive web framework that<br/>does not compromise speed and maintainability.</p>
+  <p>A productive web framework that<br/>does not compromise speed or maintainability.</p>
 </section>
 
 <section class="row">
diff --git a/lib/mix/phoenix.ex b/lib/mix/phoenix.ex
index 5a8464f9f..c65691402 100644
--- a/lib/mix/phoenix.ex
+++ b/lib/mix/phoenix.ex
@@ -91,7 +91,7 @@ defmodule Mix.Phoenix do
 
   """
   def inflect(singular) do
-    base       = Mix.Phoenix.base
+    base       = Mix.Phoenix.base()
     web_module = base |> web_module() |> inspect()
     scoped     = Phoenix.Naming.camelize(singular)
     path       = Phoenix.Naming.underscore(scoped)
diff --git a/lib/mix/tasks/phx.ex b/lib/mix/tasks/phx.ex
index 2e6cef7d7..9ddf6a90d 100644
--- a/lib/mix/tasks/phx.ex
+++ b/lib/mix/tasks/phx.ex
@@ -22,7 +22,7 @@ defmodule Mix.Tasks.Phx do
     Application.ensure_all_started(:phoenix)
     Mix.shell.info "Phoenix v#{Application.spec(:phoenix, :vsn)}"
     Mix.shell.info "Productive. Reliable. Fast."
-    Mix.shell.info "A productive web framework that does not compromise speed and maintainability."
+    Mix.shell.info "A productive web framework that does not compromise speed or maintainability."
     Mix.shell.info "\nAvailable tasks:\n"
     Mix.Tasks.Help.run(["--search", "phx."])
   end
diff --git a/lib/mix/tasks/phx.gen.context.ex b/lib/mix/tasks/phx.gen.context.ex
index b257cd45b..8b9a1ea8c 100644
--- a/lib/mix/tasks/phx.gen.context.ex
+++ b/lib/mix/tasks/phx.gen.context.ex
@@ -208,6 +208,10 @@ defmodule Mix.Tasks.Phx.Gen.Context do
         raise_with_help "Expected the schema, #{inspect schema}, to be a valid module name"
       context == schema ->
         raise_with_help "The context and schema should have different names"
+      context == Mix.Phoenix.base() ->
+        raise_with_help "Cannot generate context #{context} because it has the same name as the application"
+      schema == Mix.Phoenix.base() ->
+        raise_with_help "Cannot generate schema #{schema} because it has the same name as the application"
       true ->
         args
     end
diff --git a/lib/phoenix/token.ex b/lib/phoenix/token.ex
index d10568238..41ee3ad5d 100644
--- a/lib/phoenix/token.ex
+++ b/lib/phoenix/token.ex
@@ -233,6 +233,8 @@ defmodule Phoenix.Token do
     false
   end
 
+  defp expired?(signed, max_age_secs) when max_age_secs <= 0, do: true
+
   defp expired?(signed, max_age_secs), do: (signed + trunc(max_age_secs * 1000)) < now_ms()
 
   defp now_ms, do: System.system_time(:millisecond)
diff --git a/mix.exs b/mix.exs
index fc43e63f6..f5f332bd7 100644
--- a/mix.exs
+++ b/mix.exs
@@ -22,7 +22,7 @@ defmodule Phoenix.MixProject do
       homepage_url: "http://www.phoenixframework.org",
       description: """
       Productive. Reliable. Fast. A productive web framework that
-      does not compromise speed and maintainability.
+      does not compromise speed or maintainability.
       """
     ]
   end


Test patch:
diff --git a/guides/testing/testing_channels.md b/guides/testing/testing_channels.md
index 17b947ef1..8acb11f95 100644
--- a/guides/testing/testing_channels.md
+++ b/guides/testing/testing_channels.md
@@ -168,6 +168,8 @@ Since the `handle_in/3` callback for the `"shout"` event just broadcasts the sam
 all subscribers in the `"room:lobby"` should receive the message. To check that, we do
 `assert_broadcast "shout", %{"hello" => "all"}`.
 
+**NOTE:** `assert_broadcast/3` tests that the message was broadcast in the PubSub system.
+  For testing if a client receives a message, use `assert_push/3`
 
 #### Testing an Asynchronous Push from the Server
 
diff --git a/test/mix/tasks/phx.gen.context_test.exs b/test/mix/tasks/phx.gen.context_test.exs
index 8ca5a4d71..af3920e42 100644
--- a/test/mix/tasks/phx.gen.context_test.exs
+++ b/test/mix/tasks/phx.gen.context_test.exs
@@ -104,6 +104,14 @@ defmodule Mix.Tasks.Phx.Gen.ContextTest do
         Gen.Context.run(~w(Blog Blog blogs))
       end
 
+      assert_raise Mix.Error, ~r/Cannot generate context Phoenix because it has the same name as the application/, fn ->
+        Gen.Context.run(~w(Phoenix Post blogs))
+      end
+
+      assert_raise Mix.Error, ~r/Cannot generate schema Phoenix because it has the same name as the application/, fn ->
+        Gen.Context.run(~w(Blog Phoenix blogs))
+      end
+
       assert_raise Mix.Error, ~r/Invalid arguments/, fn ->
         Gen.Context.run(~w(Blog.Post posts))
       end
diff --git a/test/phoenix/token_test.exs b/test/phoenix/token_test.exs
index e2b694598..d54754a3b 100644
--- a/test/phoenix/token_test.exs
+++ b/test/phoenix/token_test.exs
@@ -46,6 +46,7 @@ defmodule Phoenix.TokenTest do
     assert Token.verify(conn(), "id", token, max_age: -1000) == {:error, :expired}
     assert Token.verify(conn(), "id", token, max_age: 100) == {:ok, 1}
     assert Token.verify(conn(), "id", token, max_age: -100) == {:error, :expired}
+    assert Token.verify(conn(), "id", token, max_age: 0) == {:error, :expired}
 
     token = Token.sign(conn(), "id", 1)
     assert Token.verify(conn(), "id", token, max_age: 0.1) == {:ok, 1}