From ba4f52d8089d287b9853de1199398f733623ce1a Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Tue, 29 Oct 2013 13:23:15 -0300 Subject: [PATCH] Adding functional tests with design controllers to make sure that the videos are being displayed --- plugins/video/README | 30 +++++++----------------------- plugins/video/test/functional/video_plugin_environment_design_controller_test.rb | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/video/test/functional/video_plugin_myprofile_controller_test.rb | 132 ------------------------------------------------------------------------------------------------------------------------------------ plugins/video/test/functional/video_plugin_profile_design_controller_test.rb | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ plugins/video/test/unit/video_block_test.rb | 14 -------------- 5 files changed, 269 insertions(+), 169 deletions(-) create mode 100644 plugins/video/test/functional/video_plugin_environment_design_controller_test.rb delete mode 100644 plugins/video/test/functional/video_plugin_myprofile_controller_test.rb create mode 100644 plugins/video/test/functional/video_plugin_profile_design_controller_test.rb diff --git a/plugins/video/README b/plugins/video/README index 1344ccb..13c2998 100644 --- a/plugins/video/README +++ b/plugins/video/README @@ -1,15 +1,9 @@ -README - DisplayContent (DisplayContent Plugin) +README - Video (Video Plugin) ================================ -DisplayContent is a plugin to allow the user adds a block where you could choose any of your content for display it. +Video is a plugin to allow the user adds a block where you could choose any url from youtube, vimeo and url's of the following file formats: mp4, ogg, ogv and webm. -The DisplayContent block will be available for all layout columns of communities, peole, enterprises and environments. - -All the articles choosen are displayed as a list with a link for the title and the lead content. - -If a Blog or a Folder is choosen the block will display all articles inside the blog or the folder. - -Galleries are not displayed in this block. +The Video block will be available for all layout columns of communities, peole, enterprises and environments. INSTALL ======= @@ -17,10 +11,10 @@ INSTALL Enable Plugin ------------- -Also, you need to enable DisplayContent Plugin at you Noosfero: +Also, you need to enable Video Plugin at you Noosfero: cd -./script/noosfero-plugins enable display_content +./script/noosfero-plugins enable video Active Plugin ------------- @@ -30,20 +24,10 @@ As a Noosfero administrator user, go to administrator panel: - Click on "Enable/disable plugins" option - Click on "Display Content Plugin" check-box -DEVELOPMENT -=========== - -Noosfero uses jQuery 1.5.1 and the jsTree doesn't works fine with this jQuery version. -Until Noosfero upgrade its JQuery version to a newer one is necessary to load jQuery 1.8.3 inside plugin and apply some changes in jsTree to avoid jQuery conflit. - -Get the Display Content (Noosfero with Display Content Plugin) development repository: - -$ git clone https://gitorious.org/+noosfero/noosfero/display_content - -Running DisplayContent tests +Running Video tests -------------------- -$ rake test:noosfero_plugins:display_content +$ rake test:noosfero_plugins:video Get Involved diff --git a/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb b/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb new file mode 100644 index 0000000..9f31007 --- /dev/null +++ b/plugins/video/test/functional/video_plugin_environment_design_controller_test.rb @@ -0,0 +1,130 @@ +require File.dirname(__FILE__) + '/../test_helper' + +# Re-raise errors caught by the controller. +class EnvironmentDesignController; def rescue_action(e) raise e end; end + +class EnvironmentDesignControllerTest < ActionController::TestCase + + def setup + @controller = EnvironmentDesignController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + + Environment.delete_all + User.delete_all + @environment = Environment.create!(defaults_for_environment.merge(:is_default => true)) + user = create_user('testinguser') + login_as(user.person.identifier) + @environment.add_admin(user.person) + @environment.save! + + @environment.enabled_plugins = ['VideoPlugin'] + @environment.save! + + VideoBlock.delete_all + + @block = VideoBlock.new + @block.box = @environment.boxes.first + @block.save! + end + + attr_accessor :environment, :block + + should 'display video-block-data class in profile block edition' do + block.url='youtube.com/?v=XXXXX' + block.save! + get :index + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + 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 + + assert_tag :tag => 'iframe', :attributes => {:height => '315px'} + end + + should 'display youtube videos' do + block.url='youtube.com/?v=XXXXX' + block.save + get :index + + 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 + + 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 + + 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 + + assert_tag :tag => 'div', :attributes => {:class => 'video-block-data'}, :descendant => { :tag => 'span', :attributes => {:class => 'alert-block'} } + 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 deleted file mode 100644 index 94d2036..0000000 --- a/plugins/video/test/functional/video_plugin_myprofile_controller_test.rb +++ /dev/null @@ -1,132 +0,0 @@ -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/functional/video_plugin_profile_design_controller_test.rb b/plugins/video/test/functional/video_plugin_profile_design_controller_test.rb new file mode 100644 index 0000000..94d2036 --- /dev/null +++ b/plugins/video/test/functional/video_plugin_profile_design_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 ea912c6..601af9b 100644 --- a/plugins/video/test/unit/video_block_test.rb +++ b/plugins/video/test/unit/video_block_test.rb @@ -215,18 +215,4 @@ class VideoBlockTest < ActiveSupport::TestCase 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 -- libgit2 0.21.2