Skip to content

Commit

Permalink
Fix bug where layout generator ignored namespace (#2502)
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorrjohn authored Feb 14, 2024
1 parent bd5bb08 commit a742521
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/generators/administrate/views/layout_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LayoutGenerator < Administrate::ViewGenerator
def copy_template
copy_file(
"../../layouts/administrate/application.html.erb",
"app/views/layouts/admin/application.html.erb"
"app/views/layouts/#{namespace}/application.html.erb"
)

call_generator("administrate:views:navigation")
Expand Down
13 changes: 13 additions & 0 deletions spec/generators/views/layout_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
expect(contents).to eq(expected_contents)
end

it "copies the layout template into the `namespace=<namespace>` dir" do
allow(Rails::Generators).to receive(:invoke)
expected_contents = File.read(
"app/views/layouts/administrate/application.html.erb"
)
generated_file = file("app/views/layouts/console/application.html.erb")

run_generator ["--namespace", "console"]
contents = File.read(generated_file)

expect(contents).to eq(expected_contents)
end

it "copies the flashes partial into the `admin/application` namespace" do
allow(Rails::Generators).to receive(:invoke)
expected_contents = contents_for_application_template("_flashes")
Expand Down

0 comments on commit a742521

Please sign in to comment.