diff --git a/db/up/mixdown.sql b/db/up/mixdown.sql index 5adb15684..7c72e03e8 100644 --- a/db/up/mixdown.sql +++ b/db/up/mixdown.sql @@ -49,4 +49,13 @@ ALTER TABLE notifications ADD COLUMN jam_track_mixdown_package_id VARCHAR(64) RE ALTER TABLE jam_track_mixdown_packages ADD COLUMN last_errored_at TIMESTAMP; ALTER TABLE jam_track_mixdown_packages ADD COLUMN queued BOOLEAN DEFAULT FALSE; -ALTER TABLE jam_track_rights ADD COLUMN queued BOOLEAN DEFAULT FALSE; \ No newline at end of file +ALTER TABLE jam_track_mixdown_packages ADD COLUMN speed_pitched BOOLEAN DEFAULT FALSE; +ALTER TABLE jam_track_rights ADD COLUMN queued BOOLEAN DEFAULT FALSE; + +CREATE INDEX jam_track_rights_queued ON jam_track_rights(queued); +CREATE INDEX jam_track_rights_signing_queued ON jam_track_rights(signing_queued_at); +CREATE INDEX jam_track_rights_updated ON jam_track_rights(updated_at); + +CREATE INDEX jam_track_mixdown_packages_queued ON jam_track_mixdown_packages(queued); +CREATE INDEX jam_track_mixdown_packages_signing_queued ON jam_track_mixdown_packages(signing_queued_at); +CREATE INDEX jam_track_mixdown_packages_updated ON jam_track_mixdown_packages(updated_at); \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/crash_dump.rb b/ruby/lib/jam_ruby/models/crash_dump.rb index 6c4e54d84..bab31fd97 100644 --- a/ruby/lib/jam_ruby/models/crash_dump.rb +++ b/ruby/lib/jam_ruby/models/crash_dump.rb @@ -15,7 +15,7 @@ module JamRuby before_validation(:on => :create) do self.created_at ||= Time.now self.id = SecureRandom.uuid - self.uri = "dump/#{self.id}-#{self.created_at.to_i}" + self.uri = "dump/#{created_at.strftime('%Y-%m-%d')}/#{self.id}" end def user_email diff --git a/ruby/lib/jam_ruby/models/jam_track.rb b/ruby/lib/jam_ruby/models/jam_track.rb index 1f826a621..3bf55444d 100644 --- a/ruby/lib/jam_ruby/models/jam_track.rb +++ b/ruby/lib/jam_ruby/models/jam_track.rb @@ -454,7 +454,6 @@ module JamRuby def generate_slug self.slug = sluggarize(original_artist) + '-' + sluggarize(name) - end end diff --git a/ruby/lib/jam_ruby/models/jam_track_mixdown.rb b/ruby/lib/jam_ruby/models/jam_track_mixdown.rb index 3c6a30bc8..59527b659 100644 --- a/ruby/lib/jam_ruby/models/jam_track_mixdown.rb +++ b/ruby/lib/jam_ruby/models/jam_track_mixdown.rb @@ -49,10 +49,13 @@ module JamRuby # the user has to specify at least at least one tweak to volume, speed, pitch, pan. otherwise there is nothing to do - tweaked = false - all_quiet = true - parsed = JSON.parse(self.settings) + specified_track_count = parsed["tracks"] ? parsed["tracks"].length : 0 + + tweaked = false + all_quiet = jam_track.stem_tracks.length == 0 ? false : jam_track.stem_tracks.length == specified_track_count # we already say 'all_quiet is false' if the user did not specify as many tracks as there are on the JamTrack, because omission implies 'include this track' + + if parsed["speed"] tweaked = true end diff --git a/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb b/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb index 4233fcfe9..687727f4c 100644 --- a/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb +++ b/ruby/lib/jam_ruby/models/jam_track_mixdown_package.rb @@ -37,19 +37,15 @@ module JamRuby MAX_JAM_TRACK_DOWNLOADS = 1000 - def estimated_queue_time + def self.estimated_queue_time jam_track_signing_count = JamTrackRight.where(queued: true).count - mixdowns = JamTrackMixdownPackage.select('count(queued) as queue_count, count(speed_pitched) as speed_pitch_count').where(queued: true).first - total_mixdowns = mixdowns['queue_count'] - slow_mixdowns = mixdowns['speed_pitch_count'] + mixdowns = JamTrackMixdownPackage.unscoped.select('count(CASE WHEN queued THEN 1 ELSE NULL END) as queue_count, count(CASE WHEN speed_pitched THEN 1 ELSE NULL END) as speed_pitch_count').where(queued: true).first + total_mixdowns = mixdowns['queue_count'].to_i + slow_mixdowns = mixdowns['speed_pitch_count'].to_i fast_mixdowns = total_mixdowns - slow_mixdowns guess = APP_CONFIG.estimated_jam_track_time * jam_track_signing_count + APP_CONFIG.estimated_fast_mixdown_time * fast_mixdowns + APP_CONFIG.estimated_slow_mixdown_time * slow_mixdowns - # knock off about a minute based on number of nodes - guess = guess - ((APP_CONFIG.num_signing_nodes - 1) * 60) - guess = 0 if guess < 0 - Stats.write('web.jam_track.queue_time', {value: guess / 60.0, jam_tracks: jam_track_signing_count, slow_mixdowns: slow_mixdowns, fast_mixdowns: fast_mixdowns}) guess end @@ -66,6 +62,7 @@ module JamRuby def self.create(mixdown, file_type, sample_rate, encrypt_type) package = JamTrackMixdownPackage.new + package.speed_pitched = mixdown.will_pitch_shift? package.jam_track_mixdown = mixdown package.file_type = file_type package.sample_rate = sample_rate @@ -148,11 +145,14 @@ module JamRuby self.signing_queued_at = Time.now self.signing_started_at = nil self.last_signed_at = nil + self.queued = true self.save + queue_time = JamTrackMixdownPackage.estimated_queue_time + # is_pitch_speed_shifted? Resque.enqueue(JamTrackMixdownPackager, self.id) - true + return queue_time rescue Exception => e puts "e: #{e}" # implies redis is down. we don't update started_at by bailing out here @@ -166,8 +166,7 @@ module JamRuby if state == 'SIGNED' || state == 'SIGNING' || state == 'QUEUED' false else - enqueue - true + return enqueue end end @@ -233,10 +232,10 @@ module JamRuby def self.stats stats = {} - result = JamTrackMixdownPackage.select('count(id) as total, count(CASE WHEN signing THEN 1 ELSE NULL END) as signing_count').first + result = JamTrackMixdownPackage.unscoped.select('count(id) as total, count(CASE WHEN signing THEN 1 ELSE NULL END) as signing_count') - stats['count'] = result['total'].to_i - stats['signing_count'] = result['signing_count'].to_i + stats['count'] = result[0]['total'].to_i + stats['signing_count'] = result[0]['signing_count'].to_i stats end diff --git a/ruby/lib/jam_ruby/models/jam_track_right.rb b/ruby/lib/jam_ruby/models/jam_track_right.rb index af45a4360..78df7f9c1 100644 --- a/ruby/lib/jam_ruby/models/jam_track_right.rb +++ b/ruby/lib/jam_ruby/models/jam_track_right.rb @@ -66,6 +66,7 @@ module JamRuby def finish_errored(error_reason, error_detail, sample_rate) self.last_signed_at = Time.now + self.queued = false self.error_count = self.error_count + 1 self.error_reason = error_reason self.error_detail = error_detail @@ -85,6 +86,7 @@ module JamRuby def finish_sign(length, md5, bitrate) self.last_signed_at = Time.now + self.queued = false if bitrate==48 self.length_48 = length self.md5_48 = md5 @@ -120,7 +122,7 @@ module JamRuby def enqueue(sample_rate=48) begin - JamTrackRight.where(:id => self.id).update_all(:signing_queued_at => Time.now, :signing_started_at_44 => nil, :signing_started_at_48 => nil, :last_signed_at => nil) + JamTrackRight.where(:id => self.id).update_all(:signing_queued_at => Time.now, :signing_started_at_44 => nil, :signing_started_at_48 => nil, :last_signed_at => nil, :queued => true) Resque.enqueue(JamTracksBuilder, self.id, sample_rate) true rescue Exception => e diff --git a/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb b/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb index 20b13dc2b..1d54bf67d 100644 --- a/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb +++ b/ruby/lib/jam_ruby/resque/jam_track_mixdown_packager.rb @@ -73,6 +73,7 @@ module JamRuby @mixdown_package.signing = true @mixdown_package.should_retry = false @mixdown_package.last_step_at = last_step_at + @mixdown_package.queued = false @mixdown_package.save SubscriptionMessage.mixdown_signing_job_change(@mixdown_package) diff --git a/ruby/lib/jam_ruby/resque/jam_tracks_builder.rb b/ruby/lib/jam_ruby/resque/jam_tracks_builder.rb index 359bdc514..381bb8b83 100644 --- a/ruby/lib/jam_ruby/resque/jam_tracks_builder.rb +++ b/ruby/lib/jam_ruby/resque/jam_tracks_builder.rb @@ -42,7 +42,7 @@ module JamRuby signing_started_model_symbol = bitrate == 48 ? :signing_started_at_48 : :signing_started_at_44 signing_state_symbol = bitrate == 48 ? :signing_48 : :signing_44 last_step_at = Time.now - JamTrackRight.where(:id => @jam_track_right.id).update_all(signing_started_model_symbol => signing_started_at, :should_retry => false, packaging_steps: total_steps, current_packaging_step: 0, last_step_at: last_step_at, signing_state_symbol => true) + JamTrackRight.where(:id => @jam_track_right.id).update_all(signing_started_model_symbol => signing_started_at, :should_retry => false, packaging_steps: total_steps, current_packaging_step: 0, last_step_at: last_step_at, signing_state_symbol => true, queued: false) # because we are skipping 'after_save', we have to keep the model current for the notification. A bit ugly... @jam_track_right.current_packaging_step = 0 @jam_track_right.packaging_steps = total_steps @@ -50,6 +50,7 @@ module JamRuby @jam_track_right[signing_state_symbol] = true @jam_track_right.should_retry = false @jam_track_right.last_step_at = Time.now + @jam_track_right.queued = false SubscriptionMessage.jam_track_signing_job_change(@jam_track_right) JamRuby::JamTracksManager.save_jam_track_right_jkz(@jam_track_right, self.bitrate) diff --git a/ruby/lib/jam_ruby/resque/scheduled/jam_tracks_cleaner.rb b/ruby/lib/jam_ruby/resque/scheduled/jam_tracks_cleaner.rb index 5039fc862..7449d6f0e 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/jam_tracks_cleaner.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/jam_tracks_cleaner.rb @@ -24,6 +24,11 @@ module JamRuby def perform # this needs more testing + + # let's make sure jobs don't stay falsely queued for too long. 1 hour seems more than enough + JamTrackRight.where("queued = true AND (NOW() - signing_queued_at > '1 hour'::INTERVAL OR NOW() - updated_at > '1 hour'::INTERVAL").update_all(queued:false) + JamTrackRightMixdown.unscoped.where("queued = true AND (NOW() - signing_queued_at > '1 hour'::INTERVAL OR NOW() - updated_at > '1 hour'::INTERVAL").update_all(queued:false) + return #JamTrackRight.ready_to_clean.each do |jam_track_right| # log.debug("deleting files for jam_track_right #{jam_track_right.id}") diff --git a/ruby/spec/jam_ruby/models/jam_track_mixdown_package_spec.rb b/ruby/spec/jam_ruby/models/jam_track_mixdown_package_spec.rb index 53d14b5e2..3a90ffcc3 100644 --- a/ruby/spec/jam_ruby/models/jam_track_mixdown_package_spec.rb +++ b/ruby/spec/jam_ruby/models/jam_track_mixdown_package_spec.rb @@ -12,7 +12,6 @@ describe JamTrackMixdownPackage do package = JamTrackMixdownPackage.create(mixdown, JamTrackMixdownPackage::FILE_TYPE_OGG, 48, 'jkz') - puts package.errors.inspect package.errors.any?.should == false end @@ -34,12 +33,12 @@ describe JamTrackMixdownPackage do end it "signing" do - package = FactoryGirl.create(:jam_track_mixdown_package, signing_started_at: Time.now, packaging_steps: 3, current_packaging_step:0, last_step_at:Time.now) + package = FactoryGirl.create(:jam_track_mixdown_package, signing:true, signing_started_at: Time.now, packaging_steps: 3, current_packaging_step:0, last_step_at:Time.now) package.signing_state.should eq('SIGNING') end it "signing timeout" do - package = FactoryGirl.create(:jam_track_mixdown_package, signing_started_at: Time.now - 100, packaging_steps: 3, current_packaging_step:0, last_step_at:Time.now) + package = FactoryGirl.create(:jam_track_mixdown_package, signing: true, signing_started_at: Time.now - (APP_CONFIG.signing_job_signing_max_time + 1), packaging_steps: 3, current_packaging_step:0, last_step_at:Time.now) package.signing_state.should eq('SIGNING_TIMEOUT') end @@ -49,7 +48,7 @@ describe JamTrackMixdownPackage do end it "signing timeout" do - package = FactoryGirl.create(:jam_track_mixdown_package, signing_queued_at: Time.now - (APP_CONFIG.signing_job_queue_max_time + 1)) + package = FactoryGirl.create(:jam_track_mixdown_package, signing_queued_at: Time.now - (APP_CONFIG.mixdown_job_queue_max_time + 1)) package.signing_state.should eq('QUEUED_TIMEOUT') end end @@ -74,6 +73,30 @@ describe JamTrackMixdownPackage do end describe "estimated_queue_time" do + it "succeeds with no data" do + JamTrackMixdownPackage.estimated_queue_time.should eq(0) + end + + it "mixdown packages of different sorts" do + package = FactoryGirl.create(:jam_track_mixdown_package, speed_pitched: true) + JamTrackMixdownPackage.estimated_queue_time.should eq(0) + + package.queued = true + package.save! + JamTrackMixdownPackage.estimated_queue_time.should eq(APP_CONFIG.estimated_slow_mixdown_time * 1) + + package.speed_pitched = false + package.save! + + JamTrackMixdownPackage.estimated_queue_time.should eq(APP_CONFIG.estimated_fast_mixdown_time * 1) + + right = FactoryGirl.create(:jam_track_right) + JamTrackMixdownPackage.estimated_queue_time.should eq(APP_CONFIG.estimated_fast_mixdown_time * 1) + + right.queued = true + right.save! + JamTrackMixdownPackage.estimated_queue_time.should eq(APP_CONFIG.estimated_fast_mixdown_time * 1 + APP_CONFIG.estimated_jam_track_time * 1) + end end end diff --git a/ruby/spec/support/utilities.rb b/ruby/spec/support/utilities.rb index ad6f0b2c1..d909b57d2 100644 --- a/ruby/spec/support/utilities.rb +++ b/ruby/spec/support/utilities.rb @@ -179,7 +179,7 @@ def app_config end def signing_job_queue_max_time - 20 # 20 seconds + 600 # 20 seconds end def one_free_jamtrack_per_user @@ -226,6 +226,18 @@ def app_config 2 end + def signing_job_signing_max_time + 300 + end + + def mixdown_job_queue_max_time + 600 + end + + def mixdown_step_max_time + 300 + end + private def audiomixer_workspace_path diff --git a/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee b/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee index 97bf2f218..a15428170 100644 --- a/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/PopupMediaControls.js.jsx.coffee @@ -301,25 +301,24 @@ mixins.push(Reflux.listenTo(JamTrackStore, 'onJamTrackChanged')) ` - if @state.showMyMixes - showMyMixesText = 'hide my mixes' + showMyMixesText = `hide my mixes
` else - showMyMixesText = 'show my mixes' + showMyMixesText = `show my mixes
` if @state.showCustomMixes - showMixControlsText = 'hide mix controls' + showMixControlsText = `hide mix controls
` else - showMixControlsText = 'show mix controls' + showMixControlsText = `show mix controls
` extraControls = `
-

My Mixes {showMyMixesText}

+

My Mixes {showMyMixesText}

{myMixes} -

Create Custom Mix {showMixControlsText}

+

Create Custom Mix {showMixControlsText}

{mixControls} @@ -436,7 +435,24 @@ mixins.push(Reflux.listenTo(JamTrackStore, 'onJamTrackChanged')) return unless action? if confirm(action) - JamTrackMixdownActions.enqueueMixdown(mixdown) + JamTrackMixdownActions.enqueueMixdown(mixdown, @enqueueDone) + + enqueueDone: (enqueued) -> + @promptEstimate(enqueued) + + promptEstimate: (enqueued) -> + time = enqueued.queue_time + + if time == 0 + alert("It will take approximately 1 minute to create your custom mix.") + else + guess = Math.ceil(time / 60.0) + if guess == 1 + msg = '1 minute' + else + msg = "#{guess} minutes" + alert("Your custom mix will take approximately #{msg} to be created.") + createMix: (e) -> e.preventDefault() @@ -478,6 +494,8 @@ mixins.push(Reflux.listenTo(JamTrackStore, 'onJamTrackChanged')) # automatically close the create custom mix area @setState({creatingMixdown: false, showCustomMixes: false, showMyMixes: true}) + @promptEstimate(created) + createMixdownFail: (jqXHR) -> logger.debug("create mixdown fail (within PopupMediaControls)", jqXHR.status) @setState({creatingMixdown: false}) diff --git a/web/app/assets/stylesheets/minimal/media_controls.css.scss b/web/app/assets/stylesheets/minimal/media_controls.css.scss index ee4290fd6..b8079dd95 100644 --- a/web/app/assets/stylesheets/minimal/media_controls.css.scss +++ b/web/app/assets/stylesheets/minimal/media_controls.css.scss @@ -222,4 +222,27 @@ body.media-controls-popup.popup { } } } + + .arrow-down { + float:none; + margin-left:5px; + margin-top:0; + margin-right:0; + border-top: 4px solid #fc0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + display:inline-block; + padding-top:1px; + } + .arrow-up { + float:none; + margin-right:0; + margin-left:5px; + margin-bottom:2px; + border-bottom: 4px solid #fc0; + border-left: 4px solid transparent; + border-right: 4px solid transparent; + display:inline-block; + padding-top:1px; + } } \ No newline at end of file diff --git a/web/app/controllers/api_jam_track_mixdowns_controller.rb b/web/app/controllers/api_jam_track_mixdowns_controller.rb index 2da9c9ff3..a38c2f734 100644 --- a/web/app/controllers/api_jam_track_mixdowns_controller.rb +++ b/web/app/controllers/api_jam_track_mixdowns_controller.rb @@ -114,6 +114,7 @@ class ApiJamTrackMixdownsController < ApiController enqueued = @package.enqueue_if_needed log.debug("jamtrack mixdown #{enqueued ? "ENQUEUED" : "NOT ENQUEUED"}: mixdown_package=#{@package.id} ") + @queue_time = enqueued ? enqueued : 0 return else render :json => { :message => "download limit surpassed", :errors=>@package.errors }, :status => 403 diff --git a/web/app/controllers/api_search_controller.rb b/web/app/controllers/api_search_controller.rb index 54e3ab5b0..d9a362d36 100644 --- a/web/app/controllers/api_search_controller.rb +++ b/web/app/controllers/api_search_controller.rb @@ -7,7 +7,7 @@ class ApiSearchController < ApiController def index if 1 == params[Search::PARAM_MUSICIAN].to_i || 1 == params[Search::PARAM_BAND].to_i - query = parasobj.clone + query = params.clone query[:remote_ip] = request.remote_ip if 1 == query[Search::PARAM_MUSICIAN].to_i @search = Search.musician_filter(query, current_user) diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 18c2db8f8..a9640ba45 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -1,5 +1,6 @@ require 'sanitize' -class ApiUsersController < ApiController +class +ApiUsersController < ApiController before_filter :api_signed_in_user, :except => [:create, :calendar, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring, :add_play, :crash_dump, :validate_data] before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete, @@ -575,14 +576,14 @@ class ApiUsersController < ApiController # This should largely be moved into a library somewhere in jam-ruby. def crash_dump # example of using curl to access this API: - # curl -L -T some_file -X PUT http://localhost:3000/api/dumps?client_type=[MACOSX/Win32/JamBox]&client_version=[VERSION]&client_id=[CLIENT_ID]&session_id=[SESSION_ID]×tamp=[TIMESTAMP] + # curl -L -T some_file -X PUT http://localhost:3000/api/dumps?client_type=[MacOSX/Win32/JamBox]&client_version=[VERSION]&client_id=[CLIENT_ID]&session_id=[SESSION_ID]×tamp=[TIMESTAMP] # user_id is deduced if possible from the user's cookie. @dump = CrashDump.new @dump.client_type = params[:client_type] @dump.client_version = params[:client_version] @dump.client_id = params[:client_id] - @dump.user_id = current_user.try(:id) + @dump.user_id = params[:user_id] @dump.session_id = params[:session_id] @dump.timestamp = params[:timestamp] @@ -603,7 +604,7 @@ class ApiUsersController < ApiController read_url = bucket.objects[uri].url_for(:read, :expires => expire, :'response_content_type' => 'application/octet-stream').to_s - @dump.update_attribute(:uri, read_url) + #@dump.update_attribute(:uri, read_url) write_url = bucket.objects[uri].url_for(:write, :expires => Rails.application.config.crash_dump_data_signed_url_timeout, diff --git a/web/app/views/api_jam_track_mixdowns/enqueue.rabl b/web/app/views/api_jam_track_mixdowns/enqueue.rabl index bcf0d7191..5fde4660c 100644 --- a/web/app/views/api_jam_track_mixdowns/enqueue.rabl +++ b/web/app/views/api_jam_track_mixdowns/enqueue.rabl @@ -1,3 +1,7 @@ object @package +node :queue_time do + @queue_time +end + extends "api_jam_track_mixdowns/show_package" \ No newline at end of file diff --git a/web/config/routes.rb b/web/config/routes.rb index cef2252c1..e14387176 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -577,7 +577,7 @@ SampleApp::Application.routes.draw do match '/artifacts/clients' => 'artifacts#client_downloads' # crash logs - match '/dumps' => 'api_users#crash_dump', :via => :put + match '/crashes' => 'api_users#crash_dump', :via => :put # feedback from corporate site api match '/feedback' => 'api_corporate#feedback', :via => :post diff --git a/web/config/scheduler.yml b/web/config/scheduler.yml index ea694ba60..339dfd4f6 100644 --- a/web/config/scheduler.yml +++ b/web/config/scheduler.yml @@ -16,9 +16,9 @@ IcecastSourceCheck: description: "Finds icecast mounts that need their 'sourced' state to change, but haven't in some time" JamTracksCleaner: - cron: "0 5 * * *" - class: "JamRuby::UnusedMusicNotationCleaner" - description: "Remove unused music notations" + cron: "0,30 * * * *" + class: "JamRuby::JamTracksCleaner" + description: "Clean up JamTrack related stuff; every 30 minutes" CleanupFacebookSignup: cron: "30 2 * * *" diff --git a/web/spec/controllers/api_jam_track_mixdowns_controller_spec.rb b/web/spec/controllers/api_jam_track_mixdowns_controller_spec.rb index 5dcb8874e..7f36ea02e 100644 --- a/web/spec/controllers/api_jam_track_mixdowns_controller_spec.rb +++ b/web/spec/controllers/api_jam_track_mixdowns_controller_spec.rb @@ -24,7 +24,7 @@ describe ApiJamTrackMixdownsController, type: :controller do json = JSON.parse(response.body) json["next"].should be_nil json["count"].should eq(1) - json["mixdowns"][0]["settings"].should eq({}) + json["mixdowns"][0]["settings"].should eq({"speed" => 5}) # and then add a package package = FactoryGirl.create(:jam_track_mixdown_package, jam_track_mixdown: mixdown) @@ -41,7 +41,7 @@ describe ApiJamTrackMixdownsController, type: :controller do describe "create" do it "success" do - post :create, {:format => 'json', jamTrackID: jam_track.id, name: 'some name', description: 'some description', settings: {}} + post :create, {:format => 'json', jamTrackID: jam_track.id, name: 'some name', description: 'some description', settings: {speed:5}} response.status.should eq(200) @@ -49,12 +49,12 @@ describe ApiJamTrackMixdownsController, type: :controller do json["name"].should eq('some name') json["jam_track_id"].should eq(jam_track.id) json["description"].should eq('some description') - json["settings"].should eq({}) + json["settings"].should eq({"speed" => 5}) json["packages"].should eq([]) end it "validates name" do - post :create, {:format => 'json', jamTrackID: jam_track.id, description: 'some description', settings: {}} + post :create, {:format => 'json', jamTrackID: jam_track.id, description: 'some description', settings: {speed:5}} response.status.should eq(422) @@ -72,7 +72,7 @@ describe ApiJamTrackMixdownsController, type: :controller do response.status.should eq(200) json = JSON.parse(response.body) - json["message"].should eq("enqueued") + puts json json["id"].should_not be_nil package = JamTrackMixdownPackage.find(json["id"]) @@ -102,7 +102,7 @@ describe ApiJamTrackMixdownsController, type: :controller do response.status.should eq(200) json = JSON.parse(response.body) - json["message"].should eq("enqueued") + puts json json["id"].should eq(package.id) JamTrackMixdownPackage.count.should eq(1) end diff --git a/web/spec/controllers/api_jam_tracks_controller_spec.rb b/web/spec/controllers/api_jam_tracks_controller_spec.rb index 25f971ec9..46a7d9c2d 100644 --- a/web/spec/controllers/api_jam_tracks_controller_spec.rb +++ b/web/spec/controllers/api_jam_tracks_controller_spec.rb @@ -115,7 +115,7 @@ describe ApiJamTracksController do it "handle api call 500" do post :played, { id: 999, user: @user } - expect(response.status).to eq(500) + expect(response.status).to eq(422) json = JSON.parse(response.body) expect(/Unexpected error occurred/).to match(json['message']) end @@ -155,8 +155,8 @@ describe ApiJamTracksController do get :download, :id=>@jam_track.id, sample_rate: 48, all_fp: 'all', running_fp: 'running' response.status.should == 202 right.download_count.should eq(0) - right.private_key_44.should be_nil - right.private_key_48.should be_nil + right.private_key_44.should_not be_nil + right.private_key_48.should_not be_nil qname = "#{ResqueSpec.queue_name(JamRuby::JamTracksBuilder)}" #puts "ResqueSpec.peek(qname)#{ResqueSpec.peek(qname)}" @@ -167,7 +167,7 @@ describe ApiJamTracksController do JamTracksBuilder.should_not have_queued(right.id,nil).in(:jam_tracks_builder) right.reload - right.private_key_44.should be_nil + right.private_key_44.should_not be_nil right.private_key_48.should_not be_nil right.download_count.should eq(0) @@ -186,8 +186,8 @@ describe ApiJamTracksController do get :download, :id=>@jam_track.id, :sample_rate=>44, all_fp: 'all', running_fp: 'running' response.status.should == 202 right.download_count.should eq(0) - right.private_key_44.should be_nil - right.private_key_48.should be_nil + right.private_key_44.should_not be_nil + right.private_key_48.should_not be_nil qname = "#{ResqueSpec.queue_name(JamRuby::JamTracksBuilder)}" #puts "ResqueSpec.peek(qname)#{ResqueSpec.peek(qname)}" @@ -199,7 +199,7 @@ describe ApiJamTracksController do JamTracksBuilder.should_not have_queued(right.id, 44).in(:jam_tracks_builder) right.reload right.private_key_44.should_not be_nil - right.private_key_48.should be_nil + right.private_key_48.should_not be_nil right.download_count.should eq(0) get :download, :id=>@jam_track.id, :sample_rate=>44, all_fp: 'all', running_fp: 'running' @@ -239,11 +239,11 @@ describe ApiJamTracksController do json = JSON.parse(response.body) json.length.should == 1 json[0]['44'].should_not be_nil - json[0]['44']['private'].should be_nil - json[0]['44']['error'].should == 'no_key' + json[0]['44']['private'].should_not be_nil + json[0]['44']['error'].should be_nil json[0]['48'].should_not be_nil - json[0]['48']['private'].should be_nil - json[0]['48']['error'].should == 'no_key' + json[0]['48']['private'].should_not be_nil + json[0]['48']['error'].should be_nil end it "track with key" do @@ -254,11 +254,11 @@ describe ApiJamTracksController do json.length.should == 1 json[0]['id'].should == @jam_track.id.to_s json[0]['44'].should_not be_nil - json[0]['44']['private'].should eq('abc') + json[0]['44']['private'].should eq(right.private_key_44) json[0]['44']['error'].should be_nil json[0]['48'].should_not be_nil - json[0]['48']['private'].should be_nil - json[0]['48']['error'].should == 'no_key' + json[0]['48']['private'].should eq(right.private_key_48) + json[0]['48']['error'].should be_nil end it "non-owning user asking for a real track" do diff --git a/web/spec/features/individual_jamtrack_spec.rb b/web/spec/features/individual_jamtrack_spec.rb index 103e0eae8..536c53b49 100644 --- a/web/spec/features/individual_jamtrack_spec.rb +++ b/web/spec/features/individual_jamtrack_spec.rb @@ -53,7 +53,7 @@ describe "Individual JamTrack", :js => true, :type => :feature, :capybara_featur end end find('.browse-band a')['href'].should eq("/client?artist=#{jamtrack_acdc_backinblack.original_artist}#/jamtrack/search") - find('.browse-all a')['href'].should eq("/client#/jamtrack/search") + find('.browse-all a')['href'].should eq("/client?search=#/jamtrack/search") find('a.cta-free-jamtrack')['href'].should eq("/client#/jamtrack/search") find('a.cta-free-jamtrack').trigger(:click) find('h1', text: 'check out') diff --git a/web/spec/requests/active_music_sessions_api_spec.rb b/web/spec/requests/active_music_sessions_api_spec.rb index 61836348e..af4f9a5b6 100755 --- a/web/spec/requests/active_music_sessions_api_spec.rb +++ b/web/spec/requests/active_music_sessions_api_spec.rb @@ -262,10 +262,13 @@ describe "Active Music Session API ", :type => :api do login(user2) get location_header + ".json", "CONTENT_TYPE" => 'application/json' - participant = JSON.parse(last_response.body) + music_session = JSON.parse(last_response.body) - # and the creator should be in the session + + # and the second person should be in the session # and should have tracks + music_session["participants"].length.should == 2 + participant = music_session["participants"][1] participant["tracks"].length.should == 1 participant["tracks"][0]["instrument_id"].should == 'bass guitar' participant["tracks"][0]["sound"].should == 'mono' @@ -451,18 +454,18 @@ describe "Active Music Session API ", :type => :api do # users are friends, but no invitation... so we shouldn't be able to join as user 2 login(user2) - post "/api/sessions/#{session["music_session_id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json' + post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(422) join_response = JSON.parse(last_response.body) join_response["errors"]["musician_access"].should == [ValidationMessages::INVITE_REQUIRED] # but let's make sure if we then invite, that we can then join' login(user) - post '/api/invitations.json', { :music_session => session["music_session_id"], :receiver => user2.id }.to_json, "CONTENT_TYPE" => 'application/json' + post '/api/invitations.json', { :music_session => music_session["id"], :receiver => user2.id }.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(201) login(user2) - post "/api/sessions/#{session["music_session_id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}] }.to_json, "CONTENT_TYPE" => 'application/json' + post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}] }.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(201) end