diff --git a/plugins/video/test/unit/video_galery_block_test.rb b/plugins/video/test/unit/video_galery_block_test.rb index 399634c..898a974 100644 --- a/plugins/video/test/unit/video_galery_block_test.rb +++ b/plugins/video/test/unit/video_galery_block_test.rb @@ -21,7 +21,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase content = render_block_content(block) - assert_equal content, "\n" + assert_equal content, "" end should 'render nothing with an empty gallery message when there are no children' do @@ -51,7 +51,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase content = render_block_content(block) - assert_tag_in_string content, tag: 'div', content: "\n #{body}\n " + assert_match body, content assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') end end diff --git a/plugins/video/test/unit/video_galery_test.rb b/plugins/video/test/unit/video_galery_test.rb index 7ed929b..da0a883 100644 --- a/plugins/video/test/unit/video_galery_test.rb +++ b/plugins/video/test/unit/video_galery_test.rb @@ -13,4 +13,25 @@ class VideoGaleryTest < ActiveSupport::TestCase assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.') end + should 'render nothing with an empty gallery message when there are no children' do + video_gallery = VideoPlugin::VideoGallery.new + video_gallery.children = [] + video_gallery.stubs(:body).returns('Video gallery body') + + content = instance_eval(&video_gallery.to_html) + 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 + body = "Video Gallery Body" + video_gallery = VideoPlugin::VideoGallery.new + video_gallery.children = [] + video_gallery.expects(:body).twice.returns(body) + + content = instance_eval(&video_gallery.to_html) + + assert_match body, content + 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 index 6f58485..a9b0ebb 100644 --- a/plugins/video/views/blocks/video_gallery.html.erb +++ b/plugins/video/views/blocks/video_gallery.html.erb @@ -1,18 +1,6 @@ -<% 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 %> + <%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %> - <% 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 new file mode 100644 index 0000000..be6bf4b --- /dev/null +++ b/plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb @@ -0,0 +1 @@ +<%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %> diff --git a/plugins/video/views/shared/_video_gallery.html.erb b/plugins/video/views/shared/_video_gallery.html.erb new file mode 100644 index 0000000..d976ce2 --- /dev/null +++ b/plugins/video/views/shared/_video_gallery.html.erb @@ -0,0 +1,14 @@ +<% 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