From 2afc5f95c6ee2b383a312518723cd2065fecccd5 Mon Sep 17 00:00:00 2001 From: Rafael Reggiani Manzo Date: Tue, 3 May 2016 17:12:50 -0300 Subject: [PATCH] Remove VideoGalleryBlock#content method --- plugins/video/lib/video_plugin/video_gallery_block.rb | 10 ---------- plugins/video/test/unit/video_galery_block_test.rb | 45 +++++++++++++++++++++++++++++++++++++++++++++ plugins/video/views/blocks/video_gallery.html.erb | 18 ++++++++++++++++++ plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb | 14 -------------- 4 files changed, 63 insertions(+), 24 deletions(-) create mode 100644 plugins/video/views/blocks/video_gallery.html.erb delete mode 100644 plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb 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? %> +
+ <%= video_gallery.body %> +
+
+ <% end %> + + <% if video_gallery.children.empty? %> + <%= _('(empty video gallery)') %> + <% else %> + <%= list_videos(:contents=>video_gallery.children) %> + <% end %> +<% end %> diff --git a/plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb b/plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb deleted file mode 100644 index d976ce2..0000000 --- a/plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb +++ /dev/null @@ -1,14 +0,0 @@ -<% extend VideoPlugin::VideoGalleryHelper %> - -<% unless video_gallery.body.blank? %> -
- <%= video_gallery.body %> -
-
-<% end %> - -<% if video_gallery.children.empty? %> - <%= _('(empty video gallery)') %> -<% else %> - <%= list_videos(:contents=>video_gallery.children) %> -<% end %> -- libgit2 0.21.2