ref: master
plugins/video/test/unit/video_galery_block_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
require_relative '../test_helper' class VideoGaleryBlockTest < ActiveSupport::TestCase should "define its description" do assert_equal VideoPlugin::VideoGalleryBlock.description, _('Display a Video Gallery') end should "define its help description" do assert_equal VideoPlugin::VideoGalleryBlock.new.help, _('This block presents a video gallery') 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, "" 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_match body, content assert_tag_in_string content, tag: 'em', content: _('(empty video gallery)') end end |