Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where layout wasn't respecting namespace argument #2502

Merged
merged 1 commit into from
Feb 14, 2024
Merged
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
2 changes: 1 addition & 1 deletion lib/generators/administrate/views/layout_generator.rb
Original file line number Diff line number Diff line change
@@ -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")
13 changes: 13 additions & 0 deletions spec/generators/views/layout_generator_spec.rb
Original file line number Diff line number Diff line change
@@ -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")
Loading