diff options
author | Xavier Noria <fxn@hashref.com> | 2010-06-10 22:00:55 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-06-10 22:00:55 +0200 |
commit | 63560660062d552d6bbebec007154f0c639bf865 (patch) | |
tree | 0ff7ee5c1a63815685e9640ca4a9ceafb7732178 /actionpack/test | |
parent | 59e89facc2264322bcab59c9a8622380b62d4d40 (diff) | |
parent | 61fc7a455099f179de88967f403f2038b9d3c821 (diff) | |
download | rails-63560660062d552d6bbebec007154f0c639bf865.tar.gz rails-63560660062d552d6bbebec007154f0c639bf865.tar.bz2 rails-63560660062d552d6bbebec007154f0c639bf865.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/abstract_unit.rb | 3 | ||||
-rw-r--r-- | actionpack/test/controller/base_test.rb | 11 | ||||
-rw-r--r-- | actionpack/test/controller/filters_test.rb | 17 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 61 | ||||
-rw-r--r-- | actionpack/test/template/body_parts_test.rb | 25 | ||||
-rw-r--r-- | actionpack/test/template/test_case_test.rb | 4 | ||||
-rw-r--r-- | actionpack/test/template/text_helper_test.rb | 108 |
7 files changed, 56 insertions, 173 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index d2e5d2e965..84c5395610 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -24,6 +24,9 @@ require 'action_view/testing/resolvers' require 'action_dispatch' require 'active_support/dependencies' require 'active_model' +require 'active_record' +require 'action_controller/caching' +require 'action_controller/caching/sweeping' begin require 'ruby-debug' diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb index 49f79681f6..4f58b5d968 100644 --- a/actionpack/test/controller/base_test.rb +++ b/actionpack/test/controller/base_test.rb @@ -90,6 +90,7 @@ class RecordIdentifierController < ActionController::Base end class ControllerClassTests < ActiveSupport::TestCase + def test_controller_path assert_equal 'empty', EmptyController.controller_path assert_equal EmptyController.controller_path, EmptyController.new.controller_path @@ -166,7 +167,15 @@ class PerformActionTest < ActionController::TestCase rescue_action_in_public! end - + + def test_process_should_be_precise + use_controller EmptyController + exception = assert_raise AbstractController::ActionNotFound do + get :non_existent + end + assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController" + end + def test_get_on_priv_should_show_selector use_controller MethodMissingController get :shouldnt_be_called diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb index d5704eba78..14f1bd797a 100644 --- a/actionpack/test/controller/filters_test.rb +++ b/actionpack/test/controller/filters_test.rb @@ -445,6 +445,23 @@ class FilterTest < ActionController::TestCase end + class ::AppSweeper < ActionController::Caching::Sweeper; end + class SweeperTestController < ActionController::Base + cache_sweeper :app_sweeper + def show + render :text => 'hello world' + end + end + def test_sweeper_should_not_block_rendering + response = test_process(SweeperTestController) + assert_equal 'hello world', response.body + end + + def test_before_method_of_sweeper_should_always_return_true + sweeper = ActionController::Caching::Sweeper.send(:new) + assert sweeper.before(TestController.new) + end + def test_non_yielding_around_filters_not_returning_false_do_not_raise controller = NonYieldingAroundFilterController.new controller.instance_variable_set "@filter_return_value", true diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index a294535e88..e13960e0dc 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -34,33 +34,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end - resources :users do - shallow do - resources :photos do - resources :types do - member do - post :preview - end - collection do - delete :erase - end - end - end - end - end - - shallow do - resources :teams do - resources :players - end - - resources :countries do - resources :cities do - resources :places - end - end - end - match 'account/logout' => redirect("/logout"), :as => :logout_redirect match 'account/login', :to => redirect("/login") @@ -171,6 +144,16 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest resources :sheep + resources :clients do + namespace :google do + resource :account do + namespace :secret do + resource :info + end + end + end + end + match 'sprockets.js' => ::TestRoutingMapper::SprocketsApp match 'people/:id/update', :to => 'people#update', :as => :update_person @@ -779,18 +762,6 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest end end - def test_shallow_routes - with_test_routes do - assert_equal '/photos/4', photo_path(4) - assert_equal '/types/10/edit', edit_type_path(10) - assert_equal '/types/5/preview', preview_type_path(5) - assert_equal '/photos/2/types', photo_types_path(2) - assert_equal '/cities/1/places', url_for(:controller => :places, :action => :index, :city_id => 1, :only_path => true) - assert_equal '/teams/new', url_for(:controller => :teams, :action => :new, :only_path => true) - assert_equal '/photos/11/types/erase', url_for(:controller => :types, :action => :erase, :photo_id => 11, :only_path => true) - end - end - def test_update_project_person with_test_routes do get '/projects/1/people/2/update' @@ -852,6 +823,18 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest assert_equal '/account/admin/subscription', account_admin_subscription_path end end + + def test_namespace_nested_in_resources + with_test_routes do + get '/clients/1/google/account' + assert_equal '/clients/1/google/account', client_google_account_path(1) + assert_equal 'google/accounts#show', @response.body + + get '/clients/1/google/account/secret/info' + assert_equal '/clients/1/google/account/secret/info', client_google_account_secret_info_path(1) + assert_equal 'google/secret/infos#show', @response.body + end + end def test_articles_with_id with_test_routes do diff --git a/actionpack/test/template/body_parts_test.rb b/actionpack/test/template/body_parts_test.rb deleted file mode 100644 index 69cf684083..0000000000 --- a/actionpack/test/template/body_parts_test.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'abstract_unit' - -class BodyPartsTest < ActionController::TestCase - RENDERINGS = [Object.new, Object.new, Object.new] - - class TestController < ActionController::Base - def response_body() "" end - - def index - RENDERINGS.each do |rendering| - view_context.punctuate_body! rendering - end - end - end - - tests TestController - - def test_body_parts - get :index - # TestProcess buffers body_parts into body - # TODO: Rewrite test w/o going through process - assert_equal RENDERINGS, @response.body_parts - assert_equal RENDERINGS.join, @response.body - end -end diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index 16e5ee4f72..9b50ea8a42 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -37,6 +37,10 @@ module ActionView include SharedTests test_case = self + test "memoizes the _view" do + assert_same _view, _view + end + test "works without testing a helper module" do assert_equal 'Eloy', render('developers/developer', :developer => stub(:name => 'Eloy')) end diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb index 64f1d46413..17fc8b6edd 100644 --- a/actionpack/test/template/text_helper_test.rb +++ b/actionpack/test/template/text_helper_test.rb @@ -1,17 +1,6 @@ # encoding: us-ascii require 'abstract_unit' require 'testing_sandbox' -begin - require 'redcloth' -rescue LoadError - $stderr.puts "Skipping textilize tests. `gem install RedCloth` to enable." -end - -begin - require 'bluecloth' -rescue LoadError - $stderr.puts "Skipping markdown tests. 'gem install bluecloth' to enable." -end class TextHelperTest < ActionView::TestCase tests ActionView::Helpers::TextHelper @@ -665,101 +654,4 @@ class TextHelperTest < ActionView::TestCase assert_equal("red", cycle("red", "blue")) assert_equal(%w{Specialized Fuji Giant}, @cycles) end - - # TODO test textilize_without_paragraph and markdown - if defined? RedCloth - def test_textilize_should_be_html_safe - assert textilize("*This is Textile!* Rejoice!").html_safe? - end - - def test_textilize - assert_equal("<p><strong>This is Textile!</strong> Rejoice!</p>", textilize("*This is Textile!* Rejoice!")) - end - - def test_textilize_with_blank - assert_equal("", textilize("")) - end - - def test_textilize_with_options - assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong>", :filter_html)) - end - - def test_textilize_should_sanitize_unsafe_input - assert_equal("<p>This is worded <strong>strongly</strong></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>")) - end - - def test_textilize_should_not_sanitize_input_if_safe_option - assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>", :safe)) - end - - def test_textilize_should_not_sanitize_safe_input - assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", textilize("This is worded <strong>strongly</strong><script>code!</script>".html_safe)) - end - - def test_textilize_with_hard_breaks - assert_equal("<p>This is one scary world.<br />\n True.</p>", textilize("This is one scary world.\n True.")) - end - - def test_textilize_without_paragraph_should_be_html_safe - textilize_without_paragraph("*This is Textile!* Rejoice!").html_safe? - end - - def test_textilize_without_paragraph - assert_equal("<strong>This is Textile!</strong> Rejoice!", textilize_without_paragraph("*This is Textile!* Rejoice!")) - end - - def test_textilize_without_paragraph_with_blank - assert_equal("", textilize_without_paragraph("")) - end - - def test_textilize_without_paragraph_with_options - assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong>", :filter_html)) - end - - def test_textilize_without_paragraph_should_sanitize_unsafe_input - assert_equal("This is worded <strong>strongly</strong>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>")) - end - - def test_textilize_without_paragraph_should_not_sanitize_input_if_safe_option - assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>", :safe)) - end - - def test_textilize_without_paragraph_should_not_sanitize_safe_input - assert_equal("This is worded <strong>strongly</strong><script>code!</script>", textilize_without_paragraph("This is worded <strong>strongly</strong><script>code!</script>".html_safe)) - end - - def test_textilize_without_paragraph_with_hard_breaks - assert_equal("This is one scary world.<br />\n True.", textilize_without_paragraph("This is one scary world.\n True.")) - end - end - - if defined? BlueCloth - def test_markdown_should_be_html_safe - assert markdown("We are using __Markdown__ now!").html_safe? - end - - def test_markdown - assert_equal("<p>We are using <strong>Markdown</strong> now!</p>", markdown("We are using __Markdown__ now!")) - end - - def test_markdown_with_blank - assert_equal("", markdown("")) - end - - def test_markdown_should_sanitize_unsafe_input - assert_equal("<p>This is worded <strong>strongly</strong></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>")) - end - - def test_markdown_should_not_sanitize_input_if_safe_option - assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>", :safe)) - end - - def test_markdown_should_not_sanitize_safe_input - assert_equal("<p>This is worded <strong>strongly</strong><script>code!</script></p>", markdown("This is worded <strong>strongly</strong><script>code!</script>".html_safe)) - end - - def test_markdown_with_hard_breaks - assert_equal("<p>This is one scary world.</p>\n\n<p>True.</p>", markdown("This is one scary world.\n\nTrue.")) - end - end end |