diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-05 18:21:13 +0300 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-07-12 15:35:29 +0300 |
commit | 3d2c540db6bb33f1a7be6c1ba375d4f604544862 (patch) | |
tree | 5c293bc8889ac8c5cb8fc8a0e49934d72f0c60a2 /spec/lib/banzai/object_renderer_spec.rb | |
parent | 3ca9253444710c6a2d5ad4dca345f8d558be4f1a (diff) |
Object renderer read_multi rendered entries from Cache
Diffstat (limited to 'spec/lib/banzai/object_renderer_spec.rb')
-rw-r--r-- | spec/lib/banzai/object_renderer_spec.rb | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb index d99175967af..cf6cdd33ebb 100644 --- a/spec/lib/banzai/object_renderer_spec.rb +++ b/spec/lib/banzai/object_renderer_spec.rb @@ -29,7 +29,7 @@ describe Banzai::ObjectRenderer do renderer = described_class.new(project, user) - expect(renderer).to receive(:render_attribute).with(object, :note). + expect(renderer).to receive(:render_attributes).with([object], :note). and_call_original rendered = renderer.render_objects([object], :note) @@ -89,14 +89,25 @@ describe Banzai::ObjectRenderer do end end - describe '#render_attribute' do - it 'renders the attribute of an object' do - object = double(:doc, note: 'hello') + describe '#render_attributes' do + it 'renders the attribute of a list of objects' do + objects = [double(:doc, note: 'hello'), double(:doc, note: 'bye')] renderer = described_class.new(project, user, pipeline: :note) - doc = renderer.render_attribute(object, :note) - expect(doc).to be_an_instance_of(Nokogiri::HTML::DocumentFragment) - expect(doc.to_html).to eq('<p>hello</p>') + expect(Banzai).to receive(:cache_collection_render). + with([ + { text: 'hello', context: renderer.context_for(objects[0], :note) }, + { text: 'bye', context: renderer.context_for(objects[1], :note) } + ]). + and_call_original + + docs = renderer.render_attributes(objects, :note) + + expect(docs[0]).to be_an_instance_of(Nokogiri::HTML::DocumentFragment) + expect(docs[0].to_html).to eq('<p>hello</p>') + + expect(docs[1]).to be_an_instance_of(Nokogiri::HTML::DocumentFragment) + expect(docs[1].to_html).to eq('<p>bye</p>') end end |