aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-03-13 02:55:24 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-03-13 02:55:24 -0700
commit5d76dee329282acc918de50fecde869f1431e2f1 (patch)
tree0c6210535c511efa160cce8a6c09bdd08a09fb9f /actionpack
parent7c1714cbd0b37d1fc5ca2ac3e08980943454d516 (diff)
downloadrails-5d76dee329282acc918de50fecde869f1431e2f1.tar.gz
rails-5d76dee329282acc918de50fecde869f1431e2f1.tar.bz2
rails-5d76dee329282acc918de50fecde869f1431e2f1.zip
Example using an edge side include body part to fetch queued rendering results
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/body_parts/open_uri.rb13
-rw-r--r--actionpack/test/template/body_parts_test.rb36
2 files changed, 27 insertions, 22 deletions
diff --git a/actionpack/lib/action_view/body_parts/open_uri.rb b/actionpack/lib/action_view/body_parts/open_uri.rb
deleted file mode 100644
index 8ebd17b4a1..0000000000
--- a/actionpack/lib/action_view/body_parts/open_uri.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-require 'action_view/body_parts/threaded'
-require 'open-uri'
-
-module ActionView
- module BodyParts
- class OpenUri < Threaded
- def initialize(url)
- url = URI::Generic === url ? url : URI.parse(url)
- super(true) { |parts| parts << url.read }
- end
- end
- end
-end
diff --git a/actionpack/test/template/body_parts_test.rb b/actionpack/test/template/body_parts_test.rb
index d15c8808d9..88f09af94f 100644
--- a/actionpack/test/template/body_parts_test.rb
+++ b/actionpack/test/template/body_parts_test.rb
@@ -36,28 +36,36 @@ class OutputBufferTest < ActionController::TestCase
end
end
+
class QueuedPartTest < ActionController::TestCase
- class SimpleQueued < ActionView::BodyParts::Queued
+ class EdgeSideInclude < ActionView::BodyParts::Queued
+ QUEUE_REDEMPTION_URL = 'http://queue/jobs/%s'
+ ESI_INCLUDE_TAG = '<esi:include src="%s" />'
+
+ def self.redemption_tag(receipt)
+ ESI_INCLUDE_TAG % QUEUE_REDEMPTION_URL % receipt
+ end
+
protected
def submit(job)
- job
+ job.reverse
end
def redeem(receipt)
- receipt.to_s.reverse
+ self.class.redemption_tag(receipt)
end
end
class TestController < ActionController::Base
def index
- queued_render 'foo'
- queued_render 'bar'
- queued_render 'baz'
+ edge_side_include 'foo'
+ edge_side_include 'bar'
+ edge_side_include 'baz'
@performed_render = true
end
- def queued_render(job)
- response.template.punctuate_body! SimpleQueued.new(job)
+ def edge_side_include(job)
+ response.template.punctuate_body! EdgeSideInclude.new(job)
end
end
@@ -65,10 +73,12 @@ class QueuedPartTest < ActionController::TestCase
def test_queued_parts
get :index
- assert_equal 'oofrabzab', @response.body
+ expected = %(oof rab zab).map { |receipt| EdgeSideInclude.redemption_tag(receipt) }
+ assert_equal expected, @response.body
end
end
+
class ThreadedPartTest < ActionController::TestCase
class TestController < ActionController::Base
def index
@@ -113,7 +123,15 @@ class ThreadedPartTest < ActionController::TestCase
end
end
+
class OpenUriPartTest < ActionController::TestCase
+ class OpenUri < ActionView::BodyParts::Threaded
+ def initialize(url)
+ url = URI::Generic === url ? url : URI.parse(url)
+ super(true) { |parts| parts << url.read }
+ end
+ end
+
class TestController < ActionController::Base
def index
render_url 'http://localhost/foo'