Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Call it "streaming," not "progressive rendering" everywhere.

Need a consistent vocabulary, and this is what Rails 3.1 has chosen.
  • Loading branch information...
commit 757bb4b16cf990756ef11cce67135213e55db746 1 parent 2074201
@oggy authored
View
58 lib/template_streaming.rb
@@ -7,7 +7,7 @@ def configure(config)
end
end
- PROGRESSIVE_KEY = 'template_streaming.progressive'.freeze
+ STREAMING_KEY = 'template_streaming.streaming'.freeze
module Controller
def self.included(base)
@@ -19,37 +19,37 @@ def self.included(base)
helper_method :flush, :push
include ActiveSupport::Callbacks
- define_callbacks :when_rendering_progressively
+ define_callbacks :when_streaming_template
end
end
module ClassMethods
- def render_progressively(options={})
- before_filter :action_renders_progressively, options
+ def stream(options={})
+ before_filter :action_streams, options
end
end
- def action_renders_progressively
- @action_progressively_renders = true
+ def action_streams
+ @action_streams = true
end
- def action_renders_progressively?
- @action_progressively_renders
+ def action_streams?
+ @action_streams
end
def render_with_template_streaming(*args, &block)
options = args.first { |a| a.is_a?(Hash) }
- if options && options.size == 1 && options.key?(:progressive)
+ if options && options.size == 1 && options.key?(:stream)
# Need to set the default values, since the standard #render won't.
options[:template] = default_template
options[:layout] = true
end
push_render_stack_frame do |stack_height|
- if start_rendering_progressively?(stack_height, *args)
- @render_progressively = true
- @template.render_progressively = true
+ if start_streaming_template?(stack_height, *args)
+ @streaming_template = true
+ @template.streaming_template = true
@performed_render = true
- @streaming_body = StreamingBody.new(progressive_rendering_threshold) do
+ @streaming_body = StreamingBody.new(template_streaming_threshold) do
cookies.freeze
if self.class.session_store.sent_with_headers?
session.freeze
@@ -76,13 +76,13 @@ def render_with_template_streaming(*args, &block)
# would cause the flash to be referenced again, sweeping the
# flash a second time. To prevent this, we preserve the
# flash in a separate ivar, and patch #flash to return this
- # if we're rendering progressively.
+ # if we're streaming.
#
flash # ensure sweep
@template_streaming_flash = @_flash
- request.env[PROGRESSIVE_KEY] = true
+ request.env[STREAMING_KEY] = true
- run_callbacks :when_rendering_progressively
+ run_callbacks :when_streaming_template
else
render_without_template_streaming(*args, &block)
end
@@ -130,8 +130,8 @@ def template_streaming_flash # :nodoc:
@template_streaming_flash
end
- def render_progressively?
- @render_progressively
+ def streaming_template?
+ @streaming_template
end
private # --------------------------------------------------------
@@ -146,7 +146,7 @@ def push_render_stack_frame
end
end
- def start_rendering_progressively?(render_stack_height, *render_args)
+ def start_streaming_template?(render_stack_height, *render_args)
render_stack_height == 1 or
return false
@@ -158,9 +158,9 @@ def start_rendering_progressively?(render_stack_height, *render_args)
if !(UNSTREAMABLE_KEYS & render_options.keys).empty? || render_args.first == :update
false
else
- explicit_option = render_options[:progressive]
+ explicit_option = render_options[:stream]
if explicit_option.nil?
- action_renders_progressively?
+ action_streams?
else
explicit_option
end
@@ -173,7 +173,7 @@ def start_rendering_progressively?(render_stack_height, *render_args)
# The number of bytes that must be received by the client before
# anything will be rendered.
#
- def progressive_rendering_threshold
+ def template_streaming_threshold
content_type = response.header['Content-type']
content_type.nil? || content_type =~ %r'\Atext/html' or
return 0
@@ -239,7 +239,7 @@ def self.included(base)
def render_with_template_streaming(*args, &block)
options = args.first
- if render_progressively? && options.is_a?(Hash)
+ if streaming_template? && options.is_a?(Hash)
# These branches exist to handle the case where AC::Base#render calls
# AV::Base#render for rendering a partial with a layout. AC::Base
# renders the partial then the layout separately, but we need to render
@@ -251,8 +251,8 @@ def render_with_template_streaming(*args, &block)
return DeferredPartialRender.new(args)
elsif options[:text].is_a?(DeferredPartialRender)
render = options.delete(:text)
- # We patch the case of rendering :partial with :layout
- # progressively in _render_with_layout.
+ # We patch the case of rendering :partial with :layout while
+ # streaming in _render_with_layout.
return render(render.args.first.merge(:layout => options[:layout]))
end
end
@@ -261,14 +261,14 @@ def render_with_template_streaming(*args, &block)
DeferredPartialRender = Struct.new(:args)
- attr_writer :render_progressively
+ attr_writer :streaming_template
- def render_progressively?
- @render_progressively
+ def streaming_template?
+ @streaming_template
end
def _render_with_layout_with_template_streaming(options, local_assigns, &block)
- if !render_progressively?
+ if !streaming_template?
_render_with_layout_without_template_streaming(options, local_assigns, &block)
elsif block_given?
# The standard method doesn't properly restore @_proc_for_layout. Do it ourselves.
View
8 lib/template_streaming/autoflushing.rb
@@ -1,8 +1,8 @@
module TemplateStreaming
class << self
#
- # If non-nil, #flush will automatically be called when rendering
- # progressively before and after each render call.
+ # If non-nil, #flush will automatically be called when streaming
+ # before and after each render call.
#
# The value of this attribute should be a number, which is the
# number of milliseconds since the last flush that should elapse
@@ -25,7 +25,7 @@ def render_with_template_streaming_autoflushing(*args, &block)
def capture(*args, &block)
if block == @_proc_for_layout
- # Rendering the content of a progressive layout - inject autoflushing.
+ # Rendering the content of a streamed layout - inject autoflushing.
with_autoflushing do
super
end
@@ -53,7 +53,7 @@ def initialize(app)
def call(env)
response = @app.call(env)
- if env[PROGRESSIVE_KEY] && TemplateStreaming.autoflush
+ if env[STREAMING_KEY] && TemplateStreaming.autoflush
response[2] = BodyProxy.new(response[2])
end
response
View
2  lib/template_streaming/caching.rb
@@ -47,7 +47,7 @@ def self.included(base)
end
def after_with_template_streaming_caching(controller)
- if controller.render_progressively?
+ if controller.streaming_template?
# This flag is ass-backwards to me. It really means *don't* cache the layout...
cache_layout? and
raise NotImplementedError, "sorry, using caches_action with :layout => false is not yet supported by Template Streaming"
View
43 lib/template_streaming/error_recovery.rb
@@ -10,7 +10,7 @@ def initialize(app)
def call(env)
response = *@app.call(env)
- if env[TemplateStreaming::PROGRESSIVE_KEY]
+ if env[TemplateStreaming::STREAMING_KEY]
response[2] = BodyProxy.new(env, response[2])
response
else
@@ -125,42 +125,41 @@ def uninserted_errors(exceptions)
def render_exceptions(exceptions)
template = @controller.response.template
- template.render_progressive_exceptions(exceptions)
+ template.render_streaming_exceptions(exceptions)
end
end
end
module Controller
def self.included(base)
- base.when_rendering_progressively :set_template_streaming_controller
- base.class_inheritable_accessor :progressive_rendering_error_callbacks
- base.class_inheritable_accessor :progressive_rendering_error_renderer
- base.progressive_rendering_error_callbacks = []
+ base.when_streaming_template :set_template_streaming_controller
+ base.class_inheritable_accessor :streaming_error_callbacks
+ base.class_inheritable_accessor :streaming_error_renderer
+ base.streaming_error_callbacks = []
base.extend ClassMethods
end
module ClassMethods
#
- # Call the given block when an error occurs while rendering
- # progressively.
+ # Call the given block when an error occurs while streaming.
#
# The block is called with the controller instance and exception object.
#
# Hook in your exception notification system here.
#
- def on_progressive_rendering_error(&block)
- progressive_rendering_error_callbacks << block
+ def on_streaming_error(&block)
+ streaming_error_callbacks << block
end
#
# Call the give block to render errors injected into the page, when
- # uncaught exceptions are raised while progressively rendering.
+ # uncaught exceptions are raised while streaming.
#
# The block is called with the view instance an list of exception
# objects. It should return the HTML to inject into the page.
#
- def render_errors_progressively_with(&block)
- self.progressive_rendering_error_renderer = block
+ def render_streaming_errors_with(&block)
+ self.streaming_error_renderer = block
end
end
@@ -181,7 +180,7 @@ def self.included(base)
end
def render_with_template_streaming_error_recovery(*args, &block)
- if render_progressively?
+ if streaming_template?
begin
render_without_template_streaming_error_recovery(*args, &block)
rescue ActionView::MissingTemplate => e
@@ -190,7 +189,7 @@ def render_with_template_streaming_error_recovery(*args, &block)
rescue Exception => e
logger.error "#{e.class}: #{e.message}"
logger.error e.backtrace.join("\n").gsub(/^/, ' ')
- controller.progressive_rendering_error_callbacks.each{|c| c.call(e)}
+ controller.streaming_error_callbacks.each{|c| c.call(e)}
exceptions = controller.request.env[EXCEPTIONS_KEY] and
exceptions << e
''
@@ -200,13 +199,13 @@ def render_with_template_streaming_error_recovery(*args, &block)
end
end
- def render_progressive_exceptions(exceptions)
- controller.progressive_rendering_error_renderer.call(self, exceptions)
+ def render_streaming_exceptions(exceptions)
+ controller.streaming_error_renderer.call(self, exceptions)
end
- def render_default_progressive_exceptions(exceptions)
+ def render_default_streaming_exceptions(exceptions)
# Ensure errors in the error rendering don't recurse.
- @rendering_default_progressive_exceptions = true
+ @rendering_default_streaming_exceptions = true
begin
@content = exceptions.map do |exception|
template_path = ActionController::Rescue::RESCUES_TEMPLATE_PATH
@@ -216,19 +215,19 @@ def render_default_progressive_exceptions(exceptions)
end.join
render :file => "#{File.dirname(__FILE__)}/templates/errors.erb"
ensure
- @rendering_default_progressive_exceptions = false
+ @rendering_default_streaming_exceptions = false
end
end
end
DEFAULT_ERROR_RENDERER = lambda do |view, exceptions|
- view.render_default_progressive_exceptions(exceptions)
+ view.render_default_streaming_exceptions(exceptions)
end
ActionController::Dispatcher.middleware.insert_after ActionController::Failsafe, Middleware
ActionController::Base.send :include, Controller
ActionView::Base.send :include, View
- ActionController::Base.progressive_rendering_error_renderer = DEFAULT_ERROR_RENDERER
+ ActionController::Base.streaming_error_renderer = DEFAULT_ERROR_RENDERER
end
end
View
16 spec/autoflushing_spec.rb
@@ -1,9 +1,9 @@
require 'spec/spec_helper'
describe TemplateStreaming::Autoflushing do
- include ProgressiveRenderingTest
+ include StreamingApp
- describe "when rendering progressively" do
+ describe "when streaming" do
describe "when autoflushing is on" do
use_attribute_value TemplateStreaming, :autoflush, 0
@@ -11,7 +11,7 @@
layout "[<%= yield %>]"
view "(<%= render :partial => 'partial' %>)"
partial 'partial'
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
run
received.should == chunks('[', '(', 'partial', ')', ']', :end => true)
end
@@ -22,7 +22,7 @@
partial "{<%= render :layout => 'subpartial_layout', :partial => 'subpartial' %>}"
template 'test/_subpartial_layout', '<<%= yield %>>'
template 'test/_subpartial', 'subpartial'
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
run
received.should == chunks('[', '(', '{', '<', 'subpartial', '>', '}', ')', ']', :end => true)
end
@@ -33,7 +33,7 @@
partial "{<% render :layout => 'subpartial_layout' do %>`<%= render :partial => 'subpartial' %>'<% end %>}"
template 'test/_subpartial_layout', '<<%= yield %>>'
template 'test/_subpartial', 'subpartial'
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
run
received.should == chunks('[', '(', '{', '<', '`', 'subpartial', '\'', '>', '}', ')', ']', :end => true)
end
@@ -42,7 +42,7 @@
layout "[<%= yield %>][<%= yield %>]"
view "(<%= render :partial => 'partial' %>)(<%= render :partial => 'partial' %>)"
partial 'partial'
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
run
received.should == chunks('[', '(', 'partial', ')(', 'partial', ')', '][', '(', 'partial', ')(', 'partial', ')', ']', :end => true)
end
@@ -60,12 +60,12 @@
|<%= Time.stub(:now).and_return(data.t + 0.3); render :partial => 'c' -%>
|<%= 4 -%>
EOS
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
template 'test/_a', 'a'
template 'test/_b', 'b'
template 'test/_c', 'c'
template 'test/_d', 'd'
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
run
received.should == chunks('1', 'a2b3', 'c4', :end => true)
end
View
18 spec/caching_spec.rb
@@ -1,7 +1,7 @@
require 'spec/spec_helper'
describe TemplateStreaming::Caching do
- include ProgressiveRenderingTest
+ include StreamingApp
describe "page caching" do
use_attribute_value ActionController::Base, :page_cache_directory, "#{TMP}/page_cache"
@@ -9,7 +9,7 @@
before do
controller.caches_page :action
- action { render :progressive => true }
+ action { render :stream => true }
view "a<% flush %>b"
end
@@ -29,7 +29,7 @@
pop_attribute_value ActionController::Base, :cache_store
end
- describe "when rendering progressively" do
+ describe "when streaming" do
describe "when no layout is used" do
before do
controller.caches_action :action
@@ -37,14 +37,14 @@
it "should render the page correctly" do
view "a<% flush %>b"
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
run
received.should == chunks('a', 'b', :end => true)
end
it "should use the cached copy if it exists" do
view "<% data.render_count += 1 %>a<% flush %>b"
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
data.render_count = 0
run
run
@@ -54,11 +54,11 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
describe "when no layout is used" do
before do
controller.caches_action :action
- action { render :progressive => false, :layout => nil }
+ action { render :stream => false, :layout => nil }
end
it "should render the page correctly" do
@@ -80,7 +80,7 @@
describe "when the layout is cached" do
before do
controller.caches_action :action, :layout => true
- action { render :progressive => false, :layout => 'layout' }
+ action { render :stream => false, :layout => 'layout' }
end
it "should cache the layout" do
@@ -104,7 +104,7 @@
# AC always does render(:layout => true) to render the layout when the
# body is cached, even if an explicit layout name is given. Hence, our
# layout name must match the controller name.
- action { render :progressive => false, :layout => 'test' }
+ action { render :stream => false, :layout => 'test' }
end
it "should not cache the layout" do
View
26 spec/error_recovery_spec.rb
@@ -1,7 +1,7 @@
require 'spec/spec_helper'
describe TemplateStreaming::ErrorRecovery do
- include ProgressiveRenderingTest
+ include StreamingApp
describe "when there is an error during rendering" do
before do
@@ -13,7 +13,7 @@ def rescue_action(exception)
end
end
- describe "when not progressively rendering" do
+ describe "when not streaming" do
it "should show the standard error page" do
view "<% raise 'test exception' %>"
run
@@ -22,9 +22,9 @@ def rescue_action(exception)
end
end
- describe "when progressively rendering" do
+ describe "when streaming" do
before do
- controller.render_errors_progressively_with do |view, exceptions|
+ controller.render_streaming_errors_with do |view, exceptions|
messages = exceptions.map { |e| e.original_exception.message }
"(#{messages.join(',')})"
end
@@ -41,13 +41,13 @@ def local_request?
it "should run the error callback for each error raised" do
messages = []
- controller.on_progressive_rendering_error do |error|
+ controller.on_streaming_error do |error|
messages << error.original_exception.message
end
view "<% render :partial => 'a' %><% render :partial => 'b' %>"
template 'test/_a', "<% raise 'a' %>"
template 'test/_b', "<% raise 'b' %>"
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
run
messages.should == ['a', 'b']
end
@@ -55,7 +55,7 @@ def local_request?
describe "when a structurally-complete response is rendered" do
before do
view "<% raise 'x' %>"
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
end
it "should inject errors correctly when the error occurs before the doctype" do
@@ -109,7 +109,7 @@ def local_request?
describe "when an structurally-incomplete response is rendered" do
before do
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
end
it "should inject errors correctly when nothing is rendered" do
@@ -157,7 +157,7 @@ def local_request?
describe "when the response consists of multiple templates" do
before do
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
end
it "should inject errors when there is an error in the toplevel layout" do
@@ -214,13 +214,13 @@ def local_request?
it "should run the error callback for each error raised" do
messages = []
- controller.on_progressive_rendering_error do |error|
+ controller.on_streaming_error do |error|
messages << error.original_exception.message
end
view "<% render :partial => 'a' %><% render :partial => 'b' %>"
template 'test/_a', "<% raise 'a' %>"
template 'test/_b', "<% raise 'b' %>"
- action { render :progressive => true, :layout => nil }
+ action { render :stream => true, :layout => nil }
run
messages.should == ['a', 'b']
end
@@ -228,7 +228,7 @@ def local_request?
it "should not inject any error information" do
layout "<!DOCTYPE html><html><head></head><body><% flush %><%= yield %></body></html>"
view "...<% raise 'x' %>..."
- action { render :progressive => true, :layout => 'layout' }
+ action { render :stream => true, :layout => 'layout' }
run
received.should == chunks("<!DOCTYPE html><html><head></head><body>", "</body></html>", :end => true)
end
@@ -252,7 +252,7 @@ def local_request?
it "should render the standard error information" do
view "<% raise 'test exception' %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
received.should include('test exception')
received.should include('#uncaught_exceptions')
View
2  spec/spec_helper.rb
@@ -10,4 +10,4 @@
require 'template_streaming'
require 'temporaries'
-require 'support/progressive_rendering_test'
+require 'support/streaming_app'
View
10 spec/support/progressive_rendering_test.rb → spec/support/streaming_app.rb
@@ -1,13 +1,13 @@
-module ProgressiveRenderingTest
+module StreamingApp
VIEW_PATH = "#{TMP}/views"
COOKIE_SECRET = 'x'*30
def self.included(base)
- base.before { setup_progressive_rendering_test }
- base.after { teardown_progressive_rendering_test }
+ base.before { setup_streaming_app }
+ base.after { teardown_streaming_app }
end
- def setup_progressive_rendering_test
+ def setup_streaming_app
push_temporary_directory TMP
ActionController::Base.session = {:key => "session", :secret => COOKIE_SECRET}
@@ -30,7 +30,7 @@ def controller
TestController
end
- def teardown_progressive_rendering_test
+ def teardown_streaming_app
pop_constant_value Object, :TestController
pop_temporary_directory
FileUtils.rm_rf VIEW_PATH
View
186 spec/template_streaming_spec.rb
@@ -1,13 +1,13 @@
require 'spec/spec_helper'
describe TemplateStreaming do
- include ProgressiveRenderingTest
+ include StreamingApp
describe "#flush" do
- describe "when rendering progressively" do
+ describe "when streaming" do
before do
action do
- render :progressive => true, :layout => 'layout'
+ render :stream => true, :layout => 'layout'
end
end
@@ -39,10 +39,10 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should not affect the output" do
view "a<% flush %>b"
- action { render :progressive => false, :layout => nil }
+ action { render :stream => false, :layout => nil }
run
received.should == 'ab'
end
@@ -50,7 +50,7 @@
it "should not invert the layout rendering order" do
view "<% data.order << :view -%>"
layout "<% data.order << :layout1 -%><%= yield -%><% data.order << :layout2 -%>"
- action { render :progressive => false, :layout => 'layout' }
+ action { render :stream => false, :layout => 'layout' }
data.order = []
run
data.order.should == [:view, :layout1, :layout2]
@@ -59,10 +59,10 @@
end
describe "#push" do
- describe "when rendering progressively" do
+ describe "when streaming" do
before do
action do
- render :progressive => true, :layout => 'layout'
+ render :stream => true, :layout => 'layout'
end
end
@@ -79,10 +79,10 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
before do
action do
- render :progressive => false, :layout => 'layout'
+ render :stream => false, :layout => 'layout'
end
end
@@ -100,10 +100,10 @@
end
describe "response headers" do
- describe "when rendering progressively" do
+ describe "when streaming" do
before do
action do
- render :progressive => true, :layout => nil
+ render :stream => true, :layout => nil
end
end
@@ -120,10 +120,10 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
before do
action do
- render :progressive => false, :layout => nil
+ render :stream => false, :layout => nil
end
end
@@ -141,44 +141,44 @@
end
end
- describe ".render_progressively" do
+ describe ".stream" do
before do
TestController.layout 'layout'
layout "[<% flush %><%= yield %>]"
view "a"
end
- it "should render all actions progressively if no options are given" do
- TestController.render_progressively
+ it "should stream all actions if no options are given" do
+ TestController.stream
run
received.should == chunks('[', 'a]', :end => true)
end
- it "should render the action progressively if it is included with :only" do
- TestController.render_progressively :only => :action
+ it "should stream the action if it is included with :only" do
+ TestController.stream :only => :action
run
received.should == chunks('[', 'a]', :end => true)
end
- it "should not render the action progressively if it is excepted" do
- TestController.render_progressively :except => :action
+ it "should not stream the action if it is excepted" do
+ TestController.stream :except => :action
run
received.should == "[a]"
end
- it "should be overridden to true by an explicit :progressive => true when rendering" do
- TestController.render_progressively :except => :action
+ it "should be overridden to true by an explicit :stream => true when rendering" do
+ TestController.stream :except => :action
action do
- render :progressive => true
+ render :stream => true
end
run
received.should == chunks('[', 'a]', :end => true)
end
- it "should be overridden to false by an explicit :progressive => false when rendering" do
- TestController.render_progressively :only => :action
+ it "should be overridden to false by an explicit :stream => false when rendering" do
+ TestController.stream :only => :action
action do
- render :progressive => false
+ render :stream => false
end
run
received.should == "[a]"
@@ -186,9 +186,9 @@
end
describe "#render in the controller" do
- describe "when rendering progressively" do
+ describe "when streaming" do
before do
- @render_options = {:progressive => true}
+ @render_options = {:stream => true}
view "(<% flush %><%= render :partial => 'partial' %>)"
partial "a<% flush %>b"
end
@@ -199,7 +199,7 @@
layout "[<% flush %><%= yield %>]"
end
- it "should render templates specified with :action progressively" do
+ it "should stream templates specified with :action" do
render_options = @render_options
action do
render render_options.merge(:action => 'action')
@@ -208,7 +208,7 @@
received.should == chunks('[', '(', 'a', 'b)]', :end => true)
end
- it "should render templates specified with :partial progressively" do
+ it "should stream templates specified with :partial" do
render_options = @render_options
action do
render render_options.merge(:partial => 'partial')
@@ -217,7 +217,7 @@
received.should == chunks('[', 'a', 'b]', :end => true)
end
- it "should render :inline templates progressively" do
+ it "should stream :inline templates" do
render_options = @render_options
action do
render render_options.merge(:inline => "a<% flush %>b")
@@ -232,7 +232,7 @@
@render_options[:layout] = nil
end
- it "should render templates specified with :action progressively" do
+ it "should stream templates specified with :action" do
render_options = @render_options
action do
render render_options.merge(:action => 'action')
@@ -241,7 +241,7 @@
received.should == chunks('(', 'a', 'b)', :end => true)
end
- it "should render templates specified with :partial progressively" do
+ it "should stream templates specified with :partial" do
render_options = @render_options
action do
render render_options.merge(:partial => 'partial')
@@ -250,7 +250,7 @@
received.should == chunks('a', 'b', :end => true)
end
- it "should render :inline templates progressively" do
+ it "should stream :inline templates" do
render_options = @render_options
action do
render render_options.merge(:inline => "a<% flush %>b")
@@ -339,9 +339,9 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
before do
- @render_options = {:progressive => false}
+ @render_options = {:stream => false}
view "(<%= render :partial => 'partial' %>)"
partial "ab"
end
@@ -352,7 +352,7 @@
layout "[<%= yield %>]"
end
- it "should render templates specified with :action unprogressively" do
+ it "should not stream templates specified with :action" do
render_options = @render_options
action do
render render_options.merge(:action => 'action')
@@ -361,7 +361,7 @@
received.should == '[(ab)]'
end
- it "should render templates specified with :partial unprogressively" do
+ it "should not stream templates specified with :partial" do
render_options = @render_options
action do
render render_options.merge(:partial => 'partial')
@@ -370,7 +370,7 @@
received.should == '[ab]'
end
- it "should render :inline templates unprogressively" do
+ it "should not stream :inline templates" do
render_options = @render_options
action do
render render_options.merge(:inline => 'ab')
@@ -385,7 +385,7 @@
@render_options[:layout] = nil
end
- it "should render templates specified with :action unprogressively" do
+ it "should not stream templates specified with :action" do
render_options = @render_options
action do
render render_options.merge(:action => 'action')
@@ -394,7 +394,7 @@
received.should == '(ab)'
end
- it "should render templates specified with :partial unprogressively" do
+ it "should not stream templates specified with :partial" do
render_options = @render_options
action do
render render_options.merge(:partial => 'partial')
@@ -403,7 +403,7 @@
received.should == 'ab'
end
- it "should render :inline templates unprogressively" do
+ it "should not stream :inline templates" do
render_options = @render_options
action do
render render_options.merge(:inline => 'ab')
@@ -413,7 +413,7 @@
end
end
- it "should render a given :text string unprogressively" do
+ it "should not stream a given :text string" do
render_options = @render_options
action do
render render_options.merge(:text => 'ab')
@@ -423,12 +423,12 @@
end
end
- it "should use the standard defaults when only a :progressive option is given" do
+ it "should use the standard defaults when only a :stream option is given" do
template 'layouts/controller_layout', "[<%= yield %>]"
TestController.layout 'controller_layout'
view 'a'
action do
- render :progressive => false
+ render :stream => false
end
run
received.should == '[a]'
@@ -436,10 +436,10 @@
end
describe "#render in the view" do
- describe "when rendering progressively" do
+ describe "when streaming" do
before do
action do
- render :progressive => true, :layout => 'layout'
+ render :stream => true, :layout => 'layout'
end
layout "[<% flush %><%= yield %>]"
template 'test/_partial_layout', "{<% flush %><%= yield %>}"
@@ -460,10 +460,10 @@
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
before do
action do
- render :progressive => false, :layout => 'layout'
+ render :stream => false, :layout => 'layout'
end
layout "[<%= yield %>]"
template 'test/_partial_layout', "{<%= yield %>}"
@@ -487,11 +487,11 @@
describe "#render_to_string in the controller" do
it "should not flush anything out to the client" do
- TestController.render_progressively
+ TestController.stream
action do
@string = render_to_string :partial => 'partial'
received.should == ''
- render :progressive => true
+ render :stream => true
end
layout "<%= yield %>"
view "<%= @string %>"
@@ -503,7 +503,7 @@
describe "#render_to_string in the view" do
it "should not flush anything out to the client" do
- TestController.render_progressively
+ TestController.stream
TestController.helper_method :render_to_string
layout "<%= yield %>"
view <<-'EOS'.gsub(/^ *\|/, '')
@@ -513,7 +513,7 @@
EOS
partial "partial"
action do
- render :progressive => true
+ render :stream => true
end
run
received.should == chunks("partial", :end => true)
@@ -524,7 +524,7 @@
before do
view "a<% flush %>"
action do
- render :progressive => true, :layout => nil
+ render :stream => true, :layout => nil
end
end
@@ -549,27 +549,27 @@
end
end
- describe "#when_rendering_progressively" do
+ describe "#when_streaming_template" do
before do
- TestController.when_rendering_progressively { |c| c.data.order << :callback }
+ TestController.when_streaming_template { |c| c.data.order << :callback }
view "<% data.order << :rendering %>"
layout '<%= yield %>'
data.order = []
end
- it "should be called when rendering progressively" do
+ it "should be called when streaming" do
action do
data.order << :action
- render :progressive => true
+ render :stream => true
end
run
data.order.should == [:action, :callback, :rendering]
end
- it "should not be called when not rendering progressively" do
+ it "should not be called when not streaming" do
action do
data.order << :action
- render :progressive => false
+ render :stream => false
end
run
data.order.should == [:action, :rendering]
@@ -591,14 +591,14 @@ def destroy(env)
end
describe "#flash" do
- describe "when rendering progressively" do
+ describe "when streaming" do
it "should behave correctly when referenced in the controller" do
values = []
view ""
action do
flash[:key] = "value" if params[:set]
values << flash[:key]
- render :progressive => true
+ render :stream => true
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -614,7 +614,7 @@ def destroy(env)
view "(<%= flash[:key] %>)"
action do
flash[:key] = "value" if params[:set]
- render :progressive => true
+ render :stream => true
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -630,7 +630,7 @@ def destroy(env)
it "should be frozen in the view if the session is sent with the headers" do
view "<% data.frozen = flash.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_true
end
@@ -638,21 +638,21 @@ def destroy(env)
it "should not be frozen in the view if the session is not sent with the headers" do
with_attribute_value ActionController::Base, :session_store, BlackHoleSessionStore do
view "<% data.frozen = flash.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_false
end
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should behave correctly when referenced in the controller" do
values = []
view ""
action do
flash[:key] = "value" if params[:set]
values << flash[:key]
- render :progressive => false
+ render :stream => false
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -684,21 +684,21 @@ def destroy(env)
it "should not be frozen in the view" do
view "<% data.frozen = flash.frozen? %>"
- action { render :progressive => false }
+ action { render :stream => false }
run
data.frozen.should be_false
end
end
describe "#flash.now" do
- describe "when rendering progressively" do
+ describe "when streaming" do
it "should behave correctly when referenced in the controller" do
values = []
view ""
action do
flash.now[:key] = "value" if params[:set]
values << flash[:key]
- render :progressive => true
+ render :stream => true
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -711,7 +711,7 @@ def destroy(env)
view "(<%= flash[:key] %>)"
action do
flash.now[:key] = "value" if params[:set]
- render :progressive => true
+ render :stream => true
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -722,14 +722,14 @@ def destroy(env)
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should behave correctly when referenced in the controller" do
values = []
view ""
action do
flash.now[:key] = "value" if params[:set]
values << flash[:key]
- render :progressive => false
+ render :stream => false
end
run('QUERY_STRING' => 'set=1')
session_cookie = headers['Set-Cookie'].scan(/^(session=[^;]*)/).first.first
@@ -754,10 +754,10 @@ def destroy(env)
end
describe "#cookies" do
- describe "when rendering progressively" do
+ describe "when streaming" do
it "should be frozen in the view" do
view "<% data.frozen = cookies.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_true
end
@@ -765,17 +765,17 @@ def destroy(env)
it "should be frozen in the view irrespective of session store" do
with_attribute_value ActionController::Base, :session_store, BlackHoleSessionStore do
view "<% data.frozen = cookies.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_true
end
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should not be frozen in the view" do
view "<% data.frozen = session.frozen? %>"
- action { render :progressive => false }
+ action { render :stream => false }
run
data.frozen.should be_false
end
@@ -783,10 +783,10 @@ def destroy(env)
end
describe "#session" do
- describe "when rendering progressively" do
+ describe "when streaming" do
it "should be frozen in the view if the session is sent with the headers" do
view "<% data.frozen = session.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_true
end
@@ -794,17 +794,17 @@ def destroy(env)
it "should not be frozen in the view if the session is not sent with the headers" do
with_attribute_value ActionController::Base, :session_store, BlackHoleSessionStore do
view "<% data.frozen = session.frozen? %>"
- action { render :progressive => true }
+ action { render :stream => true }
run
data.frozen.should be_false
end
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should not be frozen in the view" do
view "<% data.frozen = session.frozen? %>"
- action { render :progressive => false }
+ action { render :stream => false }
run
data.frozen.should be_false
end
@@ -812,13 +812,13 @@ def destroy(env)
end
describe "#form_authenticity_token" do
- describe "when rendering progressively" do
+ describe "when streaming" do
it "should match what is in the session when referenced in the controller" do
view ''
value = nil
action do
value = form_authenticity_token
- render :progressive => true
+ render :stream => true
end
run
session[:_csrf_token].should == value
@@ -827,20 +827,20 @@ def destroy(env)
it "should match what is in the session when only referenced in the view" do
view "<%= form_authenticity_token %>"
action do
- render :progressive => true
+ render :stream => true
end
run
received.should == chunks(session[:_csrf_token], :end => true)
end
end
- describe "when not rendering progressively" do
+ describe "when not streaming" do
it "should match what is in the session when referenced in the controller" do
view ''
value = nil
action do
value = form_authenticity_token
- render :progressive => false
+ render :stream => false
end
run
session[:_csrf_token].should == value
@@ -849,7 +849,7 @@ def destroy(env)
it "should match what is in the session when only referenced in the view" do
view "<%= form_authenticity_token %>"
action do
- render :progressive => false
+ render :stream => false
end
run
received.should == session[:_csrf_token]
@@ -877,7 +877,7 @@ def render_call(layout, partial, style)
template 'test/_outer', "outer[<% flush %>#{render_call 'inner_layout', 'inner', inner_style}]"
template 'test/_inner', "inner"
action do
- render :layout => 'layout', :progressive => true
+ render :layout => 'layout', :stream => true
end
run
received.should == chunks('layout[', 'view[', 'outer_layout[', 'outer[', 'inner_layout[', 'inner]]]]]', :end => true)
@@ -894,7 +894,7 @@ def render_call(layout, partial, style)
partial "partial"
template 'test/_partial_layout', 'partial_layout[<% flush %><%= yield %>]'
action do
- render :layout => 'layout', :progressive => true
+ render :layout => 'layout', :stream => true
end
run
received.should == chunks('layout[', 'partial_layout[', 'partial]view]', :end => true)
@@ -914,7 +914,7 @@ def render_call(layout, partial, style)
template 'test/_inner', 'inner'
partial "partial"
action do
- render :layout => 'layout', :progressive => true
+ render :layout => 'layout', :stream => true
end
run
received.should == chunks('layout[', 'view[', 'outer_layout[', 'inner_layout[', 'inner]outer]]]', :end => true)
Please sign in to comment.
Something went wrong with that request. Please try again.