aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/generators/app_generator_test.rb
diff options
context:
space:
mode:
authorFred Wu <ifredwu@gmail.com>2010-08-25 11:36:07 +1000
committerJosé Valim <jose.valim@gmail.com>2010-08-28 17:54:53 -0300
commit83f4507cf153ea6081dd70326f5f3a0331cc167e (patch)
treeb2e41589c1e8e68b9ba0f8ba5290f55a61b754d6 /railties/test/generators/app_generator_test.rb
parent3e22e0b0250e1386f68ebbdb7f23ae10888f5da6 (diff)
downloadrails-83f4507cf153ea6081dd70326f5f3a0331cc167e.tar.gz
rails-83f4507cf153ea6081dd70326f5f3a0331cc167e.tar.bz2
rails-83f4507cf153ea6081dd70326f5f3a0331cc167e.zip
Fixed the session name generated by the app_generator. Also refactored the corresponding test suites to be cleaner. [#5434 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'railties/test/generators/app_generator_test.rb')
-rw-r--r--railties/test/generators/app_generator_test.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index dcd7629505..9ce2308a02 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -45,6 +45,12 @@ class AppGeneratorTest < Rails::Generators::TestCase
super
Rails::Generators::AppGenerator.instance_variable_set('@desc', nil)
@bundle_command = File.basename(Thor::Util.ruby_command).sub(/ruby/, 'bundle')
+
+ Kernel::silence_warnings do
+ Thor::Base.shell.send(:attr_accessor, :always_force)
+ @shell = Thor::Base.shell.new
+ @shell.send(:always_force=, true)
+ end
end
def teardown
@@ -118,17 +124,26 @@ class AppGeneratorTest < Rails::Generators::TestCase
FileUtils.mv(app_root, app_moved_root)
- # forces the shell to automatically overwrite all files
- Thor::Base.shell.send(:attr_accessor, :always_force)
- shell = Thor::Base.shell.new
- shell.send(:always_force=, true)
-
generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
- :destination_root => app_moved_root, :shell => shell
+ :destination_root => app_moved_root, :shell => @shell
generator.send(:app_const)
silence(:stdout){ generator.send(:create_config_files) }
assert_file "myapp_moved/config/environment.rb", /Myapp::Application\.initialize!/
end
+
+ def test_rails_update_generates_correct_session_key
+ app_root = File.join(destination_root, 'myapp')
+ run_generator [app_root]
+
+ Rails.application.config.root = app_root
+ Rails.application.class.stubs(:name).returns("Myapp")
+ Rails.application.stubs(:is_a?).returns(Rails::Application)
+
+ generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true }, :destination_root => app_root, :shell => @shell
+ generator.send(:app_const)
+ silence(:stdout){ generator.send(:create_config_files) }
+ assert_file "myapp/config/initializers/session_store.rb", /_myapp_session/
+ end
def test_application_names_are_not_singularized
run_generator [File.join(destination_root, "hats")]