breezy_template 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/breezy_template.rb +285 -211
- data/lib/breezy_template/active_support.rb +3 -3
- data/lib/breezy_template/blank.rb +11 -0
- data/lib/breezy_template/breezy_template.rb +7 -0
- data/lib/breezy_template/cache_extension.rb +75 -27
- data/lib/breezy_template/configuration.rb +3 -1
- data/lib/breezy_template/deferment_extension.rb +14 -12
- data/lib/breezy_template/dependency_tracker.rb +5 -2
- data/lib/breezy_template/digestor.rb +2 -1
- data/lib/breezy_template/errors.rb +24 -0
- data/lib/breezy_template/handler.rb +4 -2
- data/lib/breezy_template/key_formatter.rb +34 -0
- data/lib/breezy_template/partial_extension.rb +57 -19
- data/lib/breezy_template/search_extension.rb +3 -3
- data/test/dependency_tracker_test.rb +80 -64
- data/test/{breezy_template_test.rb → extensions_test.rb} +130 -77
- data/test/template_test.rb +714 -0
- data/test/test_helper.rb +0 -1
- metadata +31 -25
- data/lib/breezy_template/version.rb +0 -3
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'breezy_template/breezy_template'
|
2
|
+
|
3
|
+
class BreezyTemplate
|
2
4
|
module SearchExtension
|
3
5
|
def found!
|
4
6
|
found = @found
|
@@ -67,7 +69,6 @@ module BreezyTemplate
|
|
67
69
|
def set!(key, value = BLANK, *args)
|
68
70
|
return if @found
|
69
71
|
options = args.first || {}
|
70
|
-
options = _normalize_options(options)
|
71
72
|
|
72
73
|
if @search_path && !@search_path.empty?
|
73
74
|
if key.to_s == @search_path.first
|
@@ -80,7 +81,6 @@ module BreezyTemplate
|
|
80
81
|
yield self
|
81
82
|
elsif _partial_options?(options)
|
82
83
|
without_track = args.dup
|
83
|
-
# without_track.first.delete(:track)
|
84
84
|
super(key, value, *without_track)
|
85
85
|
else
|
86
86
|
::Kernel.raise 'This should not happen'
|
@@ -1,66 +1,82 @@
|
|
1
1
|
# # taken from jbuilder's jbuilder_dependency_tracker_test.rb
|
2
2
|
#
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
3
|
+
require 'test_helper'
|
4
|
+
require 'breezy_template/dependency_tracker'
|
5
|
+
require 'mocha'
|
6
|
+
|
7
|
+
class FakeTemplate
|
8
|
+
attr_reader :source, :handler
|
9
|
+
def initialize(source, handler = :jbuilder)
|
10
|
+
@source, @handler = source, handler
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
class BreezyTemplateDependencyTrackerTest < ActiveSupport::TestCase
|
16
|
+
def make_tracker(name, source)
|
17
|
+
template = FakeTemplate.new(source)
|
18
|
+
BreezyTemplate::DependencyTracker.new(name, template)
|
19
|
+
end
|
20
|
+
|
21
|
+
def track_dependencies(source)
|
22
|
+
make_tracker('breezy_template', source).dependencies
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'jbuilder direct partial! feature are not allowed' do
|
26
|
+
dependencies = track_dependencies <<-RUBY
|
27
|
+
json.partial! 'path/to/partial', foo: bar
|
28
|
+
json.partial! 'path/to/another/partial', :fizz => buzz
|
29
|
+
RUBY
|
30
|
+
|
31
|
+
assert_equal [], dependencies
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'detects partial with no options (1.9 style)' do
|
35
|
+
dependencies = track_dependencies <<-RUBY
|
36
|
+
json.content hello: 'world', partial: 'path/to/partial'
|
37
|
+
RUBY
|
38
|
+
|
39
|
+
assert_equal %w[path/to/partial], dependencies
|
40
|
+
end
|
41
|
+
|
42
|
+
test 'detects partial with no options (1.8 style)' do
|
43
|
+
dependencies = track_dependencies <<-RUBY
|
44
|
+
json.content :hello => 'world', :partial => 'path/to/partial'
|
45
|
+
RUBY
|
46
|
+
|
47
|
+
assert_equal %w[path/to/partial], dependencies
|
48
|
+
end
|
49
|
+
|
50
|
+
test 'detects partial with options (1.9 style)' do
|
51
|
+
dependencies = track_dependencies <<-RUBY
|
52
|
+
json.content hello: 'world', partial: ['path/to/partial', foo: :bar]
|
53
|
+
RUBY
|
54
|
+
|
55
|
+
assert_equal %w[path/to/partial], dependencies
|
56
|
+
end
|
57
|
+
|
58
|
+
test 'detects partial with options (1.8 style)' do
|
59
|
+
dependencies = track_dependencies <<-RUBY
|
60
|
+
json.content :hello => 'world', :partial => ['path/to/partial', :foo => :bar]
|
61
|
+
RUBY
|
62
|
+
|
63
|
+
assert_equal %w[path/to/partial], dependencies
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'detects partial in indirect collecton calls' do
|
67
|
+
dependencies = track_dependencies <<-RUBY
|
68
|
+
json.comments @post.comments, partial: ['comments/comment', as: :comment]
|
69
|
+
RUBY
|
70
|
+
|
71
|
+
assert_equal %w[comments/comment], dependencies
|
72
|
+
end
|
73
|
+
|
74
|
+
test 'detects explicit depedency' do
|
75
|
+
dependencies = track_dependencies <<-RUBY
|
76
|
+
# Template Dependency: path/to/partial
|
77
|
+
json.foo 'bar'
|
78
|
+
RUBY
|
79
|
+
|
80
|
+
assert_equal %w[path/to/partial], dependencies
|
81
|
+
end
|
82
|
+
end
|
@@ -297,7 +297,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
297
297
|
Rails.cache.clear
|
298
298
|
|
299
299
|
result = jbuild(<<-JBUILDER)
|
300
|
-
json.post @post, partial: "blog_post", as: :blog_post, joint: :header
|
300
|
+
json.post @post, partial: ["blog_post", as: :blog_post, joint: :header]
|
301
301
|
JBUILDER
|
302
302
|
|
303
303
|
expected = strip_format(<<-JS)
|
@@ -317,6 +317,58 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
317
317
|
assert_equal expected, result
|
318
318
|
end
|
319
319
|
|
320
|
+
test "renders a partial with implicit joint" do
|
321
|
+
result = jbuild(<<-JBUILDER)
|
322
|
+
json.footer nil, partial: ["footer", joint: true]
|
323
|
+
JBUILDER
|
324
|
+
|
325
|
+
expected = strip_format(<<-JS)
|
326
|
+
(function(){
|
327
|
+
var joints={};
|
328
|
+
var cache={};
|
329
|
+
var defers=[];
|
330
|
+
joints['footer'] ||= []; joints['footer'].push('footer');
|
331
|
+
return ({"data":{"footer":{"terms":"You agree"}},"joints":joints,"defers":defers});
|
332
|
+
})()
|
333
|
+
JS
|
334
|
+
assert_equal expected, result
|
335
|
+
end
|
336
|
+
|
337
|
+
test "renders a partial with explicit joint" do
|
338
|
+
result = jbuild(<<-JBUILDER)
|
339
|
+
json.footer nil, partial: ["footer", joint: 'hello']
|
340
|
+
JBUILDER
|
341
|
+
|
342
|
+
expected = strip_format(<<-JS)
|
343
|
+
(function(){
|
344
|
+
var joints={};
|
345
|
+
var cache={};
|
346
|
+
var defers=[];
|
347
|
+
joints['hello'] ||= []; joints['hello'].push('footer');
|
348
|
+
return ({"data":{"footer":{"terms":"You agree"}},"joints":joints,"defers":defers});
|
349
|
+
})()
|
350
|
+
JS
|
351
|
+
assert_equal expected, result
|
352
|
+
end
|
353
|
+
|
354
|
+
test "render array of partials with unique joints" do
|
355
|
+
result = jbuild(<<-JBUILDER)
|
356
|
+
json.array! [1,2], partial: ["footer", joint: ->(x){"somefoo"+x.to_s}]
|
357
|
+
JBUILDER
|
358
|
+
|
359
|
+
expected = strip_format(<<-JS)
|
360
|
+
(function(){
|
361
|
+
var joints={};
|
362
|
+
var cache={};
|
363
|
+
var defers=[];
|
364
|
+
joints['somefoo1'] ||= []; joints['somefoo1'].push('0');joints['somefoo2'] ||= []; joints['somefoo2'].push('1');
|
365
|
+
return ({"data":[{"terms":"You agree"},{"terms":"You agree"}],"joints":joints,"defers":defers});
|
366
|
+
})()
|
367
|
+
JS
|
368
|
+
|
369
|
+
assert_equal expected, result
|
370
|
+
end
|
371
|
+
|
320
372
|
test "renders a partial with no locals" do
|
321
373
|
result = jbuild(<<-JBUILDER)
|
322
374
|
json.footer nil, partial: "footer"
|
@@ -335,7 +387,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
335
387
|
|
336
388
|
test "renders a partial with locals" do
|
337
389
|
result = jbuild(<<-JBUILDER)
|
338
|
-
json.profile nil, partial: "profile", locals: {email: "test@test.com"}
|
390
|
+
json.profile nil, partial: ["profile", locals: {email: "test@test.com"}]
|
339
391
|
JBUILDER
|
340
392
|
|
341
393
|
expected = strip_format(<<-JS)
|
@@ -351,8 +403,11 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
351
403
|
|
352
404
|
test "renders a partial with locals and caches" do
|
353
405
|
result = jbuild(<<-JBUILDER)
|
354
|
-
|
355
|
-
|
406
|
+
opts = {
|
407
|
+
cache: 'cachekey',
|
408
|
+
partial: ["profile", locals: {email: "test@test.com"}]
|
409
|
+
}
|
410
|
+
json.profile 32, opts
|
356
411
|
JBUILDER
|
357
412
|
|
358
413
|
expected = strip_format(<<-JS)
|
@@ -370,7 +425,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
370
425
|
|
371
426
|
test "renders a partial even without a :as to the value, this usage is rare" do
|
372
427
|
result = jbuild(<<-JBUILDER)
|
373
|
-
json.profile 32, partial: "profile", locals: {email: "test@test.com"}
|
428
|
+
json.profile 32, partial: ["profile", locals: {email: "test@test.com"}]
|
374
429
|
JBUILDER
|
375
430
|
|
376
431
|
expected = strip_format(<<-JS)
|
@@ -404,8 +459,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
404
459
|
|
405
460
|
test "render array of partials without an :as to a member and cache" do
|
406
461
|
result = jbuild(<<-JBUILDER)
|
407
|
-
json.
|
408
|
-
json.array! [1,2], partial: "footer"
|
462
|
+
json.array! [1,2], partial: "footer", cache: ->(i){ ['a', i] }
|
409
463
|
JBUILDER
|
410
464
|
|
411
465
|
expected = strip_format(<<-JS)
|
@@ -424,7 +478,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
424
478
|
|
425
479
|
test "render array of partials" do
|
426
480
|
result = jbuild(<<-JBUILDER)
|
427
|
-
json.array! BLOG_POST_COLLECTION, partial: "blog_post", as: :blog_post
|
481
|
+
json.array! BLOG_POST_COLLECTION, partial: ["blog_post", as: :blog_post]
|
428
482
|
JBUILDER
|
429
483
|
|
430
484
|
expected = strip_format(<<-JS)
|
@@ -452,7 +506,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
452
506
|
|
453
507
|
test "renders array of partials as empty array with nil-collection" do
|
454
508
|
result = jbuild(<<-JBUILDER)
|
455
|
-
json.array! nil, partial: "blog_post", as: :blog_post
|
509
|
+
json.array! nil, partial: ["blog_post", as: :blog_post]
|
456
510
|
JBUILDER
|
457
511
|
|
458
512
|
expected = strip_format(<<-JS)
|
@@ -487,8 +541,10 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
487
541
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
488
542
|
|
489
543
|
result = jbuild(<<-JBUILDER)
|
490
|
-
|
491
|
-
|
544
|
+
opts = {
|
545
|
+
cache: [['b', 'c']]
|
546
|
+
}
|
547
|
+
json.hello 32, opts
|
492
548
|
JBUILDER
|
493
549
|
|
494
550
|
expected = strip_format(<<-JS)
|
@@ -509,8 +565,10 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
509
565
|
|
510
566
|
result = jbuild(<<-JBUILDER)
|
511
567
|
json.hello do
|
512
|
-
|
513
|
-
|
568
|
+
opts = {
|
569
|
+
cache: ->(i){ ['a', i] }
|
570
|
+
}
|
571
|
+
json.array! [4,5], opts do |x|
|
514
572
|
json.top "hello" + x.to_s
|
515
573
|
end
|
516
574
|
end
|
@@ -534,14 +592,11 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
534
592
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
535
593
|
|
536
594
|
result = jbuild(<<-JBUILDER)
|
537
|
-
json.
|
538
|
-
|
539
|
-
json.wrap! :cache, ['d', 'z']
|
540
|
-
json.content do
|
595
|
+
json.hello cache: [['a', 'b']] do
|
596
|
+
json.content cache: [['d', 'z']] do
|
541
597
|
json.subcontent 'inner'
|
542
598
|
end
|
543
|
-
json.
|
544
|
-
json.other do
|
599
|
+
json.other cache: [['e', 'z']] do
|
545
600
|
json.subcontent 'other'
|
546
601
|
end
|
547
602
|
end
|
@@ -612,15 +667,15 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
612
667
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
613
668
|
|
614
669
|
jbuild(<<-JBUILDER)
|
615
|
-
|
616
|
-
json.post do
|
670
|
+
opts = {cache: ['cachekey']}
|
671
|
+
json.post opts do
|
617
672
|
json.name "Cache"
|
618
673
|
end
|
619
674
|
JBUILDER
|
620
675
|
|
621
676
|
result = jbuild(<<-JBUILDER)
|
622
|
-
|
623
|
-
json.post do
|
677
|
+
opts = {cache: ['cachekey']}
|
678
|
+
json.post opts do
|
624
679
|
json.name "Miss"
|
625
680
|
end
|
626
681
|
JBUILDER
|
@@ -642,8 +697,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
642
697
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
643
698
|
|
644
699
|
result = jbuild <<-JBUILDER
|
645
|
-
json.
|
646
|
-
json.content do
|
700
|
+
json.content cache: "cachekey" do
|
647
701
|
json.array! %w[a b c]
|
648
702
|
end
|
649
703
|
JBUILDER
|
@@ -674,8 +728,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
674
728
|
@context.expects :fragment_name_with_digest
|
675
729
|
|
676
730
|
jbuild <<-JBUILDER
|
677
|
-
json.
|
678
|
-
json.content do
|
731
|
+
json.content cache: 'cachekey' do
|
679
732
|
json.name "Cache"
|
680
733
|
end
|
681
734
|
JBUILDER
|
@@ -688,36 +741,34 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
688
741
|
ActiveSupport::Cache.expects :expand_cache_key
|
689
742
|
|
690
743
|
jbuild <<-JBUILDER
|
691
|
-
json.
|
692
|
-
json.content do
|
744
|
+
json.content cache: 'cachekey' do
|
693
745
|
json.name "Cache"
|
694
746
|
end
|
695
747
|
JBUILDER
|
696
748
|
end
|
697
749
|
|
698
|
-
test "current cache digest option accepts options through the last element hash" do
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
end
|
750
|
+
# test "current cache digest option accepts options through the last element hash" do
|
751
|
+
# undef_context_methods :fragment_name_with_digest
|
752
|
+
#
|
753
|
+
# @context.expects(:cache_fragment_name)
|
754
|
+
# .with("cachekey", skip_digest: true)
|
755
|
+
# .returns("cachekey")
|
756
|
+
#
|
757
|
+
# ActiveSupport::Cache.expects :expand_cache_key
|
758
|
+
#
|
759
|
+
# jbuild <<-JBUILDER
|
760
|
+
# json.wrap! :cache, 'cachekey', skip_digest: true
|
761
|
+
# json.content do
|
762
|
+
# json.name "Cache"
|
763
|
+
# end
|
764
|
+
# JBUILDER
|
765
|
+
# end
|
714
766
|
|
715
767
|
test "does not perform caching when controller.perform_caching is false" do
|
716
768
|
controller.perform_caching = false
|
717
769
|
|
718
770
|
result = jbuild <<-JBUILDER
|
719
|
-
json.
|
720
|
-
json.content do
|
771
|
+
json.content cache: 'cachekey' do
|
721
772
|
json.name "Cache"
|
722
773
|
end
|
723
774
|
JBUILDER
|
@@ -738,8 +789,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
738
789
|
@post = BLOG_POST_COLLECTION.first
|
739
790
|
|
740
791
|
result = jbuild(<<-JBUILDER)
|
741
|
-
json.
|
742
|
-
json.post @post, partial: "blog_post", as: :blog_post
|
792
|
+
json.post @post, partial: ["blog_post", as: :blog_post], cache: [['a', 'b']]
|
743
793
|
JBUILDER
|
744
794
|
|
745
795
|
expected = strip_format(<<-JS)
|
@@ -762,13 +812,21 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
762
812
|
@miss = BlogPost.new(2, "miss", "John Smith")
|
763
813
|
|
764
814
|
cat = jbuild(<<-JBUILDER)
|
765
|
-
|
766
|
-
|
815
|
+
opts = {
|
816
|
+
cache: [['a', 'b']],
|
817
|
+
partial: ["blog_post", as: :blog_post]
|
818
|
+
}
|
819
|
+
|
820
|
+
json.post @hit, opts
|
767
821
|
JBUILDER
|
768
822
|
|
769
823
|
result = jbuild(<<-JBUILDER)
|
770
|
-
|
771
|
-
|
824
|
+
opts = {
|
825
|
+
cache: [['a', 'b']],
|
826
|
+
partial: ["blog_post", as: :blog_post]
|
827
|
+
}
|
828
|
+
|
829
|
+
json.post @miss, opts
|
772
830
|
JBUILDER
|
773
831
|
|
774
832
|
expected = strip_format(<<-JS)
|
@@ -787,8 +845,11 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
787
845
|
|
788
846
|
test "render array of partials and caches" do
|
789
847
|
result = jbuild(<<-JBUILDER)
|
790
|
-
|
791
|
-
|
848
|
+
opts = {
|
849
|
+
cache: (->(d){ ['a', d.id] }),
|
850
|
+
partial: ["blog_post", as: :blog_post]
|
851
|
+
}
|
852
|
+
json.array! BLOG_POST_COLLECTION, opts
|
792
853
|
JBUILDER
|
793
854
|
Rails.cache.clear
|
794
855
|
|
@@ -929,8 +990,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
929
990
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
930
991
|
result = jbuild(<<-JBUILDER, breezy_filter: 'hit.hit2')
|
931
992
|
json.hit do
|
932
|
-
json.
|
933
|
-
json.hit2 do
|
993
|
+
json.hit2 cache: 'a' do
|
934
994
|
json.greeting 'hello world'
|
935
995
|
end
|
936
996
|
end
|
@@ -955,14 +1015,14 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
955
1015
|
test "filtering for a node of a AR relation in a tree by id via an appended where clause" do
|
956
1016
|
result = jbuild(<<-JBUILDER, breezy_filter: 'hit.hit2.id=1')
|
957
1017
|
post = Post.create
|
958
|
-
post.
|
959
|
-
post.
|
1018
|
+
post.notes.create title: 'first'
|
1019
|
+
post.notes.create title: 'second'
|
960
1020
|
|
961
|
-
post.
|
1021
|
+
post.notes.expects(:where).once().with('id'=>1).returns([{id: 1, title: 'first'}])
|
962
1022
|
|
963
1023
|
json.hit do
|
964
1024
|
json.hit2 do
|
965
|
-
json.array! post.
|
1025
|
+
json.array! post.notes do |x|
|
966
1026
|
raise 'this should be be called' if x[:title] == 'second'
|
967
1027
|
json.title x[:title]
|
968
1028
|
end
|
@@ -989,15 +1049,15 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
989
1049
|
test "filtering for a node of a AR relation in a tree by index via an appended where clause" do
|
990
1050
|
result = jbuild(<<-JBUILDER, breezy_filter: 'hit.hit2.0')
|
991
1051
|
post = Post.create
|
992
|
-
post.
|
993
|
-
post.
|
1052
|
+
post.notes.create title: 'first'
|
1053
|
+
post.notes.create title: 'second'
|
994
1054
|
|
995
|
-
offset = post.
|
996
|
-
post.
|
1055
|
+
offset = post.notes.offset(0)
|
1056
|
+
post.notes.expects(:offset).once().with(0).returns(offset)
|
997
1057
|
|
998
1058
|
json.hit do
|
999
1059
|
json.hit2 do
|
1000
|
-
json.array! post.
|
1060
|
+
json.array! post.notes do |x|
|
1001
1061
|
raise 'this should be be called' if x[:title] == 'second'
|
1002
1062
|
json.title x[:title]
|
1003
1063
|
end
|
@@ -1080,8 +1140,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1080
1140
|
|
1081
1141
|
result = jbuild(<<-JBUILDER, request: req)
|
1082
1142
|
json.hit do
|
1083
|
-
json.
|
1084
|
-
json.hit2 do
|
1143
|
+
json.hit2(defer: :auto)do
|
1085
1144
|
json.hit3 do
|
1086
1145
|
json.greeting 'hello world'
|
1087
1146
|
end
|
@@ -1111,8 +1170,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1111
1170
|
|
1112
1171
|
result = jbuild(<<-JBUILDER, request: req)
|
1113
1172
|
json.hit do
|
1114
|
-
json.
|
1115
|
-
json.hit2 do
|
1173
|
+
json.hit2 defer: :manual do
|
1116
1174
|
json.hit3 do
|
1117
1175
|
json.greeting 'hello world'
|
1118
1176
|
end
|
@@ -1144,8 +1202,7 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1144
1202
|
json.hit2 do
|
1145
1203
|
data = [{id: 1, name: 'foo'}, {id: 2, name: 'bar'}]
|
1146
1204
|
json.array! data, key: :id do
|
1147
|
-
json.
|
1148
|
-
json.greeting do
|
1205
|
+
json.greeting defer: :auto do
|
1149
1206
|
json.gree 'hi'
|
1150
1207
|
end
|
1151
1208
|
end
|
@@ -1174,7 +1231,6 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1174
1231
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
1175
1232
|
|
1176
1233
|
result = jbuild(<<-JBUILDER)
|
1177
|
-
json.wrap! :defer, :auto
|
1178
1234
|
json.hello(32, defer: :auto)
|
1179
1235
|
JBUILDER
|
1180
1236
|
|
@@ -1193,7 +1249,6 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1193
1249
|
test 'deferment is disabled when filtering by keypath' do
|
1194
1250
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
1195
1251
|
result = jbuild(<<-JBUILDER, breezy_filter: 'hello.world')
|
1196
|
-
json.wrap! :defer, :auto
|
1197
1252
|
json.hello defer: :auto do
|
1198
1253
|
json.world 32
|
1199
1254
|
end
|
@@ -1215,10 +1270,8 @@ class BreezyTemplateTest < ActionView::TestCase
|
|
1215
1270
|
test 'deferment is enabled at the end of a keypath when filtering' do
|
1216
1271
|
undef_context_methods :fragment_name_with_digest, :cache_fragment_name
|
1217
1272
|
result = jbuild(<<-JBUILDER, breezy_filter: 'hello')
|
1218
|
-
json.wrap! :defer, :auto
|
1219
1273
|
json.hello do
|
1220
|
-
json.
|
1221
|
-
json.content do
|
1274
|
+
json.content defer: :auto do
|
1222
1275
|
json.world 32
|
1223
1276
|
end
|
1224
1277
|
end
|