Generate default layout in engine with --mountable option

This commit is contained in:
Piotr Sarnacki 2010-12-15 12:20:48 +01:00 committed by Vijay Dev
parent 7f77d6691f
commit ed32c8fe51
4 changed files with 8 additions and 2 deletions

View File

@ -284,6 +284,7 @@ module Rails
def app_const_base
@app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize
end
alias :camelized :app_const_base
def app_const
@app_const ||= "#{app_const_base}::Application"

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title><%= app_const_base %></title>
<title><%= camelized %></title>
<%%= stylesheet_link_tag :all %>
<%%= javascript_include_tag :defaults %>
<%%= csrf_meta_tags %>

View File

@ -8,7 +8,11 @@ module Rails
end
def app
directory "app" if options[:mountable]
if options[:mountable]
directory "app"
template "#{app_templates_dir}/app/views/layouts/application.html.erb.tt",
"app/views/layouts/#{name}/application.html.erb"
end
end
def readme

View File

@ -166,6 +166,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase
assert_file "test/dummy/config/routes.rb", /mount Bukkits::Engine => "\/bukkits"/
assert_file "app/controllers/bukkits/application_controller.rb", /module Bukkits\n class ApplicationController < ActionController::Base/
assert_file "app/helpers/bukkits/application_helper.rb", /module Bukkits\n module ApplicationHelper/
assert_file "app/views/layouts/bukkits/application.html.erb", /<title>Bukkits<\/title>/
end
def test_passing_dummy_path_as_a_parameter