Skip to content

Commit

Permalink
Add some deprecations for logic being removed in 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Jan 17, 2012
1 parent 57f73a6 commit 20baeec
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
17 changes: 15 additions & 2 deletions actionpack/lib/action_controller/metal/compatibility.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/deprecation'

module ActionController module ActionController
module Compatibility module Compatibility
extend ActiveSupport::Concern extend ActiveSupport::Concern
Expand All @@ -24,13 +26,19 @@ class << self
) )


def rescue_action(env) def rescue_action(env)
ActiveSupport::Deprecation.warn "Calling `rescue_action` is deprecated and will be removed in Rails 4.0.", caller
raise env["action_dispatch.rescue.exception"] raise env["action_dispatch.rescue.exception"]
end end
end end


# For old tests # For old tests
def initialize_template_class(*) end def initialize_template_class(*)
def assign_shortcuts(*) end ActiveSupport::Deprecation.warn "Calling `initialize_template_class` is deprecated and has no effect anymore.", caller
end

def assign_shortcuts(*)
ActiveSupport::Deprecation.warn "Calling `assign_shortcuts` is deprecated and has no effect anymore.", caller
end


def _normalize_options(options) def _normalize_options(options)
options[:text] = nil if options.delete(:nothing) == true options[:text] = nil if options.delete(:nothing) == true
Expand All @@ -44,6 +52,9 @@ def render_to_body(options)
end end


def _handle_method_missing def _handle_method_missing
ActiveSupport::Deprecation.warn "Using `method_missing` to handle non" \
" existing actions is deprecated and will be removed in Rails 4.0, " \
" please use `action_missing` instead.", caller
method_missing(@_action_name.to_sym) method_missing(@_action_name.to_sym)
end end


Expand All @@ -52,6 +63,8 @@ def method_for_action(action_name)
end end


def performed? def performed?
ActiveSupport::Deprecation.warn "Calling `performed?` is deprecated and will " \
"be removed in Rails 4.0. Please check for `response_body` presence instead.", caller
response_body response_body
end end
end end
Expand Down
12 changes: 9 additions & 3 deletions actionpack/test/controller/base_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ def test_process_should_be_precise


def test_get_on_priv_should_show_selector def test_get_on_priv_should_show_selector
use_controller MethodMissingController use_controller MethodMissingController
get :shouldnt_be_called assert_deprecated /Using `method_missing` to handle .* use `action_missing` instead/ do
get :shouldnt_be_called
end
assert_response :success assert_response :success
assert_equal 'shouldnt_be_called', @response.body assert_equal 'shouldnt_be_called', @response.body
end end
Expand All @@ -170,14 +172,18 @@ def test_method_missing_is_not_an_action_name
use_controller MethodMissingController use_controller MethodMissingController
assert !@controller.__send__(:action_method?, 'method_missing') assert !@controller.__send__(:action_method?, 'method_missing')


get :method_missing assert_deprecated /Using `method_missing` to handle .* use `action_missing` instead/ do
get :method_missing
end
assert_response :success assert_response :success
assert_equal 'method_missing', @response.body assert_equal 'method_missing', @response.body
end end


def test_method_missing_should_recieve_symbol def test_method_missing_should_recieve_symbol
use_controller AnotherMethodMissingController use_controller AnotherMethodMissingController
get :some_action assert_deprecated /Using `method_missing` to handle .* use `action_missing` instead/ do
get :some_action
end
assert_kind_of NameError, @controller._exception assert_kind_of NameError, @controller._exception
end end


Expand Down
2 changes: 0 additions & 2 deletions actionpack/test/controller/caching_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -686,8 +686,6 @@ def setup
@controller.params = @params @controller.params = @params
@controller.request = @request @controller.request = @request
@controller.response = @response @controller.response = @response
@controller.send(:initialize_template_class, @response)
@controller.send(:assign_shortcuts, @request, @response)
end end


def test_fragment_cache_key def test_fragment_cache_key
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/render_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def conditional_hello


def conditional_hello_with_record def conditional_hello_with_record
record = Struct.new(:updated_at, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123") record = Struct.new(:updated_at, :cache_key).new(Time.now.utc.beginning_of_day, "foo/123")

if stale?(record) if stale?(record)
render :action => 'hello_world' render :action => 'hello_world'
end end
Expand Down
7 changes: 0 additions & 7 deletions actionpack/test/controller/view_paths_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,16 +22,9 @@ def hello_world; render(:template => 'test/hello_world'); end
end end


def setup def setup
# TestController.view_paths = nil

@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new

@controller = TestController.new @controller = TestController.new
# Following is needed in order to setup @controller.template object properly
@controller.send :assign_shortcuts, @request, @response
@controller.send :initialize_template_class, @response

@paths = TestController.view_paths @paths = TestController.view_paths
end end


Expand Down

0 comments on commit 20baeec

Please sign in to comment.