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? %> -