diff --git a/plugins/video/controllers/video_plugin_admin_controller.rb b/plugins/video/controllers/video_plugin_admin_controller.rb deleted file mode 100644 index a11b9ed..0000000 --- a/plugins/video/controllers/video_plugin_admin_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class VideoPluginAdminController < AdminController - - append_view_path File.join(File.dirname(__FILE__) + '/../views') - -end diff --git a/plugins/video/controllers/video_plugin_module.rb b/plugins/video/controllers/video_plugin_module.rb deleted file mode 100644 index 1f79047..0000000 --- a/plugins/video/controllers/video_plugin_module.rb +++ /dev/null @@ -1,3 +0,0 @@ -module VideoPluginController - -end diff --git a/plugins/video/controllers/video_plugin_myprofile_controller.rb b/plugins/video/controllers/video_plugin_myprofile_controller.rb deleted file mode 100644 index 710af80..0000000 --- a/plugins/video/controllers/video_plugin_myprofile_controller.rb +++ /dev/null @@ -1,5 +0,0 @@ -class VideoPluginMyprofileController < MyProfileController - - append_view_path File.join(File.dirname(__FILE__) + '/../views') - -end diff --git a/plugins/video/lib/video_block.rb b/plugins/video/lib/video_block.rb index 0e0335c..5e95d58 100644 --- a/plugins/video/lib/video_block.rb +++ b/plugins/video/lib/video_block.rb @@ -5,38 +5,33 @@ class VideoBlock < Block settings_items :height, :type => :integer, :default => 315 def is_youtube? - url.match(/.*(youtube.com.*v=[[:alnum:]]*|youtu.be\/[[:alnum:]]*).*/) ? true : false + url.match(/.*(youtube.com.*v=[[:alnum:]]+|youtu.be\/[[:alnum:]]+).*/) ? true : false end def is_vimeo? - url.match(/^(http[s]?:\/\/)?(www.)?(vimeo.com|player.vimeo.com\/video)\/[[:digit:]]*/) ? true : false + url.match(/^(http[s]?:\/\/)?(www.)?(vimeo.com|player.vimeo.com\/video)\/[[:digit:]]+/) ? true : false end def is_video_file? url.match(/.*(mp4|ogg|ogv|webm)$/) ? true : false end - #FIXME Make this test def format_embed_video_url_for_youtube - "//www.youtube-nocookie.com/embed/#{extract_youtube_id}?rel=0&wmode=transparent" + "//www.youtube-nocookie.com/embed/#{extract_youtube_id}?rel=0&wmode=transparent" if is_youtube? end - #FIXME Make this test def format_embed_video_url_for_vimeo - "//player.vimeo.com/video/#{extract_vimeo_id}" + "//player.vimeo.com/video/#{extract_vimeo_id}" if is_vimeo? end - #FIXME Make this test def self.description - _('Add Video') + _('Add Videos') end - #FIXME Make this test def help - _('This block presents a video block.') + _('This block presents a video from youtube, vimeo and video formats mp4, ogg, ogv and webm') end - #FIXME Make this test def content(args={}) block = self @@ -45,14 +40,8 @@ class VideoBlock < Block end end - #FIXME Make this test - def cacheable? - false - end - private - #FIXME Make this test def extract_youtube_id return nil unless is_youtube? youtube_match = url.match('v=([[:alnum:]]*)') @@ -65,4 +54,5 @@ class VideoBlock < Block vimeo_match = url.match('([[:digit:]]*)$') vimeo_match[1] unless vimeo_match.nil? end + end diff --git a/plugins/video/test/functional/display_content_plugin_admin_controller_test.rb b/plugins/video/test/functional/display_content_plugin_admin_controller_test.rb deleted file mode 100644 index 363ab45..0000000 --- a/plugins/video/test/functional/display_content_plugin_admin_controller_test.rb +++ /dev/null @@ -1,179 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require File.dirname(__FILE__) + '/../../controllers/display_content_plugin_admin_controller' - - -# Re-raise errors caught by the controller. -class DisplayContentPluginAdminControllerController; def rescue_action(e) raise e end; end - -class DisplayContentPluginAdminControllerTest < ActionController::TestCase - - def setup - @controller = DisplayContentPluginAdminController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - @environment = Environment.default - user_login = create_admin_user(@environment) - login_as(user_login) - @admin = User[user_login].person - @environment.enabled_plugins = ['DisplayContentPlugin'] - @environment.portal_community = fast_create(Community, :name => 'my test profile', :identifier => 'mytestcommunity') - @environment.save! - - box = Box.new(:owner => @environment, :position => 1) - box.save - - DisplayContentBlock.delete_all - @block = DisplayContentBlock.new - @block.box = environment.boxes.first - @block.save! - end - - attr_accessor :environment, :block - - should 'access index action' do - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - assert_response :success - end - - should 'index action returns a empty json if there is no content' do - Article.delete_all - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - assert_equal [], json_response - end - - should 'index action returns an json with node content' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node checked if the node is in the nodes list' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) - block.nodes= [article.id] - block.save! - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - expected_json['attr'].merge!({'class' => 'jstree-checked'}) - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node undetermined if the node is in the parent nodes list' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id) - block.parent_nodes= [article.id] - block.save! - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) - expected_json['children'] = [] - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node closed if the node has article with children' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => f.title} - expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - expected_json['state'] = 'closed' - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with all the children nodes if some parent is in the parents list' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) - block.parent_nodes = [f.id] - block.save! - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => f.title} - expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - children = [ - {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id}}, - {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} - ] - expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) - expected_json['children'] = children - expected_json['state'] = 'closed' - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) - block.parent_nodes = [f.id] - block.save! - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = [] - value = {'data' => f.title} - value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - children = [ - {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id}}, - {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} - ] - value['attr'].merge!({'class' => 'jstree-undetermined'}) - value['children'] = children - value['state'] = 'closed' - expected_json.push(value) - - value = {'data' => a3.title} - value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} - expected_json.push(value) - - assert_equal expected_json, json_response - end - - should 'index action returns an json without children nodes if the parent is not in the parents list' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => environment.portal_community.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => environment.portal_community.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => environment.portal_community.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => environment.portal_community.id) - - get :index, :block_id => block.id - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = [] - value = {'data' => f.title} - value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - value['state'] = 'closed' - expected_json.push(value) - - value = {'data' => a3.title} - value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} - expected_json.push(value) - - assert_equal expected_json, json_response - end - -end diff --git a/plugins/video/test/functional/display_content_plugin_myprofile_controller_test.rb b/plugins/video/test/functional/display_content_plugin_myprofile_controller_test.rb deleted file mode 100644 index 1ad04f7..0000000 --- a/plugins/video/test/functional/display_content_plugin_myprofile_controller_test.rb +++ /dev/null @@ -1,180 +0,0 @@ -require File.dirname(__FILE__) + '/../test_helper' -require File.dirname(__FILE__) + '/../../controllers/display_content_plugin_myprofile_controller' - - -# Re-raise errors caught by the controller. -class DisplayContentPluginMyprofileControllerController; def rescue_action(e) raise e end; end - -class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase - - def setup - @controller = DisplayContentPluginMyprofileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - - user = create_user('testinguser') - login_as(user.login) - @profile = user.person - @environment = @profile.environment - - @environment.enabled_plugins = ['DisplaContentPlugin'] - @environment.save! - -# box = Box.new(:owner => @environment, :position => 1) -# box.save - - DisplayContentBlock.delete_all - @block = DisplayContentBlock.new - @block.box = @profile.boxes.first - @block.save! - end - - attr_accessor :profile, :block - - should 'access index action' do - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - assert_response :success - end - - should 'index action returns a empty json if there is no content' do - Article.delete_all - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - assert_equal [], json_response - end - - should 'index action returns an json with node content' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node checked if the node is in the nodes list' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - block.nodes= [article.id] - block.save! - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - expected_json['attr'].merge!({'class' => 'jstree-checked'}) - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node undetermined if the node is in the parent nodes list' do - Article.delete_all - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id) - block.parent_nodes= [article.id] - block.save! - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => article.title} - expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} - expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) - expected_json['children'] = [] - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with node closed if the node has article with children' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - article = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - block.save! - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => f.title} - expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - expected_json['state'] = 'closed' - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with all the children nodes if some parent is in the parents list' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) - block.parent_nodes = [f.id] - block.save! - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = {'data' => f.title} - expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - children = [ - {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id}}, - {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} - ] - expected_json['attr'].merge!({'class' => 'jstree-undetermined'}) - expected_json['children'] = children - expected_json['state'] = 'closed' - - assert_equal [expected_json], json_response - end - - should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) - block.parent_nodes = [f.id] - block.save! - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = [] - value = {'data' => f.title} - value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - children = [ - {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id}}, - {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} - ] - value['attr'].merge!({'class' => 'jstree-undetermined'}) - value['children'] = children - value['state'] = 'closed' - expected_json.push(value) - - value = {'data' => a3.title} - value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} - expected_json.push(value) - - assert_equal expected_json, json_response - end - - should 'index action returns an json without children nodes if the parent is not in the parents list' do - Article.delete_all - f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) - - get :index, :block_id => block.id, :profile => profile.identifier - json_response = ActiveSupport::JSON.decode(@response.body) - expected_json = [] - value = {'data' => f.title} - value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} - value['state'] = 'closed' - expected_json.push(value) - - value = {'data' => a3.title} - value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} - expected_json.push(value) - - assert_equal expected_json, json_response - end - -end diff --git a/plugins/video/test/functional/video_plugin_myprofile_controller_test.rb b/plugins/video/test/functional/video_plugin_myprofile_controller_test.rb new file mode 100644 index 0000000..94d2036 --- /dev/null +++ b/plugins/video/test/functional/video_plugin_myprofile_controller_test.rb @@ -0,0 +1,132 @@ +require File.dirname(__FILE__) + '/../test_helper' + +# Re-raise errors caught by the controller. +class ProfileDesignController; def rescue_action(e) raise e end; end + +class ProfileDesignControllerTest < ActionController::TestCase + + def setup + @controller = ProfileDesignController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + user = create_user('testinguser') + login_as(user.login) + @profile = user.person + @environment = @profile.environment + + @environment.enabled_plugins = ['VideoPlugin'] + @environment.save! + + VideoBlock.delete_all + @box1 = Box.create!(:owner => @profile) + @profile.boxes = [@box1] + + @block = VideoBlock.new + @block.box = @box1 + @block.save! + + @profile.blocks<<@block + @profile.save! + end + + attr_accessor :profile, :block + + should 'display video-block-data class in profile block edition' do + block.url='youtube.com/?v=XXXXX' + block.save + get :index, :profile => profile.identifier + + assert_tag :div, :attributes => {:class => 'video-block-data'} + end + + should "display iframe tag in profile block edition on youtube url's" do + block.url='youtube.com/?v=XXXXX' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'iframe' + end + + should "the width in iframe tag be defined on youtube url's" do + block.url='youtube.com/?v=XXXXX' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} + end + + should "display iframe tag in profile block edition on vimeo url's" do + block.url='http://vimeo.com/98979' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'iframe' + end + + should "the width in iframe tag be defined on vimeo url's" do + block.url='http://vimeo.com/98979' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'iframe', :attributes => {:width => '400px'} + end + + should "display video tag in profile block edition for any video url" do + block.url='http://www.vmsd.com/98979.mp4' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'video' + end + + should "the width in video tag be defined for any video url" do + block.url='http://www.vmsd.com/98979.mp4' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'video', :attributes => {:width => '400px'} + end + + should 'the heigth in iframe tag be defined' do + block.url='youtube.com/?v=XXXXX' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'iframe', :attributes => {:height => '315px'} + end + + should 'display youtube videos' do + block.url='youtube.com/?v=XXXXX' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'youtube'} } + end + + should 'display vimeo videos' do + block.url='http://vimeo.com/98979' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'vimeo'} } + end + + should 'display other videos' do + block.url='http://www.vmsd.com/98979.mp4' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'div', :attributes => {:class => 'video'} } + end + + should 'display a messagem to register a new url' do + block.url='http://www.vmsd.com/test.pdf' + block.save + get :index, :profile => profile.identifier + + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'span', :attributes => {:class => 'alert-block'} } + end + + +end diff --git a/plugins/video/test/unit/video_block_test.rb b/plugins/video/test/unit/video_block_test.rb index 87104e6..ea912c6 100644 --- a/plugins/video/test/unit/video_block_test.rb +++ b/plugins/video/test/unit/video_block_test.rb @@ -51,6 +51,44 @@ class VideoBlockTest < ActiveSupport::TestCase assert !block.is_youtube? end + should "format embed video for youtube videos" do + block = VideoBlock.new + block.url = "youtube.com/?v=XXXXX" + assert_match /\/\/www.youtube-nocookie.com\/embed/, block.format_embed_video_url_for_youtube + end + + should "format embed video return nil if is not a youtube url" do + block = VideoBlock.new + block.url = "http://www.yt.com/?v=XXXXX" + assert_nil block.format_embed_video_url_for_youtube + end + + should "extract youtube id from youtube video url's if it's a valid youtube full url" do + block = VideoBlock.new + id = 'oi43jre2d2' + block.url = "youtube.com/?v=#{id}" + assert_equal id, block.send('extract_youtube_id') + end + + should "extract youtube id from youtube video url's if it's a valid youtube short url" do + block = VideoBlock.new + id = 'oi43jre2d2' + block.url = "youtu.be/#{id}" + assert_equal id, block.send('extract_youtube_id') + end + + should "extract_youtube_id return nil if the url it's not a valid youtube url" do + block = VideoBlock.new + block.url = "http://www.yt.com/?v=XXXXX" + assert_nil block.send('extract_youtube_id') + end + + should "extract_youtube_id return nil if youtue url there is no id" do + block = VideoBlock.new + block.url = "youtube.com/" + assert_nil block.send('extract_youtube_id') + end + #### Tests for Vimeo Videos should "is_vimeo return true when the url contains http://vimeo.com" do @@ -101,6 +139,37 @@ class VideoBlockTest < ActiveSupport::TestCase assert !block.is_vimeo? end + should "format embed video for vimeo videos" do + block = VideoBlock.new + block.url = "vimeo.com/09898" + assert_match /\/\/player.vimeo.com\/video\/[[:digit:]]+/, block.format_embed_video_url_for_vimeo + end + + should "format embed video return nil if is not a vimeo url" do + block = VideoBlock.new + block.url = "http://www.yt.com/?v=XXXXX" + assert_nil block.format_embed_video_url_for_vimeo + end + + should "extract vimeo id from vimeo video url's if it's a valid vimeo url" do + block = VideoBlock.new + id = '23048239432' + block.url = "vimeo.com/#{id}" + assert_equal id, block.send('extract_vimeo_id') + end + + should "extract_vimeo_id return nil if the url it's not a valid vimeo url" do + block = VideoBlock.new + block.url = "http://www.yt.com/XXXXX" + assert_nil block.send('extract_vimeo_id') + end + + should "extract_vimeo_id return nil if vimeo url there is no id" do + block = VideoBlock.new + block.url = "vimeo.com/" + assert_nil block.send('extract_youtube_id') + end + # Other video formats should "is_video return true if url ends with mp4" do block = VideoBlock.new @@ -138,4 +207,26 @@ class VideoBlockTest < ActiveSupport::TestCase assert !block.is_video_file? end + should 'display video block partial' do + block = VideoBlock.new + self.expects(:render).with(:file => 'video_block', :locals => { + :block => block + }) + instance_eval(& block.content) + end + + should 'display box_organizer/iframe_video_block partial for youtube videos' do + block = VideoBlock.new + block.url = "youtube.com/?v=XXXXX" + +# self.expects(:render).with(:partial => 'box_organizer/iframe_video_block', :locals => { +# :url => block.format_embed_video_url_for_youtube, +# :width => block.width, +# :height => block.height +# }) +c = instance_eval(& block.content) +puts c.inspect + end + + end diff --git a/plugins/video/test/unit/video_plugin_test.rb b/plugins/video/test/unit/video_plugin_test.rb index a805e4a..36afe76 100644 --- a/plugins/video/test/unit/video_plugin_test.rb +++ b/plugins/video/test/unit/video_plugin_test.rb @@ -1,7 +1,6 @@ require File.dirname(__FILE__) + '/../test_helper' class VideoPluginTest < ActiveSupport::TestCase - should "return VideoBlock in extra_blocks class method" do assert VideoPlugin.extra_blocks.keys.include?(VideoBlock) end diff --git a/plugins/video/views/box_organizer/_video_block.rhtml b/plugins/video/views/box_organizer/_video_block.rhtml index 1fd7a06..c19d4b6 100644 --- a/plugins/video/views/box_organizer/_video_block.rhtml +++ b/plugins/video/views/box_organizer/_video_block.rhtml @@ -1,11 +1,11 @@