diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/configuration_test.rb | 11 | ||||
-rw-r--r-- | railties/test/application/paths_test.rb | 1 | ||||
-rw-r--r-- | railties/test/application/rake_test.rb | 88 | ||||
-rw-r--r-- | railties/test/generators/actions_test.rb | 7 | ||||
-rw-r--r-- | railties/test/generators/app_generator_test.rb | 1 | ||||
-rw-r--r-- | railties/test/generators/generated_attribute_test.rb | 5 | ||||
-rw-r--r-- | railties/test/generators/plugin_new_generator_test.rb | 2 |
7 files changed, 110 insertions, 5 deletions
diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index 2547863d12..448982f9de 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -45,7 +45,7 @@ module ApplicationTests Rails.env = "development" assert_equal [:default, "development"], Rails.groups assert_equal [:default, "development", :assets], Rails.groups(:assets => [:development]) - assert_equal [:default, "development", :assets], Rails.groups(:assets => %w(development)) + assert_equal [:default, "development", :another, :assets], Rails.groups(:another, :assets => %w(development)) Rails.env = "test" assert_equal [:default, "test"], Rails.groups(:assets => [:development]) @@ -516,5 +516,14 @@ module ApplicationTests get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml" assert_equal 'XML', last_response.body end + + test "Rails.application#env_config exists and include some existing parameters" do + make_basic_app + + assert_respond_to app, :env_config + assert_equal app.env_config['action_dispatch.parameter_filter'], app.config.filter_parameters + assert_equal app.env_config['action_dispatch.secret_token'], app.config.secret_token + assert_equal app.env_config['action_dispatch.show_exceptions'], app.config.action_dispatch.show_exceptions + end end end diff --git a/railties/test/application/paths_test.rb b/railties/test/application/paths_test.rb index 0d22d8c19a..964cff48cd 100644 --- a/railties/test/application/paths_test.rb +++ b/railties/test/application/paths_test.rb @@ -48,7 +48,6 @@ module ApplicationTests assert_path @paths["vendor"], "vendor" assert_path @paths["vendor/plugins"], "vendor/plugins" assert_path @paths["tmp"], "tmp" - assert_path @paths["tmp/cache"], "tmp/cache" assert_path @paths["config"], "config" assert_path @paths["config/locales"], "config/locales/en.yml" assert_path @paths["config/environment"], "config/environment.rb" diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb index 7671c129e9..cc65a674c9 100644 --- a/railties/test/application/rake_test.rb +++ b/railties/test/application/rake_test.rb @@ -91,7 +91,7 @@ module ApplicationTests get '/cart', :to => 'cart#show' end RUBY - assert_match 'cart GET /cart(.:format)', Dir.chdir(app_path){ `rake routes` } + assert_equal "cart GET /cart(.:format) cart#show\n", Dir.chdir(app_path){ `rake routes` } end def test_rake_routes_shows_custom_assets @@ -100,7 +100,91 @@ module ApplicationTests get '/custom/assets', :to => 'custom_assets#show' end RUBY - assert_match 'custom_assets GET /custom/assets(.:format)', Dir.chdir(app_path){ `rake routes` } + assert_equal "custom_assets GET /custom/assets(.:format) custom_assets#show\n", + Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_resources_route + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + resources :articles + end + RUBY + expected = + " articles GET /articles(.:format) articles#index\n" << + " POST /articles(.:format) articles#create\n" << + " new_article GET /articles/new(.:format) articles#new\n" << + "edit_article GET /articles/:id/edit(.:format) articles#edit\n" << + " article GET /articles/:id(.:format) articles#show\n" << + " PUT /articles/:id(.:format) articles#update\n" << + " DELETE /articles/:id(.:format) articles#destroy\n" + assert_equal expected, Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_root_route + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + root :to => 'pages#main' + end + RUBY + assert_equal "root / pages#main\n", Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_controller_and_action_only_route + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match ':controller/:action' + end + RUBY + assert_equal " /:controller/:action(.:format) \n", Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_controller_and_action_route_with_constraints + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match ':controller(/:action(/:id))', :id => /\\d+/ + end + RUBY + assert_equal " /:controller(/:action(/:id))(.:format) {:id=>/\\d+/}\n", Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_route_with_defaults + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match 'photos/:id' => 'photos#show', :defaults => {:format => 'jpg'} + end + RUBY + assert_equal %Q[ /photos/:id(.:format) photos#show {:format=>"jpg"}\n], Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_route_with_constraints + app_file "config/routes.rb", <<-RUBY + AppTemplate::Application.routes.draw do + match 'photos/:id' => 'photos#show', :id => /[A-Z]\\d{5}/ + end + RUBY + assert_equal " /photos/:id(.:format) photos#show {:id=>/[A-Z]\\d{5}/}\n", Dir.chdir(app_path){ `rake routes` } + end + + def test_rake_routes_shows_route_with_rack_app + app_file "lib/rack_app.rb", <<-RUBY + class RackApp + class << self + def call(env) + end + end + end + RUBY + + app_file "config/routes.rb", <<-RUBY + require 'rack_app' + + AppTemplate::Application.routes.draw do + match 'foo/:id' => RackApp, :id => /[A-Z]\\d{5}/ + end + RUBY + + assert_equal " /foo/:id(.:format) RackApp {:id=>/[A-Z]\\d{5}/}\n", Dir.chdir(app_path){ `rake routes` } end def test_logger_is_flushed_when_exiting_production_rake_tasks diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb index 597746c4aa..e4a8000425 100644 --- a/railties/test/generators/actions_test.rb +++ b/railties/test/generators/actions_test.rb @@ -109,6 +109,13 @@ class ActionsTest < Rails::Generators::TestCase assert_file 'config/application.rb', /#{Regexp.escape(autoload_paths)}/ end + def test_environment_should_include_data_in_environment_initializer_block_with_env_option + run_generator + autoload_paths = 'config.autoload_paths += %w["#{Rails.root}/app/extras"]' + action :environment, autoload_paths, :env => 'development' + assert_file "config/environments/development.rb", /Application\.configure do\n #{Regexp.escape(autoload_paths)}/ + end + def test_environment_with_block_should_include_block_contents_in_environment_initializer_block run_generator diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb index 81f0bf5e82..fb7ebaa1fa 100644 --- a/railties/test/generators/app_generator_test.rb +++ b/railties/test/generators/app_generator_test.rb @@ -35,6 +35,7 @@ DEFAULT_APP_FILES = %w( vendor/assets vendor/plugins tmp/cache + tmp/cache/assets ) class AppGeneratorTest < Rails::Generators::TestCase diff --git a/railties/test/generators/generated_attribute_test.rb b/railties/test/generators/generated_attribute_test.rb index c9f8ab0a7b..a85829085c 100644 --- a/railties/test/generators/generated_attribute_test.rb +++ b/railties/test/generators/generated_attribute_test.rb @@ -68,6 +68,11 @@ class GeneratedAttributeTest < Rails::Generators::TestCase assert_field_default_value :string, 'MyString' end + def test_default_value_for_type + att = Rails::Generators::GeneratedAttribute.new("type", "string") + assert_equal("", att.default) + end + def test_default_value_is_text assert_field_default_value :text, 'MyText' end diff --git a/railties/test/generators/plugin_new_generator_test.rb b/railties/test/generators/plugin_new_generator_test.rb index 4bd77ff7e3..0ccb2ae9da 100644 --- a/railties/test/generators/plugin_new_generator_test.rb +++ b/railties/test/generators/plugin_new_generator_test.rb @@ -206,7 +206,7 @@ class PluginNewGeneratorTest < Rails::Generators::TestCase def test_creating_gemspec run_generator assert_file "bukkits.gemspec", /s.name = "bukkits"/ - assert_file "bukkits.gemspec", /s.files = Dir\["\{app,config,lib\}\/\*\*\/\*"\]/ + assert_file "bukkits.gemspec", /s.files = Dir\["\{app,config,db,lib\}\/\*\*\/\*"\]/ assert_file "bukkits.gemspec", /s.test_files = Dir\["test\/\*\*\/\*"\]/ assert_file "bukkits.gemspec", /s.version = "0.0.1"/ end |