Skip to content
This repository
Browse code

Ensures the app generator generates the correct @app_name. [#5434 sta…

…te:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit 51e8435e346c3f2f6356342b661231fcaeaa357a 1 parent 6b3ad0c
Fred Wu authored August 30, 2010 josevalim committed September 24, 2010
11  railties/lib/rails/generators/rails/app/app_generator.rb
@@ -353,18 +353,21 @@ def file(*args, &block)
353 353
       end
354 354
 
355 355
       def app_name
356  
-        @app_name ||= File.basename(destination_root)
  356
+        @app_name ||= defined_app_const_base? ? defined_app_name : File.basename(destination_root)
  357
+      end
  358
+
  359
+      def defined_app_name
  360
+        defined_app_const_base.underscore
357 361
       end
358  
-      
359  
-      alias_method :defined_app_name, :app_name
360 362
 
361 363
       def defined_app_const_base
362 364
         Rails.respond_to?(:application) && defined?(Rails::Application) &&
363 365
           Rails.application.is_a?(Rails::Application) && Rails.application.class.name.sub(/::Application$/, "")
364 366
       end
365 367
 
  368
+      alias :defined_app_const_base? :defined_app_const_base
  369
+
366 370
       def app_const_base
367  
-        defined_app_name # ensures the correct app_name if it's already defined
368 371
         @app_const_base ||= defined_app_const_base || app_name.gsub(/\W/, '_').squeeze('_').camelize
369 372
       end
370 373
 
1  railties/test/generators/app_generator_test.rb
@@ -129,6 +129,7 @@ def test_application_name_is_detected_if_it_exists_and_app_folder_renamed
129 129
     generator.send(:app_const)
130 130
     silence(:stdout){ generator.send(:create_config_files) }
131 131
     assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/
  132
+    assert_file "myapp_moved/config/initializers/session_store.rb", /_myapp_session/
132 133
   end
133 134
   
134 135
   def test_rails_update_generates_correct_session_key

0 notes on commit 51e8435

Please sign in to comment.
Something went wrong with that request. Please try again.