Commit 2afc5f95c6ee2b383a312518723cd2065fecccd5
1 parent
e4788a5f
Exists in
send_email_to_admins
and in
5 other branches
Remove VideoGalleryBlock#content method
This is no longer necessary as this logic is now at BoxesHelper. In order to ensure a proper refactor unit tests were added and the view has been moved and renamed accordingly to BoxesHelper expectations.
Showing
4 changed files
with
63 additions
and
24 deletions
Show diff stats
plugins/video/lib/video_plugin/video_gallery_block.rb
... | ... | @@ -14,16 +14,6 @@ class VideoPlugin::VideoGalleryBlock < Block |
14 | 14 | _('This block presents a video gallery') |
15 | 15 | end |
16 | 16 | |
17 | - def content(args={}) | |
18 | - block = self | |
19 | - if video_gallery_id.present? | |
20 | - video_gallery = VideoPlugin::VideoGallery.find(video_gallery_id) | |
21 | - proc do | |
22 | - render :partial => 'content_viewer/video_plugin/video_gallery', :locals => {:video_gallery => video_gallery} | |
23 | - end | |
24 | - end | |
25 | - end | |
26 | - | |
27 | 17 | def list_my_galleries |
28 | 18 | Article.owner_video_galleries(owner) |
29 | 19 | end | ... | ... |
plugins/video/test/unit/video_galery_block_test.rb
... | ... | @@ -10,3 +10,48 @@ class VideoGaleryBlockTest < ActiveSupport::TestCase |
10 | 10 | end |
11 | 11 | |
12 | 12 | end |
13 | + | |
14 | +require 'boxes_helper' | |
15 | + | |
16 | +class VideoGalleryBlockViewTest < ActionView::TestCase | |
17 | + include BoxesHelper | |
18 | + | |
19 | + should 'render nothing without a video_gallery_id' do | |
20 | + block = VideoPlugin::VideoGalleryBlock.new | |
21 | + | |
22 | + content = render_block_content(block) | |
23 | + | |
24 | + assert_equal content, "\n" | |
25 | + end | |
26 | + | |
27 | + should 'render nothing with an empty gallery message when there are no children' do | |
28 | + block = VideoPlugin::VideoGalleryBlock.new | |
29 | + block.video_gallery_id = 42 | |
30 | + | |
31 | + body = "" | |
32 | + video_gallery = VideoPlugin::VideoGallery.new | |
33 | + video_gallery.children = [] | |
34 | + video_gallery.expects(:body).returns(body) | |
35 | + VideoPlugin::VideoGallery.expects(:find).with(block.video_gallery_id).returns(video_gallery) | |
36 | + | |
37 | + content = render_block_content(block) | |
38 | + | |
39 | + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') | |
40 | + end | |
41 | + | |
42 | + should 'render the body and a empty gallery message when there are no children' do | |
43 | + block = VideoPlugin::VideoGalleryBlock.new | |
44 | + block.video_gallery_id = 42 | |
45 | + | |
46 | + body = "Video Gallery Body" | |
47 | + video_gallery = VideoPlugin::VideoGallery.new | |
48 | + video_gallery.children = [] | |
49 | + video_gallery.expects(:body).twice.returns(body) | |
50 | + VideoPlugin::VideoGallery.expects(:find).with(block.video_gallery_id).returns(video_gallery) | |
51 | + | |
52 | + content = render_block_content(block) | |
53 | + | |
54 | + assert_tag_in_string content, tag: 'div', content: "\n #{body}\n " | |
55 | + assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') | |
56 | + end | |
57 | +end | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +<% extend VideoPlugin::VideoGalleryHelper %> | |
2 | + | |
3 | +<% if block.video_gallery_id.present? | |
4 | + video_gallery = VideoPlugin::VideoGallery.find(block.video_gallery_id) %> | |
5 | + | |
6 | + <% unless video_gallery.body.blank? %> | |
7 | + <div> | |
8 | + <%= video_gallery.body %> | |
9 | + </div> | |
10 | + <hr/> | |
11 | + <% end %> | |
12 | + | |
13 | + <% if video_gallery.children.empty? %> | |
14 | + <em><%= _('(empty video gallery)') %></em> | |
15 | + <% else %> | |
16 | + <%= list_videos(:contents=>video_gallery.children) %> | |
17 | + <% end %> | |
18 | +<% end %> | ... | ... |
plugins/video/views/content_viewer/video_plugin/_video_gallery.html.erb
... | ... | @@ -1,14 +0,0 @@ |
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 %> |