Skip to content

Commit

Permalink
Ensure the dashboard compiles without optional deps
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Oct 16, 2020
1 parent 2c14462 commit 3fe626c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- run: mix compile --warnings-as-errors
if: matrix.warnings_as_errors
- name: Run Tests
run: mix test
run: mix test --include integration

npm_test:
name: npm test
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ erl_crash.dump
phoenix_live_dashboard-*.tar

node_modules
tmp
7 changes: 5 additions & 2 deletions lib/phoenix/live_dashboard/pages/ecto_stats_page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ defmodule Phoenix.LiveDashboard.EctoStatsPage do

# Phoenix.HMTL.Safe may be not be implemented for Decimal
# if PhoenixEcto is not available, so we handle it here.
defp convert_value(%Decimal{} = decimal), do: Decimal.to_string(decimal)
defp convert_value(value), do: value
defp convert_value(%struct{} = decimal) when struct == Decimal,
do: Decimal.to_string(decimal)

defp convert_value(value),
do: value
end
26 changes: 26 additions & 0 deletions test/phoenix/live_dashboard_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,30 @@ defmodule Phoenix.LiveDashboardTest do
|> html_response(200) =~
~s|<script nonce="abcdef">|
end

@tag :integration
test "compiles as a dep without optional deps" do
File.rm_rf!("tmp/as_a_dep")
File.mkdir_p!("tmp/as_a_dep")

File.cd!("tmp/as_a_dep", fn ->
File.write!("mix.exs", """
defmodule DepsOnDashboard.MixProject do
use Mix.Project
def project do
[
app: :deps_on_dashboard,
version: "0.0.1",
deps_path: "../../deps",
lockfile: "../../mix.lock",
deps: [{:phoenix_live_dashboard, path: "../.."}]
]
end
end
""")

assert {_, 0} = System.cmd("mix", ["compile"], stderr_to_stdout: true)
end)
end
end
2 changes: 1 addition & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ Supervisor.start_link(
strategy: :one_for_one
)

ExUnit.start()
ExUnit.start(exclude: :integration)

0 comments on commit 3fe626c

Please sign in to comment.