TeX and CSS tweaks.
Sync with latest Instiki Trunk (Updates Rails to 1.2.2)
This commit is contained in:
parent
0ac586ee25
commit
c358389f25
443 changed files with 24218 additions and 9823 deletions
|
@ -12,6 +12,7 @@ module Submodule
|
|||
|
||||
hide_action :hidden_action
|
||||
def hidden_action
|
||||
raise "Noooo!"
|
||||
end
|
||||
|
||||
def another_hidden_action
|
||||
|
@ -23,7 +24,6 @@ module Submodule
|
|||
end
|
||||
end
|
||||
class EmptyController < ActionController::Base
|
||||
include ActionController::Caching
|
||||
end
|
||||
class NonEmptyController < ActionController::Base
|
||||
def public_action
|
||||
|
@ -34,10 +34,27 @@ class NonEmptyController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
class MethodMissingController < ActionController::Base
|
||||
|
||||
hide_action :shouldnt_be_called
|
||||
def shouldnt_be_called
|
||||
raise "NO WAY!"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def method_missing(selector)
|
||||
render :text => selector.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class ControllerClassTests < Test::Unit::TestCase
|
||||
def test_controller_path
|
||||
assert_equal 'empty', EmptyController.controller_path
|
||||
assert_equal EmptyController.controller_path, EmptyController.new.controller_path
|
||||
assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path
|
||||
assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path
|
||||
end
|
||||
def test_controller_name
|
||||
assert_equal 'empty', EmptyController.controller_name
|
||||
|
@ -57,10 +74,63 @@ class ControllerInstanceTests < Test::Unit::TestCase
|
|||
|
||||
def test_action_methods
|
||||
@empty_controllers.each do |c|
|
||||
assert_equal Set.new, c.send(:action_methods), "#{c.class.controller_path} should be empty!"
|
||||
hide_mocha_methods_from_controller(c)
|
||||
assert_equal Set.new, c.send(:action_methods), "#{c.controller_path} should be empty!"
|
||||
end
|
||||
@non_empty_controllers.each do |c|
|
||||
assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.class.controller_path} should not be empty!"
|
||||
hide_mocha_methods_from_controller(c)
|
||||
assert_equal Set.new('public_action'), c.send(:action_methods), "#{c.controller_path} should not be empty!"
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# Mocha adds methods to Object which are then included in the public_instance_methods
|
||||
# This method hides those from the controller so the above tests won't know the difference
|
||||
def hide_mocha_methods_from_controller(controller)
|
||||
mocha_methods = [:expects, :metaclass, :mocha, :mocha_inspect, :reset_mocha, :stubba_object, :stubba_method, :stubs, :verify]
|
||||
controller.class.send(:hide_action, *mocha_methods)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
class PerformActionTest < Test::Unit::TestCase
|
||||
def use_controller(controller_class)
|
||||
@controller = controller_class.new
|
||||
|
||||
# enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
|
||||
# a more accurate simulation of what happens in "real life".
|
||||
@controller.logger = Logger.new(nil)
|
||||
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
|
||||
@request.host = "www.nextangle.com"
|
||||
end
|
||||
|
||||
def test_get_on_priv_should_show_selector
|
||||
use_controller MethodMissingController
|
||||
get :shouldnt_be_called
|
||||
assert_response :success
|
||||
assert_equal 'shouldnt_be_called', @response.body
|
||||
end
|
||||
|
||||
def test_method_missing_is_not_an_action_name
|
||||
use_controller MethodMissingController
|
||||
assert ! @controller.send(:action_methods).include?('method_missing')
|
||||
|
||||
get :method_missing
|
||||
assert_response :success
|
||||
assert_equal 'method_missing', @response.body
|
||||
end
|
||||
|
||||
def test_get_on_hidden_should_fail
|
||||
use_controller NonEmptyController
|
||||
get :hidden_action
|
||||
assert_response 404
|
||||
|
||||
get :another_hidden_action
|
||||
assert_response 404
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue