Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Seth Call 2015-07-20 11:38:16 -05:00
commit 03e8b1e036
1 changed files with 18 additions and 12 deletions

View File

@ -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