2008-01-05 08:32:06 -05:00
|
|
|
require 'abstract_unit'
|
2011-12-23 13:47:21 -05:00
|
|
|
require 'active_support/logger'
|
2005-07-03 07:01:43 -04:00
|
|
|
|
|
|
|
class CaptureController < ActionController::Base
|
2013-08-13 16:28:51 -04:00
|
|
|
self.view_paths = [ File.dirname(__FILE__) + '/../../fixtures/actionpack' ]
|
2013-08-06 18:20:33 -04:00
|
|
|
|
2005-07-03 07:01:43 -04:00
|
|
|
def self.controller_name; "test"; end
|
|
|
|
def self.controller_path; "test"; end
|
|
|
|
|
2005-07-24 09:20:29 -04:00
|
|
|
def content_for
|
2010-09-28 16:44:26 -04:00
|
|
|
@title = nil
|
2005-07-24 09:20:29 -04:00
|
|
|
render :layout => "talk_from_action"
|
|
|
|
end
|
2006-11-12 19:53:20 -05:00
|
|
|
|
2007-09-20 23:40:25 -04:00
|
|
|
def content_for_with_parameter
|
2010-09-28 16:44:26 -04:00
|
|
|
@title = nil
|
2007-09-20 23:40:25 -04:00
|
|
|
render :layout => "talk_from_action"
|
|
|
|
end
|
|
|
|
|
2008-06-06 21:01:14 -04:00
|
|
|
def content_for_concatenated
|
2010-09-28 16:44:26 -04:00
|
|
|
@title = nil
|
2006-02-26 14:47:50 -05:00
|
|
|
render :layout => "talk_from_action"
|
|
|
|
end
|
2006-11-12 19:53:20 -05:00
|
|
|
|
2006-02-26 14:47:50 -05:00
|
|
|
def non_erb_block_content_for
|
2010-09-28 16:44:26 -04:00
|
|
|
@title = nil
|
2006-02-26 14:47:50 -05:00
|
|
|
render :layout => "talk_from_action"
|
|
|
|
end
|
2005-07-24 09:20:29 -04:00
|
|
|
|
2010-09-29 10:10:38 -04:00
|
|
|
def proper_block_detection
|
|
|
|
@todo = "some todo"
|
|
|
|
end
|
2005-07-03 07:01:43 -04:00
|
|
|
end
|
|
|
|
|
2009-01-07 16:23:10 -05:00
|
|
|
class CaptureTest < ActionController::TestCase
|
|
|
|
tests CaptureController
|
2005-07-03 07:01:43 -04:00
|
|
|
|
2009-01-07 16:23:10 -05:00
|
|
|
def setup
|
2009-04-08 20:33:06 -04:00
|
|
|
super
|
2005-07-03 07:01:43 -04:00
|
|
|
# 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".
|
2011-12-23 13:47:21 -05:00
|
|
|
@controller.logger = ActiveSupport::Logger.new(nil)
|
2005-07-03 07:01:43 -04:00
|
|
|
|
|
|
|
@request.host = "www.nextangle.com"
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_simple_capture
|
|
|
|
get :capturing
|
|
|
|
assert_equal "Dreamy days", @response.body.strip
|
|
|
|
end
|
2006-11-12 19:53:20 -05:00
|
|
|
|
2005-07-24 09:20:29 -04:00
|
|
|
def test_content_for
|
|
|
|
get :content_for
|
2006-02-26 14:47:50 -05:00
|
|
|
assert_equal expected_content_for_output, @response.body
|
|
|
|
end
|
2006-11-12 19:53:20 -05:00
|
|
|
|
2015-09-20 14:02:11 -04:00
|
|
|
def test_should_concatenate_content_for
|
2007-09-20 23:40:25 -04:00
|
|
|
get :content_for_concatenated
|
|
|
|
assert_equal expected_content_for_output, @response.body
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_should_set_content_for_with_parameter
|
|
|
|
get :content_for_with_parameter
|
2006-02-26 14:47:50 -05:00
|
|
|
assert_equal expected_content_for_output, @response.body
|
|
|
|
end
|
2006-11-12 19:53:20 -05:00
|
|
|
|
2006-02-26 14:47:50 -05:00
|
|
|
def test_non_erb_block_content_for
|
|
|
|
get :non_erb_block_content_for
|
|
|
|
assert_equal expected_content_for_output, @response.body
|
2005-07-24 09:20:29 -04:00
|
|
|
end
|
2005-07-03 07:01:43 -04:00
|
|
|
|
2010-05-15 20:22:30 -04:00
|
|
|
def test_proper_block_detection
|
|
|
|
get :proper_block_detection
|
2010-09-29 10:10:38 -04:00
|
|
|
assert_equal "some todo", @response.body
|
2010-05-15 20:22:30 -04:00
|
|
|
end
|
|
|
|
|
2006-02-26 14:47:50 -05:00
|
|
|
private
|
2007-03-13 01:24:10 -04:00
|
|
|
def expected_content_for_output
|
2010-05-17 11:41:54 -04:00
|
|
|
"<title>Putting stuff in the title!</title>\nGreat stuff!"
|
2007-03-13 01:24:10 -04:00
|
|
|
end
|
2005-07-03 07:01:43 -04:00
|
|
|
end
|