Commit 4f262d0ce11c4a29c031f1efea9ceb0bcdba9700

Authored by Larissa Reis
1 parent 12db0abc

video plugin: Set default thumbnail dimensions to avoid crash with nil value on gallery page

plugins/video/lib/video_plugin/video.rb
... ... @@ -12,8 +12,8 @@ class VideoPlugin::Video < Article
12 12 settings_items :video_format, :type => :string
13 13 settings_items :video_id, :type => :string
14 14 settings_items :video_thumbnail_url, :type => :string, :default => '/plugins/video/images/video_generic_thumbnail.jpg'
15   - settings_items :video_thumbnail_width, :type=> :integer
16   - settings_items :video_thumbnail_height, :type=> :integer
  15 + settings_items :video_thumbnail_width, :type=> :integer, :default => 239
  16 + settings_items :video_thumbnail_height, :type=> :integer, :default => 210
17 17 settings_items :video_duration, :type=> :integer, :default => 0
18 18  
19 19 attr_accessible :video_url
... ... @@ -35,14 +35,14 @@ class VideoPlugin::Video < Article
35 35 def self.description
36 36 _('Display embedded videos.')
37 37 end
38   -
  38 +
39 39 def is_youtube?
40 40 VideoPlugin::Video.is_youtube?(self.video_url)
41 41 end
42 42  
43 43 def is_vimeo?
44 44 VideoPlugin::Video.is_vimeo?(self.video_url)
45   - end
  45 + end
46 46  
47 47 include ActionView::Helpers::TagHelper
48 48 def to_html(options={})
... ...
plugins/video/test/unit/video_test.rb
... ... @@ -46,6 +46,11 @@ class VideoTest < ActiveSupport::TestCase
46 46 assert_equal thumbnail_fitted_height, @video.thumbnail_fitted_height
47 47 end
48 48  
  49 + should "have dimensions of default thumbnail" do
  50 + assert @video.video_thumbnail_height.present? && @video.video_thumbnail_height > 0
  51 + assert @video.video_thumbnail_width.present? && @video.video_thumbnail_width > 0
  52 + end
  53 +
49 54 should "show a no_browser_support_message" do
50 55 assert_equal @video.no_browser_support_message, '<p class="vjs-no-js">To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com/html5-video-support/" target="_blank">supports HTML5 video</a></p>'
51 56 end
... ...