Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate use of @logger and @action_name instance variables inside views. Please use instance methods logger and action_name instead.
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require File.dirname(__FILE__) + '/../abstract_unit' | ||
|
||
class DeprecateIvars < ActionController::Base | ||
def use_logger | ||
render :inline => "<%= logger.class -%>" | ||
end | ||
|
||
def use_old_logger | ||
render :inline => "<%= @logger.class -%>" | ||
end | ||
|
||
def use_action_name | ||
render :inline => "<%= action_name -%>" | ||
end | ||
|
||
def use_old_action_name | ||
render :inline => "<%= @action_name -%>" | ||
end | ||
end | ||
|
||
class DeprecateIvarsTest < Test::Unit::TestCase | ||
def setup | ||
@request = ActionController::TestRequest.new | ||
@response = ActionController::TestResponse.new | ||
|
||
@controller = DeprecateIvars.new | ||
@controller.logger = Logger.new(nil) | ||
|
||
@request.host = "rubyonrails.com" | ||
end | ||
|
||
def test_logger | ||
assert_not_deprecated { get :use_logger } | ||
assert_equal "Logger", @response.body | ||
end | ||
|
||
def test_deprecated_logger | ||
assert_deprecated { get :use_old_logger } | ||
assert_equal "Logger", @response.body | ||
end | ||
|
||
def test_action_name | ||
assert_not_deprecated { get :use_action_name } | ||
assert_equal "use_action_name", @response.body | ||
end | ||
|
||
def test_deprecated_action_name | ||
assert_deprecated { get :use_old_action_name } | ||
assert_equal "use_old_action_name", @response.body | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters