Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/mix/talon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ defmodule Mix.Talon do

@spec detect_project_structure() :: :phx | :phoenix | :unknown
def detect_project_structure do
phx_dir = otp_app_path()
phx_web_root = otp_app_path() <> "_web"
cond do
File.exists?("web") -> :phoenix
Path.join(["lib", phx_dir, "web"]) |> File.exists? -> :phx
Path.join(["lib", phx_web_root]) |> File.exists? -> :phx
true -> :unknown
end
end
Expand Down
28 changes: 28 additions & 0 deletions test/mix/tasks/talon.gen.resource_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,34 @@ defmodule Mix.Tasks.Talon.Gen.ResourceTest do
]
end
end

test "strip app namespace if provided" do
Logger.disable(self())

Application.put_env(:phx_blogger, PhxBlogger.Web.Endpoint,
secret_key_base: String.duplicate("abcdefgh", 8),
code_reloader: true,
root: File.cwd!)

in_tmp "strip_app_namespace", fn ->
Mix.Tasks.Phx.New.run([@app_name, "--no-ecto"])
end

in_project :phx_blogger, Path.join(tmp_path(), "strip_app_namespace/phx_blogger"), fn _ ->
Mix.Task.clear
GenNew.run [] #{ }~w(--phx)

Mix.Task.clear
GenResource.run ["PhxBlogger.Blogs.Post"]
root_path = Path.join(["lib", "phx_blogger", "talon"])
concern_path = Path.join([root_path, "admin"])

assert_file Path.join(concern_path, "post.ex"), [
"defmodule PhxBlogger.Admin.Blogs.Post do",
"use Talon.Resource, schema: PhxBlogger.Blogs.Post, concern: PhxBlogger.Admin"
]
end
end
end

describe "phoenix structure" do
Expand Down