Permalink
Browse files

Merge pull request #2017 from refinery/extension_generation

Default engine generation to use the engine name when provided and adding nested resources, rather than the singular class name (which is incorrect).
  • Loading branch information...
2 parents 0ba6bde + 22594a7 commit 6ca01680f7f2e8fa2d4dc482b178c7e19496dc0a @parndt parndt committed Nov 10, 2012
View
8 core/lib/refinery/extension_generation.rb
@@ -18,7 +18,13 @@ def namespacing
# Use exactly what the user requested, not a pluralised version.
options[:namespace].to_s.camelize
else
- class_name.pluralize
+ # If the user has passed an engine, we want to generate it inside of
+ # that extension.
+ if options[:extension].present?
+ options[:extension].to_s.camelize
+ else
+ class_name.pluralize
+ end
end
end
View
26 core/spec/lib/generators/refinery/engine/engine_generator_multiple_resources_spec.rb
@@ -12,6 +12,32 @@ module Refinery
run_generator %w{ rspec_product_test title:string description:text image:image brochure:resource }
end
+ context "when generating a resource without passing a namespace" do
+ before do
+ run_generator %w{ rspec_item_test title:string --extension rspec_product_tests --skip }
+ end
+
+ it "uses the extension name for the namespace" do
+ destination_root.should have_structure {
+ directory "vendor" do
+ directory "extensions" do
+ directory "rspec_product_tests" do
+ directory "app" do
+ directory "controllers" do
+ directory "refinery" do
+ directory "rspec_product_tests" do
+ file "rspec_item_tests_controller.rb"
+ end
+ end
+ end
+ end
+ end
+ end
+ end
+ }
+ end
+ end
+
context "when generating a resource inside existing extensions dir" do
before do
View
2 core/spec/lib/generators/refinery/engine/engine_generator_sanity_check_spec.rb
@@ -6,7 +6,7 @@ module Refinery
describe EngineGenerator do
include GeneratorSpec::TestCase
- it "exits when reserved word is used for extnesion name" do
+ it "exits when reserved word is used for extension name" do
clash_keywords = YAML.load_file(File.expand_path("../../../../../../lib/generators/refinery/clash_keywords.yml", __FILE__))
clash_keywords.each do |word|
lambda {

0 comments on commit 6ca0168

Please sign in to comment.