diff --git a/plugins/video/lib/video_plugin/video_gallery_block.rb b/plugins/video/lib/video_plugin/video_gallery_block.rb index 41e6219..9a369e2 100644 --- a/plugins/video/lib/video_plugin/video_gallery_block.rb +++ b/plugins/video/lib/video_plugin/video_gallery_block.rb @@ -14,16 +14,6 @@ class VideoPlugin::VideoGalleryBlock < Block _('This block presents a video gallery') end - def content(args={}) - block = self - if video_gallery_id.present? - video_gallery = VideoPlugin::VideoGallery.find(video_gallery_id) - proc do - render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} - end - end - end - def list_my_galleries Article.owner_video_galleries(owner) end diff --git a/plugins/video/test/unit/video_galery_block_test.rb b/plugins/video/test/unit/video_galery_block_test.rb index 1c85249..399634c 100644 --- a/plugins/video/test/unit/video_galery_block_test.rb +++ b/plugins/video/test/unit/video_galery_block_test.rb @@ -10,3 +10,48 @@ class VideoGaleryBlockTest < ActiveSupport::TestCase end end + +require 'boxes_helper' + +class VideoGalleryBlockViewTest < ActionView::TestCase + include BoxesHelper + + should 'render nothing without a video_gallery_id' do + block = VideoPlugin::VideoGalleryBlock.new + + content = render_block_content(block) + + assert_equal content, "\n" + end + + should 'render nothing with an empty gallery message when there are no children' do + block = VideoPlugin::VideoGalleryBlock.new + block.video_gallery_id = 42 + + body = "" + video_gallery = VideoPlugin::VideoGallery.new + video_gallery.children = [] + video_gallery.expects(:body).returns(body) + VideoPlugin::VideoGallery.expects(:find).with(block.video_gallery_id).returns(video_gallery) + + content = render_block_content(block) + + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') + end + + should 'render the body and a empty gallery message when there are no children' do + block = VideoPlugin::VideoGalleryBlock.new + block.video_gallery_id = 42 + + body = "Video Gallery Body" + video_gallery = VideoPlugin::VideoGallery.new + video_gallery.children = [] + video_gallery.expects(:body).twice.returns(body) + VideoPlugin::VideoGallery.expects(:find).with(block.video_gallery_id).returns(video_gallery) + + content = render_block_content(block) + + assert_tag_in_string content, tag: 'div', content: "\n #{body}\n " + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') + end +end diff --git a/plugins/video/views/blocks/video_gallery.html.erb b/plugins/video/views/blocks/video_gallery.html.erb new file mode 100644 index 0000000..6f58485 --- /dev/null +++ b/plugins/video/views/blocks/video_gallery.html.erb @@ -0,0 +1,18 @@ +<% extend VideoPlugin::VideoGalleryHelper %> + +<% if block.video_gallery_id.present? + video_gallery = VideoPlugin::VideoGallery.find(block.video_gallery_id) %> + + <% unless video_gallery.body.blank? %> +