From f13d14b62da2ef4accc57c6b7df6e9013f427b47 Mon Sep 17 00:00:00 2001 From: Steven Miers Date: Mon, 20 Jul 2015 10:45:55 -0500 Subject: [PATCH] Some brief notes on the youtube spec. --- web/spec/features/youtube_spec.rb | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/web/spec/features/youtube_spec.rb b/web/spec/features/youtube_spec.rb index 1fe81bf06..bf93b2451 100644 --- a/web/spec/features/youtube_spec.rb +++ b/web/spec/features/youtube_spec.rb @@ -5,7 +5,9 @@ require 'rest_client' describe "YouTube", :slow=>true, :js=>true, :type => :feature, :capybara_feature => true do subject { page } - before(:all) do + # Authenticate with a test google account. This should create + # a UserAuthorization record, just as if a real user logged into google: + before(:all) do Capybara.javascript_driver = :poltergeist Capybara.current_driver = Capybara.javascript_driver Capybara.default_wait_time = 10 @@ -18,11 +20,13 @@ describe "YouTube", :slow=>true, :js=>true, :type => :feature, :capybara_feature end after(:all) do - @user.destroy - @youtube_client.shutdown + @user.destroy + @youtube_client.shutdown Capybara.run_server = @previous_run_server end + # This test retrieves and verified the signed youtube + # upload URL in the same manner as the JK client: it "should retrieve upload url" do length = 3276 upload_hash=@youtube_client.sign_youtube_upload(@user, "test_video.mp4", length) @@ -38,6 +42,7 @@ describe "YouTube", :slow=>true, :js=>true, :type => :feature, :capybara_feature @youtube_client.verify_youtube_upload(@user, upload_hash['url'], length).should be_false end + # Check that we can actually upload to the signed youtube URL: it "upload url should allow uploading" do vid_path = Rails.root.join('spec', 'files', 'test_video.mp4') length = File.size?(vid_path) @@ -56,14 +61,15 @@ describe "YouTube", :slow=>true, :js=>true, :type => :feature, :capybara_feature RestClient.put(upload_hash['url'], File.read(vid_path)) @youtube_client.verify_youtube_upload(@user, upload_hash['url'], length).should be_true #@youtube_client.youtube_upload_status(@user, upload_hash['url'], length) - end + end + # Ensure that uploading, then verifying and completing the upload sets the appropriate flag: it "sets upload flag when complete" do @music_session = FactoryGirl.create(:active_music_session, :creator => @user, :musician_access => true) @connection = FactoryGirl.create(:connection, :user => @user, :music_session => @music_session) @video_source = FactoryGirl.create(:video_source, :connection => @connection) @recording = FactoryGirl.create(:recording, owner: @user, band: nil, duration:1) - + vid_path = Rails.root.join('spec', 'files', 'test_video.mp4') length = File.size?(vid_path) @@ -72,18 +78,18 @@ describe "YouTube", :slow=>true, :js=>true, :type => :feature, :capybara_feature upload_hash['url'].should_not be_nil RestClient.put(upload_hash['url'], File.read(vid_path)) - recorded_video = FactoryGirl.create(:recorded_video, - recording: @recording, - user: @recording.owner, - fully_uploaded: false, - url: upload_hash['url'], + recorded_video = FactoryGirl.create(:recorded_video, + recording: @recording, + user: @recording.owner, + fully_uploaded: false, + url: upload_hash['url'], length: length ) - + @recording.recorded_videos << recorded_video @youtube_client.verify_youtube_upload(@user, upload_hash['url'], length).should be_true @youtube_client.complete_upload(recorded_video).should be_true - recorded_video.fully_uploaded.should be_true + recorded_video.fully_uploaded.should be_true end end