diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/middleware_test.rb | 6 | ||||
-rw-r--r-- | railties/test/application/rake/dbs_test.rb | 13 | ||||
-rw-r--r-- | railties/test/generators/migration_generator_test.rb | 17 | ||||
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 55 |
4 files changed, 36 insertions, 55 deletions
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb index 73ef2046c0..d8076c7151 100644 --- a/railties/test/application/middleware_test.rb +++ b/railties/test/application/middleware_test.rb @@ -96,6 +96,12 @@ module ApplicationTests assert !middleware.include?("Rack::Lock") end + test "removes lock if allow concurrency is set" do + add_to_config "config.allow_concurrency = true" + boot! + assert !middleware.include?("Rack::Lock") + end + test "removes static asset server if serve_static_assets is disabled" do add_to_config "config.serve_static_assets = false" boot! diff --git a/railties/test/application/rake/dbs_test.rb b/railties/test/application/rake/dbs_test.rb index 820b838702..9e711f25bd 100644 --- a/railties/test/application/rake/dbs_test.rb +++ b/railties/test/application/rake/dbs_test.rb @@ -166,19 +166,6 @@ module ApplicationTests require "#{app_path}/config/environment" db_test_load_structure end - - test 'db:test:load_structure with database_url' do - old_rails_env = ENV["RAILS_ENV"] - ENV["RAILS_ENV"] = 'test' - - begin - require "#{app_path}/config/environment" - set_database_url - db_test_load_structure - ensure - ENV["RAILS_ENV"] = old_rails_env - end - end end end end diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb index 62d9d1f06a..d876597944 100644 --- a/railties/test/generators/migration_generator_test.rb +++ b/railties/test/generators/migration_generator_test.rb @@ -172,8 +172,19 @@ class MigrationGeneratorTest < Rails::Generators::TestCase end end - def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove - migration = "create_books" + def test_create_table_migration + run_generator ["create_books", "title:string", "content:text"] + assert_migration "db/migrate/create_books.rb" do |content| + assert_method :change, content do |change| + assert_match(/create_table :books/, change) + assert_match(/ t\.string :title/, change) + assert_match(/ t\.text :content/, change) + end + end + end + + def test_should_create_empty_migrations_if_name_not_start_with_add_or_remove_or_create + migration = "delete_books" run_generator [migration, "title:string", "content:text"] assert_migration "db/migrate/#{migration}.rb" do |content| @@ -182,7 +193,7 @@ class MigrationGeneratorTest < Rails::Generators::TestCase end end end - + def test_properly_identifies_usage_file assert generator_class.send(:usage_path) end diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 904c1db57e..34441ef679 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -63,13 +63,24 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_directory "test/integration/" assert_no_file "test" - assert_no_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile"))) + assert_file "Rakefile" do |contents| + assert_no_match(/APP_RAKEFILE/, contents) + end end def test_generating_adds_dummy_app_rake_tasks_without_unit_test_files run_generator [destination_root, "-T", "--mountable", '--dummy-path', 'my_dummy_app'] + assert_file "Rakefile", /APP_RAKEFILE/ + end + + def test_generating_adds_dummy_app_without_javascript_and_assets_deps + run_generator [destination_root] + + assert_file "test/dummy/app/assets/stylesheets/application.css" - assert_match(/APP_RAKEFILE/, File.read(File.join(destination_root, "Rakefile"))) + assert_file "test/dummy/app/assets/javascripts/application.js" do |contents| + assert_no_match(/jquery/, contents) + end end def test_ensure_that_plugin_options_are_not_passed_to_app_generator @@ -112,7 +123,9 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_ensure_that_skip_active_record_option_is_passed_to_app_generator run_generator [destination_root, "--skip_active_record"] assert_no_file "test/dummy/config/database.yml" - assert_no_match(/ActiveRecord/, File.read(File.join(destination_root, "test/test_helper.rb"))) + assert_file "test/test_helper.rb" do |contents| + assert_no_match /ActiveRecord/, contents + end end def test_ensure_that_database_option_is_passed_to_app_generator @@ -134,8 +147,6 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_skipping_javascripts_without_mountable_option run_generator assert_no_file "app/assets/javascripts/bukkits/application.js" - assert_no_file "vendor/assets/javascripts/jquery.js" - assert_no_file "vendor/assets/javascripts/jquery_ujs.js" end def test_javascripts_generation @@ -143,33 +154,9 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_file "app/assets/javascripts/bukkits/application.js" end - def test_jquery_is_the_default_javascript_library - run_generator [destination_root, "--mountable"] - assert_file "app/assets/javascripts/bukkits/application.js" do |contents| - assert_match %r{^//= require jquery}, contents - assert_match %r{^//= require jquery_ujs}, contents - end - assert_file 'bukkits.gemspec' do |contents| - assert_match(/jquery-rails/, contents) - end - end - - def test_other_javascript_libraries - run_generator [destination_root, "--mountable", '-j', 'prototype'] - assert_file "app/assets/javascripts/bukkits/application.js" do |contents| - assert_match %r{^//= require prototype}, contents - assert_match %r{^//= require prototype_ujs}, contents - end - assert_file 'bukkits.gemspec' do |contents| - assert_match(/prototype-rails/, contents) - end - end - def test_skip_javascripts run_generator [destination_root, "--skip-javascript", "--mountable"] assert_no_file "app/assets/javascripts/bukkits/application.js" - assert_no_file "vendor/assets/javascripts/jquery.js" - assert_no_file "vendor/assets/javascripts/jquery_ujs.js" end def test_template_from_dir_pwd @@ -318,16 +305,6 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase assert_no_match('gemspec', contents) assert_match(/gem "rails", "~> #{Rails::VERSION::STRING}"/, contents) assert_match(/group :development do\n gem "sqlite3"\nend/, contents) - assert_match(/# gem "jquery-rails"/, contents) - assert_no_match(/# jquery-rails is used by the dummy application\ngem "jquery-rails"/, contents) - end - end - - def test_skipping_gemspec_in_full_mode_with_javascript_option - run_generator [destination_root, "--skip-gemspec", "--full", "--javascript=prototype"] - assert_file "Gemfile" do |contents| - assert_match(/# gem "prototype-rails"/, contents) - assert_match(/# jquery-rails is used by the dummy application\ngem "jquery-rails"/, contents) end end |