Changeset 1837
- Timestamp:
- 07/15/05 15:00:39 (3 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/assertions.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/fake_controllers.rb (added)
- trunk/actionpack/test/controller/routing_test.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/test_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r1835 r1837 1 1 *SVN* 2 3 * Fixed assert_routing so that testing controllers in modules works as expected [Nicholas Seckar, Rick Olson] 2 4 3 5 * Fixed bug with :success/:failure callbacks for the JavaScriptHelper methods #1730 [court3nay/Thomas Fuchs] trunk/actionpack/lib/action_controller/assertions.rb
r1661 r1837 139 139 ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty? 140 140 141 # Assume given controller 142 request = ActionController::TestRequest.new({}, {}, nil) 143 request.path_parameters = (defaults or {}).clone 144 request.path_parameters[:controller] ||= options[:controller] 145 146 generated_path, found_extras = ActionController::Routing::Routes.generate(options, request) 141 generated_path, found_extras = ActionController::Routing::Routes.generate(options, extras) 147 142 msg = build_message(message, "found extras <?>, not <?>", found_extras, extras) 148 143 assert_block(msg) { found_extras == extras } … … 157 152 def assert_routing(path, options, defaults={}, extras={}, message=nil) 158 153 assert_recognizes(options, path, extras, message) 154 155 controller, default_controller = options[:controller], defaults[:controller] 156 if controller && controller.include?(?/) && default_controller && default_controller.include?(?/) 157 options[:controller] = "/#{controller}" 158 end 159 159 160 assert_generates(path, options, defaults, extras, message) 160 161 end trunk/actionpack/test/controller/routing_test.rb
r1834 r1837 1 1 require File.dirname(__FILE__) + '/../abstract_unit' 2 require File.dirname(__FILE__) + '/fake_controllers' 2 3 require 'test/unit' 3 4 require 'stringio' … … 94 95 end 95 96 end 96 97 # XXX Extract to test/controller/fake_controllers.rb98 module Object::Controllers99 def self.const_available?(*args)100 const_defined?(*args)101 end102 103 class ContentController104 end105 module Admin106 def self.const_available?(*args)107 const_defined?(*args)108 end109 110 class UserController111 end112 113 class NewsFeedController114 end115 end116 end117 118 97 119 98 class RecognitionTests < Test::Unit::TestCase trunk/actionpack/test/controller/test_test.rb
r1763 r1837 1 1 require File.dirname(__FILE__) + '/../abstract_unit' 2 require File.dirname(__FILE__) + '/fake_controllers' 2 3 3 4 class TestTest < Test::Unit::TestCase … … 53 54 def test_process_without_flash 54 55 process :set_flash 55 assert_ flash_equal "><", "test"56 assert_equal '><', flash['test'] 56 57 end 57 58 58 59 def test_process_with_flash 59 60 process :set_flash, nil, nil, { "test" => "value" } 60 assert_ flash_equal ">value<", "test"61 assert_equal '>value<', flash['test'] 61 62 end 62 63 … … 101 102 end 102 103 104 def test_assert_generates 105 assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5' 106 end 107 103 108 def test_assert_routing 104 assert_generates 'controller/action/5', :controller => 'controller', :action => 'action', :id => '5' 109 assert_routing 'content', :controller => 'content', :action => 'index' 110 end 111 112 def test_assert_routing_in_module 113 assert_routing 'admin/user', :controller => 'admin/user', :action => 'index' 105 114 end 106 115