Commit 894bfc4855de5583fae37dd224ae21fccb2a980d

Authored by Daniela Feitosa
1 parent 316925ae

video: fix visualization of video gallery article

plugins/video/test/unit/video_galery_block_test.rb
... ... @@ -21,7 +21,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase
21 21  
22 22 content = render_block_content(block)
23 23  
24   - assert_equal content, "\n"
  24 + assert_equal content, ""
25 25 end
26 26  
27 27 should 'render nothing with an empty gallery message when there are no children' do
... ... @@ -51,7 +51,7 @@ class VideoGalleryBlockViewTest < ActionView::TestCase
51 51  
52 52 content = render_block_content(block)
53 53  
54   - assert_tag_in_string content, tag: 'div', content: "\n #{body}\n "
  54 + assert_match body, content
55 55 assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)')
56 56 end
57 57 end
... ...
plugins/video/test/unit/video_galery_test.rb
... ... @@ -13,4 +13,25 @@ class VideoGaleryTest < ActiveSupport::TestCase
13 13 assert_equal VideoPlugin::VideoGallery.description, _('A gallery of link to videos that are hosted elsewhere.')
14 14 end
15 15  
  16 + should 'render nothing with an empty gallery message when there are no children' do
  17 + video_gallery = VideoPlugin::VideoGallery.new
  18 + video_gallery.children = []
  19 + video_gallery.stubs(:body).returns('Video gallery body')
  20 +
  21 + content = instance_eval(&video_gallery.to_html)
  22 + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)')
  23 + end
  24 +
  25 + should 'render the body and a empty gallery message when there are no children' do
  26 + body = "Video Gallery Body"
  27 + video_gallery = VideoPlugin::VideoGallery.new
  28 + video_gallery.children = []
  29 + video_gallery.expects(:body).twice.returns(body)
  30 +
  31 + content = instance_eval(&video_gallery.to_html)
  32 +
  33 + assert_match body, content
  34 + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)')
  35 + end
  36 +
16 37 end
... ...
plugins/video/views/blocks/video_gallery.html.erb
1   -<% extend VideoPlugin::VideoGalleryHelper %>
2   -
3 1 <% if block.video_gallery_id.present?
4 2 video_gallery = VideoPlugin::VideoGallery.find(block.video_gallery_id) %>
5 3  
6   - <% unless video_gallery.body.blank? %>
7   - <div>
8   - <%= video_gallery.body %>
9   - </div>
10   - <hr/>
11   - <% end %>
  4 + <%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %>
12 5  
13   - <% if video_gallery.children.empty? %>
14   - <em><%= _('(empty video gallery)') %></em>
15   - <% else %>
16   - <%= list_videos(:contents=>video_gallery.children) %>
17   - <% end %>
18 6 <% end %>
... ...
plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb 0 → 100644
... ... @@ -0,0 +1 @@
  1 +<%= render :partial => 'shared/video_gallery', :locals => {:video_gallery => video_gallery} %>
... ...
plugins/video/views/shared/_video_gallery.html.erb 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +<% extend VideoPlugin::VideoGalleryHelper %>
  2 +
  3 +<% unless video_gallery.body.blank? %>
  4 + <div>
  5 + <%= video_gallery.body %>
  6 + </div>
  7 + <hr/>
  8 +<% end %>
  9 +
  10 +<% if video_gallery.children.empty? %>
  11 + <em><%= _('(empty video gallery)') %></em>
  12 +<% else %>
  13 + <%= list_videos(:contents=>video_gallery.children) %>
  14 +<% end %>
... ...