aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb209
-rw-r--r--actionpack/test/controller/caching_test.rb10
-rw-r--r--actionpack/test/controller/filters_test.rb151
-rw-r--r--actionpack/test/controller/flash_test.rb49
-rw-r--r--actionpack/test/controller/force_ssl_test.rb4
-rw-r--r--actionpack/test/controller/http_basic_authentication_test.rb3
-rw-r--r--actionpack/test/controller/http_digest_authentication_test.rb11
-rw-r--r--actionpack/test/controller/http_token_authentication_test.rb9
-rw-r--r--actionpack/test/controller/integration_test.rb2
-rw-r--r--actionpack/test/controller/redirect_test.rb11
-rw-r--r--actionpack/test/controller/test_case_test.rb41
11 files changed, 115 insertions, 385 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index cbf333c772..5b85e83045 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -5,9 +5,6 @@ class ActionPackAssertionsController < ActionController::Base
def nothing() head :ok end
- def hello_world() render :template => "test/hello_world"; end
- def hello_repeating_in_path() render :template => "test/hello/hello"; end
-
def hello_xml_world() render :template => "test/hello_xml_world"; end
def hello_xml_world_pdf
@@ -20,8 +17,6 @@ class ActionPackAssertionsController < ActionController::Base
render :template => "test/hello_xml_world"
end
- def partial() render :partial => 'test/partial'; end
-
def redirect_internal() redirect_to "/nothing"; end
def redirect_to_action() redirect_to :action => "flash_me", :id => 1, :params => { "panda" => "fun" }; end
@@ -73,16 +68,6 @@ class ActionPackAssertionsController < ActionController::Base
render :text => "Hello!", :content_type => Mime::RSS
end
- def render_with_layout
- @variable_for_layout = nil
- render "test/hello_world", :layout => "layouts/standard"
- end
-
- def render_with_layout_and_partial
- @variable_for_layout = nil
- render "test/hello_world_with_partial", :layout => "layouts/standard"
- end
-
def session_stuffing
session['xmas'] = 'turkey'
render :text => "ho ho ho"
@@ -304,14 +289,6 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
assert session.empty?
end
- def test_render_template_action
- process :nothing
- assert_template nil
-
- process :hello_world
- assert_template 'hello_world'
- end
-
def test_redirection_location
process :redirect_internal
assert_equal 'http://test.host/nothing', @response.redirect_url
@@ -455,192 +432,6 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
end
end
-class AssertTemplateTest < ActionController::TestCase
- tests ActionPackAssertionsController
-
- def test_with_invalid_hash_keys_raises_argument_error
- assert_raise(ArgumentError) do
- assert_template foo: "bar"
- end
- end
-
- def test_with_partial
- get :partial
- assert_template :partial => '_partial'
- end
-
- def test_file_with_absolute_path_success
- get :render_file_absolute_path
- assert_template :file => File.expand_path('../../../README.rdoc', __FILE__)
- end
-
- def test_file_with_relative_path_success
- get :render_file_relative_path
- assert_template :file => 'README.rdoc'
- end
-
- def test_with_file_failure
- get :render_file_absolute_path
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :file => 'test/hello_world'
- end
-
- get :render_file_absolute_path
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template file: nil
- end
- end
-
- def test_with_nil_passes_when_no_template_rendered
- get :nothing
- assert_template nil
- end
-
- def test_with_nil_fails_when_template_rendered
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template nil
- end
- end
-
- def test_with_empty_string_fails_when_template_rendered
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template ""
- end
- end
-
- def test_with_empty_string_fails_when_no_template_rendered
- get :nothing
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template ""
- end
- end
-
- def test_passes_with_correct_string
- get :hello_world
- assert_template 'hello_world'
- assert_template 'test/hello_world'
- end
-
- def test_passes_with_correct_symbol
- get :hello_world
- assert_template :hello_world
- end
-
- def test_fails_with_incorrect_string
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template 'hello_planet'
- end
- end
-
- def test_fails_with_incorrect_string_that_matches
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template 'est/he'
- end
- end
-
- def test_fails_with_repeated_name_in_path
- get :hello_repeating_in_path
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template 'test/hello'
- end
- end
-
- def test_fails_with_incorrect_symbol
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :hello_planet
- end
- end
-
- def test_fails_with_incorrect_symbol_that_matches
- get :hello_world
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :"est/he"
- end
- end
-
- def test_fails_with_wrong_layout
- get :render_with_layout
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :layout => "application"
- end
- end
-
- def test_fails_expecting_no_layout
- get :render_with_layout
- assert_raise(ActiveSupport::TestCase::Assertion) do
- assert_template :layout => nil
- end
- end
-
- def test_fails_expecting_not_known_layout
- get :render_with_layout
- assert_raise(ArgumentError) do
- assert_template :layout => 1
- end
- end
-
- def test_passes_with_correct_layout
- get :render_with_layout
- assert_template :layout => "layouts/standard"
- end
-
- def test_passes_with_layout_and_partial
- get :render_with_layout_and_partial
- assert_template :layout => "layouts/standard"
- end
-
- def test_passed_with_no_layout
- get :hello_world
- assert_template :layout => nil
- end
-
- def test_passed_with_no_layout_false
- get :hello_world
- assert_template :layout => false
- end
-
- def test_passes_with_correct_layout_without_layouts_prefix
- get :render_with_layout
- assert_template :layout => "standard"
- end
-
- def test_passes_with_correct_layout_symbol
- get :render_with_layout
- assert_template :layout => :standard
- end
-
- def test_assert_template_reset_between_requests
- get :hello_world
- assert_template 'test/hello_world'
-
- get :nothing
- assert_template nil
-
- get :partial
- assert_template partial: 'test/_partial'
-
- get :nothing
- assert_template partial: nil
-
- get :render_with_layout
- assert_template layout: 'layouts/standard'
-
- get :nothing
- assert_template layout: nil
-
- get :render_file_relative_path
- assert_template file: 'README.rdoc'
-
- get :nothing
- assert_template file: nil
- end
-end
-
class ActionPackHeaderTest < ActionController::TestCase
tests ActionPackAssertionsController
diff --git a/actionpack/test/controller/caching_test.rb b/actionpack/test/controller/caching_test.rb
index 2d6607041d..de697858c3 100644
--- a/actionpack/test/controller/caching_test.rb
+++ b/actionpack/test/controller/caching_test.rb
@@ -352,6 +352,8 @@ class ViewCacheDependencyTest < ActionController::TestCase
end
class CollectionCacheController < ActionController::Base
+ attr_accessor :partial_rendered_times
+
def index
@customers = [Customer.new('david', params[:id] || 1)]
end
@@ -377,14 +379,15 @@ class AutomaticCollectionCacheTest < ActionController::TestCase
super
@controller = CollectionCacheController.new
@controller.perform_caching = true
- @controller.cache_store = ActiveSupport::Cache::MemoryStore.new
+ @controller.partial_rendered_times = 0
end
def test_collection_fetches_cached_views
get :index
+ assert_equal 1, @controller.partial_rendered_times
- ActionView::PartialRenderer.expects(:collection_with_template).never
get :index
+ assert_equal 1, @controller.partial_rendered_times
end
def test_preserves_order_when_reading_from_cache_plus_rendering
@@ -402,8 +405,9 @@ class AutomaticCollectionCacheTest < ActionController::TestCase
def test_caching_works_with_beginning_comment
get :index_with_comment
+ assert_equal 1, @controller.partial_rendered_times
- ActionView::PartialRenderer.expects(:collection_with_template).never
get :index_with_comment
+ assert_equal 1, @controller.partial_rendered_times
end
end
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index a1ce12a13e..9b0487841f 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -13,16 +13,6 @@ class ActionController::Base
filters.map!(&:raw_filter)
end
end
-
- def assigns(key = nil)
- assigns = {}
- instance_variables.each do |ivar|
- next if ActionController::Base.protected_instance_variables.include?(ivar)
- assigns[ivar[1..-1]] = instance_variable_get(ivar)
- end
-
- key.nil? ? assigns : assigns[key.to_s]
- end
end
class FilterTest < ActionController::TestCase
@@ -560,7 +550,7 @@ class FilterTest < ActionController::TestCase
def test_after_actions_are_not_run_if_around_action_does_not_yield
controller = NonYieldingAroundFilterController.new
test_process(controller, "index")
- assert_equal ["filter_one", "it didn't yield"], controller.assigns['filters']
+ assert_equal ["filter_one", "it didn't yield"], controller.instance_variable_get(:@filters)
end
def test_added_action_to_inheritance_graph
@@ -577,140 +567,141 @@ class FilterTest < ActionController::TestCase
def test_running_actions
test_process(PrependingController)
- assert_equal %w( wonderful_life ensure_login ), assigns["ran_filter"]
+ assert_equal %w( wonderful_life ensure_login ),
+ @controller.instance_variable_get(:@ran_filter)
end
def test_running_actions_with_proc
test_process(ProcController)
- assert assigns["ran_proc_action"]
+ assert @controller.instance_variable_get(:@ran_proc_action)
end
def test_running_actions_with_implicit_proc
test_process(ImplicitProcController)
- assert assigns["ran_proc_action"]
+ assert @controller.instance_variable_get(:@ran_proc_action)
end
def test_running_actions_with_class
test_process(AuditController)
- assert assigns["was_audited"]
+ assert @controller.instance_variable_get(:@was_audited)
end
def test_running_anomolous_yet_valid_condition_actions
test_process(AnomolousYetValidConditionController)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
- assert assigns["ran_class_action"]
- assert assigns["ran_proc_action1"]
- assert assigns["ran_proc_action2"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
+ assert @controller.instance_variable_get(:@ran_class_action)
+ assert @controller.instance_variable_get(:@ran_proc_action1)
+ assert @controller.instance_variable_get(:@ran_proc_action2)
test_process(AnomolousYetValidConditionController, "show_without_action")
- assert_nil assigns["ran_filter"]
- assert !assigns["ran_class_action"]
- assert !assigns["ran_proc_action1"]
- assert !assigns["ran_proc_action2"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
+ assert_not @controller.instance_variable_defined?(:@ran_class_action)
+ assert_not @controller.instance_variable_defined?(:@ran_proc_action1)
+ assert_not @controller.instance_variable_defined?(:@ran_proc_action2)
end
def test_running_conditional_options
test_process(ConditionalOptionsFilter)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
end
def test_running_conditional_skip_options
test_process(ConditionalOptionsSkipFilter)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
end
def test_if_is_ignored_when_used_with_only
test_process(SkipFilterUsingOnlyAndIf, 'login')
- assert_nil assigns['ran_filter']
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_except_is_ignored_when_used_with_if
test_process(SkipFilterUsingIfAndExcept, 'login')
- assert_equal %w(ensure_login), assigns["ran_filter"]
+ assert_equal %w(ensure_login), @controller.instance_variable_get(:@ran_filter)
end
def test_skipping_class_actions
test_process(ClassController)
- assert_equal true, assigns["ran_class_action"]
+ assert_equal true, @controller.instance_variable_get(:@ran_class_action)
skipping_class_controller = Class.new(ClassController) do
skip_before_action ConditionalClassFilter
end
test_process(skipping_class_controller)
- assert_nil assigns['ran_class_action']
+ assert_not @controller.instance_variable_defined?(:@ran_class_action)
end
def test_running_collection_condition_actions
test_process(ConditionalCollectionFilterController)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
test_process(ConditionalCollectionFilterController, "show_without_action")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
test_process(ConditionalCollectionFilterController, "another_action")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_running_only_condition_actions
test_process(OnlyConditionSymController)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
test_process(OnlyConditionSymController, "show_without_action")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
test_process(OnlyConditionProcController)
- assert assigns["ran_proc_action"]
+ assert @controller.instance_variable_get(:@ran_proc_action)
test_process(OnlyConditionProcController, "show_without_action")
- assert !assigns["ran_proc_action"]
+ assert_not @controller.instance_variable_defined?(:@ran_proc_action)
test_process(OnlyConditionClassController)
- assert assigns["ran_class_action"]
+ assert @controller.instance_variable_get(:@ran_class_action)
test_process(OnlyConditionClassController, "show_without_action")
- assert !assigns["ran_class_action"]
+ assert_not @controller.instance_variable_defined?(:@ran_class_action)
end
def test_running_except_condition_actions
test_process(ExceptConditionSymController)
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
test_process(ExceptConditionSymController, "show_without_action")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
test_process(ExceptConditionProcController)
- assert assigns["ran_proc_action"]
+ assert @controller.instance_variable_get(:@ran_proc_action)
test_process(ExceptConditionProcController, "show_without_action")
- assert !assigns["ran_proc_action"]
+ assert_not @controller.instance_variable_defined?(:@ran_proc_action)
test_process(ExceptConditionClassController)
- assert assigns["ran_class_action"]
+ assert @controller.instance_variable_get(:@ran_class_action)
test_process(ExceptConditionClassController, "show_without_action")
- assert !assigns["ran_class_action"]
+ assert_not @controller.instance_variable_defined?(:@ran_class_action)
end
def test_running_only_condition_and_conditional_options
test_process(OnlyConditionalOptionsFilter, "show")
- assert_not assigns["ran_conditional_index_proc"]
+ assert_not @controller.instance_variable_defined?(:@ran_conditional_index_proc)
end
def test_running_before_and_after_condition_actions
test_process(BeforeAndAfterConditionController)
- assert_equal %w( ensure_login clean_up_tmp), assigns["ran_filter"]
+ assert_equal %w( ensure_login clean_up_tmp), @controller.instance_variable_get(:@ran_filter)
test_process(BeforeAndAfterConditionController, "show_without_action")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_around_action
test_process(AroundFilterController)
- assert assigns["before_ran"]
- assert assigns["after_ran"]
+ assert @controller.instance_variable_get(:@before_ran)
+ assert @controller.instance_variable_get(:@after_ran)
end
def test_before_after_class_action
test_process(BeforeAfterClassFilterController)
- assert assigns["before_ran"]
- assert assigns["after_ran"]
+ assert @controller.instance_variable_get(:@before_ran)
+ assert @controller.instance_variable_get(:@after_ran)
end
def test_having_properties_in_around_action
test_process(AroundFilterController)
- assert_equal "before and after", assigns["execution_log"]
+ assert_equal "before and after", @controller.instance_variable_get(:@execution_log)
end
def test_prepending_and_appending_around_action
@@ -723,33 +714,33 @@ class FilterTest < ActionController::TestCase
def test_rendering_breaks_actioning_chain
response = test_process(RenderingController)
assert_equal "something else", response.body
- assert !assigns["ran_action"]
+ assert_not @controller.instance_variable_defined?(:@ran_action)
end
def test_before_action_rendering_breaks_actioning_chain_for_after_action
test_process(RenderingController)
- assert_equal %w( before_action_rendering ), assigns["ran_filter"]
- assert !assigns["ran_action"]
+ assert_equal %w( before_action_rendering ), @controller.instance_variable_get(:@ran_filter)
+ assert_not @controller.instance_variable_defined?(:@ran_action)
end
def test_before_action_redirects_breaks_actioning_chain_for_after_action
test_process(BeforeActionRedirectionController)
assert_response :redirect
assert_equal "http://test.host/filter_test/before_action_redirection/target_of_redirection", redirect_to_url
- assert_equal %w( before_action_redirects ), assigns["ran_filter"]
+ assert_equal %w( before_action_redirects ), @controller.instance_variable_get(:@ran_filter)
end
def test_before_action_rendering_breaks_actioning_chain_for_preprend_after_action
test_process(RenderingForPrependAfterActionController)
- assert_equal %w( before_action_rendering ), assigns["ran_filter"]
- assert !assigns["ran_action"]
+ assert_equal %w( before_action_rendering ), @controller.instance_variable_get(:@ran_filter)
+ assert_not @controller.instance_variable_defined?(:@ran_action)
end
def test_before_action_redirects_breaks_actioning_chain_for_preprend_after_action
test_process(BeforeActionRedirectionForPrependAfterActionController)
assert_response :redirect
assert_equal "http://test.host/filter_test/before_action_redirection_for_prepend_after_action/target_of_redirection", redirect_to_url
- assert_equal %w( before_action_redirects ), assigns["ran_filter"]
+ assert_equal %w( before_action_redirects ), @controller.instance_variable_get(:@ran_filter)
end
def test_actions_with_mixed_specialization_run_in_order
@@ -775,26 +766,26 @@ class FilterTest < ActionController::TestCase
def test_running_prepended_before_and_after_action
test_process(PrependingBeforeAndAfterController)
- assert_equal %w( before_all between_before_all_and_after_all after_all ), assigns["ran_filter"]
+ assert_equal %w( before_all between_before_all_and_after_all after_all ), @controller.instance_variable_get(:@ran_filter)
end
def test_skipping_and_limiting_controller
test_process(SkippingAndLimitedController, "index")
- assert_equal %w( ensure_login ), assigns["ran_filter"]
+ assert_equal %w( ensure_login ), @controller.instance_variable_get(:@ran_filter)
test_process(SkippingAndLimitedController, "public")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_skipping_and_reordering_controller
test_process(SkippingAndReorderingController, "index")
- assert_equal %w( find_record ensure_login ), assigns["ran_filter"]
+ assert_equal %w( find_record ensure_login ), @controller.instance_variable_get(:@ran_filter)
end
def test_conditional_skipping_of_actions
test_process(ConditionalSkippingController, "login")
- assert_nil assigns["ran_filter"]
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
test_process(ConditionalSkippingController, "change_password")
- assert_equal %w( ensure_login find_user ), assigns["ran_filter"]
+ assert_equal %w( ensure_login find_user ), @controller.instance_variable_get(:@ran_filter)
test_process(ConditionalSkippingController, "login")
assert !@controller.instance_variable_defined?("@ran_after_action")
@@ -804,23 +795,23 @@ class FilterTest < ActionController::TestCase
def test_conditional_skipping_of_actions_when_parent_action_is_also_conditional
test_process(ChildOfConditionalParentController)
- assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), assigns['ran_filter']
+ assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), @controller.instance_variable_get(:@ran_filter)
test_process(ChildOfConditionalParentController, 'another_action')
- assert_nil assigns['ran_filter']
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_condition_skipping_of_actions_when_siblings_also_have_conditions
test_process(ChildOfConditionalParentController)
- assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), assigns['ran_filter']
+ assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), @controller.instance_variable_get(:@ran_filter)
test_process(AnotherChildOfConditionalParentController)
- assert_equal %w( conditional_in_parent_after ), assigns['ran_filter']
+ assert_equal %w( conditional_in_parent_after ), @controller.instance_variable_get(:@ran_filter)
test_process(ChildOfConditionalParentController)
- assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), assigns['ran_filter']
+ assert_equal %w( conditional_in_parent_before conditional_in_parent_after ), @controller.instance_variable_get(:@ran_filter)
end
def test_changing_the_requirements
test_process(ChangingTheRequirementsController, "go_wild")
- assert_nil assigns['ran_filter']
+ assert_not @controller.instance_variable_defined?(:@ran_filter)
end
def test_a_rescuing_around_action
@@ -835,13 +826,13 @@ class FilterTest < ActionController::TestCase
def test_actions_obey_only_and_except_for_implicit_actions
test_process(ImplicitActionsController, 'show')
- assert_equal 'Except', assigns(:except)
- assert_nil assigns(:only)
+ assert_equal 'Except', @controller.instance_variable_get(:@except)
+ assert_not @controller.instance_variable_defined?(:@only)
assert_equal 'show', response.body
test_process(ImplicitActionsController, 'edit')
- assert_equal 'Only', assigns(:only)
- assert_nil assigns(:except)
+ assert_equal 'Only', @controller.instance_variable_get(:@only)
+ assert_not @controller.instance_variable_defined?(:@except)
assert_equal 'edit', response.body
end
@@ -1010,8 +1001,8 @@ class YieldingAroundFiltersTest < ActionController::TestCase
def test_with_proc
test_process(ControllerWithProcFilter,'no_raise')
- assert assigns['before']
- assert assigns['after']
+ assert @controller.instance_variable_get(:@before)
+ assert @controller.instance_variable_get(:@after)
end
def test_nested_actions
@@ -1032,12 +1023,12 @@ class YieldingAroundFiltersTest < ActionController::TestCase
def test_action_order_with_all_action_types
test_process(ControllerWithAllTypesOfFilters,'no_raise')
- assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', assigns['ran_filter'].join(' ')
+ assert_equal 'before around (before yield) around_again (before yield) around_again (after yield) after around (after yield)', @controller.instance_variable_get(:@ran_filter).join(' ')
end
def test_action_order_with_skip_action_method
test_process(ControllerWithTwoLessFilters,'no_raise')
- assert_equal 'before around (before yield) around (after yield)', assigns['ran_filter'].join(' ')
+ assert_equal 'before around (before yield) around (after yield)', @controller.instance_variable_get(:@ran_filter).join(' ')
end
def test_first_action_in_multiple_before_action_chain_halts
@@ -1063,7 +1054,7 @@ class YieldingAroundFiltersTest < ActionController::TestCase
def test_skipping_with_skip_action_callback
test_process(SkipFilterUsingSkipActionCallback,'no_raise')
- assert_equal 'before around (before yield) around (after yield)', assigns['ran_filter'].join(' ')
+ assert_equal 'before around (before yield) around (after yield)', @controller.instance_variable_get(:@ran_filter).join(' ')
end
def test_deprecated_skip_action_callback
diff --git a/actionpack/test/controller/flash_test.rb b/actionpack/test/controller/flash_test.rb
index 60a000c160..64543f0659 100644
--- a/actionpack/test/controller/flash_test.rb
+++ b/actionpack/test/controller/flash_test.rb
@@ -103,54 +103,55 @@ class FlashTest < ActionController::TestCase
get :set_flash
get :use_flash
- assert_equal "hello", assigns["flash_copy"]["that"]
- assert_equal "hello", assigns["flashy"]
+ assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"]
+ assert_equal "hello", @controller.instance_variable_get(:@flashy)
get :use_flash
- assert_nil assigns["flash_copy"]["that"], "On second flash"
+ assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On second flash"
end
def test_keep_flash
get :set_flash
get :use_flash_and_keep_it
- assert_equal "hello", assigns["flash_copy"]["that"]
- assert_equal "hello", assigns["flashy"]
+ assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"]
+ assert_equal "hello", @controller.instance_variable_get(:@flashy)
get :use_flash
- assert_equal "hello", assigns["flash_copy"]["that"], "On second flash"
+ assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"], "On second flash"
get :use_flash
- assert_nil assigns["flash_copy"]["that"], "On third flash"
+ assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On third flash"
end
def test_flash_now
get :set_flash_now
- assert_equal "hello", assigns["flash_copy"]["that"]
- assert_equal "bar" , assigns["flash_copy"]["foo"]
- assert_equal "hello", assigns["flashy"]
+ assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"]
+ assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"]
+ assert_equal "hello", @controller.instance_variable_get(:@flashy)
get :attempt_to_use_flash_now
- assert_nil assigns["flash_copy"]["that"]
- assert_nil assigns["flash_copy"]["foo"]
- assert_nil assigns["flashy"]
+ assert_nil @controller.instance_variable_get(:@flash_copy)["that"]
+ assert_nil @controller.instance_variable_get(:@flash_copy)["foo"]
+ assert_nil @controller.instance_variable_get(:@flashy)
end
def test_update_flash
get :set_flash
get :use_flash_and_update_it
- assert_equal "hello", assigns["flash_copy"]["that"]
- assert_equal "hello again", assigns["flash_copy"]["this"]
+ assert_equal "hello", @controller.instance_variable_get(:@flash_copy)["that"]
+ assert_equal "hello again", @controller.instance_variable_get(:@flash_copy)["this"]
get :use_flash
- assert_nil assigns["flash_copy"]["that"], "On second flash"
- assert_equal "hello again", assigns["flash_copy"]["this"], "On second flash"
+ assert_nil @controller.instance_variable_get(:@flash_copy)["that"], "On second flash"
+ assert_equal "hello again",
+ @controller.instance_variable_get(:@flash_copy)["this"], "On second flash"
end
def test_flash_after_reset_session
get :use_flash_after_reset_session
- assert_equal "hello", assigns["flashy_that"]
- assert_equal "good-bye", assigns["flashy_this"]
- assert_nil assigns["flashy_that_reset"]
+ assert_equal "hello", @controller.instance_variable_get(:@flashy_that)
+ assert_equal "good-bye", @controller.instance_variable_get(:@flashy_this)
+ assert_nil @controller.instance_variable_get(:@flashy_that_reset)
end
def test_does_not_set_the_session_if_the_flash_is_empty
@@ -160,13 +161,13 @@ class FlashTest < ActionController::TestCase
def test_sweep_after_halted_action_chain
get :std_action
- assert_nil assigns["flash_copy"]["foo"]
+ assert_nil @controller.instance_variable_get(:@flash_copy)["foo"]
get :filter_halting_action
- assert_equal "bar", assigns["flash_copy"]["foo"]
+ assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"]
get :std_action # follow redirection
- assert_equal "bar", assigns["flash_copy"]["foo"]
+ assert_equal "bar", @controller.instance_variable_get(:@flash_copy)["foo"]
get :std_action
- assert_nil assigns["flash_copy"]["foo"]
+ assert_nil @controller.instance_variable_get(:@flash_copy)["foo"]
end
def test_keep_and_discard_return_values
diff --git a/actionpack/test/controller/force_ssl_test.rb b/actionpack/test/controller/force_ssl_test.rb
index 5639abdc56..72ae30eb39 100644
--- a/actionpack/test/controller/force_ssl_test.rb
+++ b/actionpack/test/controller/force_ssl_test.rb
@@ -240,8 +240,8 @@ class ForceSSLFlashTest < ActionController::TestCase
@request.env.delete('PATH_INFO')
get :use_flash
- assert_equal "hello", assigns["flash_copy"]["that"]
- assert_equal "hello", assigns["flashy"]
+ assert_equal "hello", @controller.instance_variable_get("@flash_copy")["that"]
+ assert_equal "hello", @controller.instance_variable_get("@flashy")
end
end
diff --git a/actionpack/test/controller/http_basic_authentication_test.rb b/actionpack/test/controller/http_basic_authentication_test.rb
index 10fbee7582..adaf19c2dc 100644
--- a/actionpack/test/controller/http_basic_authentication_test.rb
+++ b/actionpack/test/controller/http_basic_authentication_test.rb
@@ -13,7 +13,7 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
end
def display
- render :text => 'Definitely Maybe'
+ render :text => 'Definitely Maybe' if @logged_in
end
def show
@@ -122,7 +122,6 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb
index 52a0bc9aa3..57964769a7 100644
--- a/actionpack/test/controller/http_digest_authentication_test.rb
+++ b/actionpack/test/controller/http_digest_authentication_test.rb
@@ -14,7 +14,7 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
end
def display
- render :text => 'Definitely Maybe'
+ render :text => 'Definitely Maybe' if @logged_in
end
private
@@ -124,7 +124,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -134,7 +133,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -144,7 +142,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -156,7 +153,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -167,7 +163,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -180,7 +175,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -191,7 +185,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -201,7 +194,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
put :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
@@ -244,7 +236,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
get :display
assert_response :success
- assert assigns(:logged_in)
assert_equal 'Definitely Maybe', @response.body
end
diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb
index 2521f0322c..802c17b6bf 100644
--- a/actionpack/test/controller/http_token_authentication_test.rb
+++ b/actionpack/test/controller/http_token_authentication_test.rb
@@ -80,13 +80,20 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
end
test "authentication request with badly formatted header" do
- @request.env['HTTP_AUTHORIZATION'] = "Token foobar"
+ @request.env['HTTP_AUTHORIZATION'] = 'Token token$"lifo"'
get :index
assert_response :unauthorized
assert_equal "HTTP Token: Access denied.\n", @response.body, "Authentication header was not properly parsed"
end
+ test "successful authentication request with Bearer instead of Token" do
+ @request.env['HTTP_AUTHORIZATION'] = 'Bearer lifo'
+ get :index
+
+ assert_response :success
+ end
+
test "authentication request without credential" do
get :display
diff --git a/actionpack/test/controller/integration_test.rb b/actionpack/test/controller/integration_test.rb
index a87059bee4..a6460168cb 100644
--- a/actionpack/test/controller/integration_test.rb
+++ b/actionpack/test/controller/integration_test.rb
@@ -315,8 +315,6 @@ class IntegrationTestTest < ActiveSupport::TestCase
session1 = @test.open_session { |sess| }
session2 = @test.open_session # implicit session
- assert_respond_to session1, :assert_template, "open_session makes assert_template available"
- assert_respond_to session2, :assert_template, "open_session makes assert_template available"
assert !session1.equal?(session2)
end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index ef30f1ea0f..4f5ca46b04 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -50,11 +50,6 @@ class RedirectController < ActionController::Base
redirect_to :controller => 'module_test/module_redirect', :action => "hello_world"
end
- def redirect_with_assigns
- @hello = "world"
- redirect_to :action => "hello_world"
- end
-
def redirect_to_url
redirect_to "http://www.rubyonrails.org/"
end
@@ -215,12 +210,6 @@ class RedirectTest < ActionController::TestCase
assert_redirected_to :controller => 'module_test/module_redirect', :action => 'hello_world'
end
- def test_redirect_with_assigns
- get :redirect_with_assigns
- assert_response :redirect
- assert_equal "world", assigns["hello"]
- end
-
def test_redirect_to_url
get :redirect_to_url
assert_response :redirect
diff --git a/actionpack/test/controller/test_case_test.rb b/actionpack/test/controller/test_case_test.rb
index fbfc891d19..86ffb898ad 100644
--- a/actionpack/test/controller/test_case_test.rb
+++ b/actionpack/test/controller/test_case_test.rb
@@ -140,12 +140,6 @@ XML
head :ok
end
- def test_assigns
- @foo = "foo"
- @foo_hash = { foo: :bar }
- head :ok
- end
-
def test_without_body
render html: '<div class="foo"></div>'.html_safe
end
@@ -174,17 +168,6 @@ XML
end
end
- class ViewAssignsController < ActionController::Base
- def test_assigns
- @foo = "foo"
- head :ok
- end
-
- def view_assigns
- { "bar" => "bar" }
- end
- end
-
class DefaultUrlOptionsCachingController < ActionController::Base
before_action { @dynamic_opt = 'opt' }
@@ -446,30 +429,6 @@ XML
assert_equal "OK", @response.body
end
- def test_assigns
- process :test_assigns
- # assigns can be accessed using assigns(key)
- # or assigns[key], where key is a string or
- # a symbol
- assert_equal "foo", assigns(:foo)
- assert_equal "foo", assigns("foo")
- assert_equal "foo", assigns[:foo]
- assert_equal "foo", assigns["foo"]
-
- # but the assigned variable should not have its own keys stringified
- expected_hash = { foo: :bar }
- assert_equal expected_hash, assigns(:foo_hash)
- end
-
- def test_view_assigns
- @controller = ViewAssignsController.new
- process :test_assigns
- assert_equal nil, assigns(:foo)
- assert_equal nil, assigns[:foo]
- assert_equal "bar", assigns(:bar)
- assert_equal "bar", assigns[:bar]
- end
-
def test_should_not_impose_childless_html_tags_in_xml
process :test_xml_output