|
1 | 1 | require 'abstract_unit'
|
2 | 2 | require 'action_view/body_parts/concurrent_block'
|
3 | 3 |
|
4 |
| -class BodyPartTest < ActionController::TestCase |
5 |
| - module EdgeSideInclude |
6 |
| - QUEUE_REDEMPTION_URL = 'http://render.farm/renderings/%s' |
7 |
| - ESI_INCLUDE_TAG = '<esi:include src="%s" />' |
8 |
| - |
9 |
| - def self.redemption_tag(receipt) |
10 |
| - ESI_INCLUDE_TAG % QUEUE_REDEMPTION_URL % receipt |
11 |
| - end |
12 |
| - |
13 |
| - class BodyPart |
14 |
| - def initialize(rendering) |
15 |
| - @receipt = enqueue(rendering) |
16 |
| - end |
17 |
| - |
18 |
| - def to_s |
19 |
| - EdgeSideInclude.redemption_tag(@receipt) |
20 |
| - end |
21 |
| - |
22 |
| - protected |
23 |
| - # Pretend we sent this rendering off for processing. |
24 |
| - def enqueue(rendering) |
25 |
| - rendering.object_id.to_s |
26 |
| - end |
27 |
| - end |
28 |
| - end |
| 4 | +class BodyPartsTest < ActionController::TestCase |
| 5 | + RENDERINGS = [Object.new, Object.new, Object.new] |
29 | 6 |
|
30 | 7 | class TestController < ActionController::Base
|
31 |
| - RENDERINGS = [Object.new, Object.new, Object.new] |
32 |
| - |
33 | 8 | def index
|
34 | 9 | RENDERINGS.each do |rendering|
|
35 |
| - edge_side_include rendering |
| 10 | + response.template.punctuate_body! rendering |
36 | 11 | end
|
37 | 12 | @performed_render = true
|
38 | 13 | end
|
39 |
| - |
40 |
| - def edge_side_include(rendering) |
41 |
| - response.template.punctuate_body! EdgeSideInclude::BodyPart.new(rendering) |
42 |
| - end |
43 | 14 | end
|
44 | 15 |
|
45 | 16 | tests TestController
|
46 | 17 |
|
47 |
| - def test_queued_parts |
| 18 | + def test_body_parts |
48 | 19 | get :index
|
49 |
| - expected = TestController::RENDERINGS.map { |rendering| EdgeSideInclude.redemption_tag(rendering.object_id) }.join |
50 |
| - assert_equal expected, @response.body |
| 20 | + assert_equal RENDERINGS, @response.body_parts |
| 21 | + assert_equal RENDERINGS.join, @response.body |
51 | 22 | end
|
52 | 23 | end
|
53 | 24 |
|
54 |
| - |
55 | 25 | class ConcurrentBlockPartTest < ActionController::TestCase
|
56 | 26 | class TestController < ActionController::Base
|
57 | 27 | def index
|
|
0 commit comments