diff --git a/ruby/lib/jam_ruby/models/recording.rb b/ruby/lib/jam_ruby/models/recording.rb index fb781f1e6..bd6587b56 100644 --- a/ruby/lib/jam_ruby/models/recording.rb +++ b/ruby/lib/jam_ruby/models/recording.rb @@ -201,7 +201,7 @@ module JamRuby def has_access?(user) - users.exists?(user) || plays.where("player_id=?", user).count != 0 + users.exists?(user.id) || plays.where("player_id=?", user).count != 0 end # Start recording a session. @@ -721,7 +721,7 @@ module JamRuby private def self.validate_user_is_band_member(user, band) - unless band.users.exists? user + unless band.users.exists? user.id raise JamPermissionError, ValidationMessages::USER_NOT_BAND_MEMBER_VALIDATION_ERROR end end diff --git a/web/Gemfile b/web/Gemfile index f438ef02b..ce09511e3 100644 --- a/web/Gemfile +++ b/web/Gemfile @@ -114,7 +114,7 @@ end #end group :development, :test do - gem 'rspec-rails', '2.14.2' + gem 'rspec-rails' #, require: "rspec/rails" #, '2.14.2' gem "activerecord-import", "~> 0.4.1" # gem 'guard-rspec', '0.5.5' # gem 'jasmine', '1.3.1' diff --git a/web/app/controllers/api_music_sessions_controller.rb b/web/app/controllers/api_music_sessions_controller.rb index f4ed9561e..acf3ecb22 100644 --- a/web/app/controllers/api_music_sessions_controller.rb +++ b/web/app/controllers/api_music_sessions_controller.rb @@ -577,7 +577,7 @@ class ApiMusicSessionsController < ApiController def jam_track_open - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end @@ -593,7 +593,7 @@ class ApiMusicSessionsController < ApiController end def jam_track_close - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end @@ -603,7 +603,7 @@ class ApiMusicSessionsController < ApiController end def backing_track_open - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end @@ -613,7 +613,7 @@ class ApiMusicSessionsController < ApiController end def backing_track_close - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end @@ -622,7 +622,7 @@ class ApiMusicSessionsController < ApiController end def metronome_open - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end @@ -631,7 +631,7 @@ class ApiMusicSessionsController < ApiController end def metronome_close - unless @music_session.users.exists?(current_user) + unless @music_session.users.exists?(current_user.id) raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR end diff --git a/web/app/controllers/api_recordings_controller.rb b/web/app/controllers/api_recordings_controller.rb index 0767d9053..776c10f43 100644 --- a/web/app/controllers/api_recordings_controller.rb +++ b/web/app/controllers/api_recordings_controller.rb @@ -81,7 +81,7 @@ class ApiRecordingsController < ApiController def start music_session = ActiveMusicSession.find(params[:music_session_id]) - raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR unless music_session.users.exists?(current_user) + raise JamPermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR unless music_session.users.exists?(current_user.id) @recording = Recording.start(music_session, current_user) diff --git a/web/app/controllers/api_scoring_controller.rb b/web/app/controllers/api_scoring_controller.rb index 7f9c3d684..cf89455d2 100644 --- a/web/app/controllers/api_scoring_controller.rb +++ b/web/app/controllers/api_scoring_controller.rb @@ -5,7 +5,7 @@ class ApiScoringController < ApiController def work # clientid; returns another clientid clientid = params[:clientid] - if clientid.nil? then render :json => {message: 'clientid not specified'}, :status => 400; return end + if clientid.blank? then render :json => {message: 'clientid not specified'}, :status => 400; return end conn = Connection.where(client_id: clientid, user_id: current_user.id).first if conn.nil? then render :json => {message: 'session not found'}, :status => 404; return end @@ -20,7 +20,7 @@ class ApiScoringController < ApiController def worklist # clientid; returns a list of clientid clientid = params[:clientid] - if clientid.nil? then render :json => {message: 'clientid not specified'}, :status => 400; return end + if clientid.blank? then render :json => {message: 'clientid not specified'}, :status => 400; return end conn = Connection.where(client_id: clientid, user_id: current_user.id).first if conn.nil? then render :json => {message: 'session not found'}, :status => 404; return end diff --git a/web/app/views/api_music_sessions/show.rabl b/web/app/views/api_music_sessions/show.rabl index c2259e309..911f7ebce 100644 --- a/web/app/views/api_music_sessions/show.rabl +++ b/web/app/views/api_music_sessions/show.rabl @@ -70,7 +70,7 @@ else } # only show join_requests if the current_user is in the session - child({:join_requests => :join_requests}, :if => lambda { |music_session| music_session.users.exists?(current_user) } ) { + child({:join_requests => :join_requests}, :if => lambda { |music_session| music_session.users.exists?(current_user.id) } ) { attributes :id, :text child(:user => :user) { attributes :id, :name @@ -78,7 +78,7 @@ else } # only show currently open jam track info if the current user is in the session - child({:jam_track => :jam_track}, :if => lambda { |music_session| music_session.users.exists?(current_user) }) { + child({:jam_track => :jam_track}, :if => lambda { |music_session| music_session.users.exists?(current_user.id) }) { attributes :id, :name, :description child(:jam_track_tracks => :tracks) { @@ -87,7 +87,7 @@ else } # only show currently playing recording data if the current_user is in the session - child({:claimed_recording => :claimed_recording}, :if => lambda { |music_session| music_session.users.exists?(current_user) }) { + child({:claimed_recording => :claimed_recording}, :if => lambda { |music_session| music_session.users.exists?(current_user.id) }) { attributes :id, :name, :description, :is_public child(:recording => :recording) { diff --git a/web/app/views/api_music_sessions/show_history.rabl b/web/app/views/api_music_sessions/show_history.rabl index bae82c31b..9c19ed1b1 100644 --- a/web/app/views/api_music_sessions/show_history.rabl +++ b/web/app/views/api_music_sessions/show_history.rabl @@ -178,7 +178,7 @@ else } # only show join_requests if the current_user is in the session - node(:join_requests, :if => lambda { |music_session| music_session.users.exists?(current_user) } ) do |music_session| + node(:join_requests, :if => lambda { |music_session| music_session.users.exists?(current_user.id) } ) do |music_session| child(:join_requests => :join_requests) { attributes :id, :text child(:user => :user) { @@ -188,7 +188,7 @@ else end # only show currently playing recording data if the current_user is in the session - node(:claimed_recording, :if => lambda { |music_session| music_session.users.exists?(current_user) } ) do |music_session| + node(:claimed_recording, :if => lambda { |music_session| music_session.users.exists?(current_user.id) } ) do |music_session| child(:claimed_recording => :claimed_recording) { attributes :id, :name, :description, :is_public diff --git a/web/spec/controllers/api_affiliate_controller_spec.rb b/web/spec/controllers/api_affiliate_controller_spec.rb index 93306844d..00f40c413 100644 --- a/web/spec/controllers/api_affiliate_controller_spec.rb +++ b/web/spec/controllers/api_affiliate_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiAffiliateController do +describe ApiAffiliateController, type: :controller do render_views let(:partner1) {FactoryGirl.create(:affiliate_partner)} diff --git a/web/spec/controllers/api_claimed_recordings_spec.rb b/web/spec/controllers/api_claimed_recordings_spec.rb index 8adf5dd86..cdeb8e454 100644 --- a/web/spec/controllers/api_claimed_recordings_spec.rb +++ b/web/spec/controllers/api_claimed_recordings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiClaimedRecordingsController do +describe ApiClaimedRecordingsController, type: :controller do render_views before(:each) do @@ -19,7 +19,7 @@ describe ApiClaimedRecordingsController do @recording.claim(@user, "name", "description", @genre, true) @recording.reload @claimed_recording = @recording.claimed_recordings.first! - @recording.has_mix?.should be_false + @recording.has_mix?.should be false end @@ -75,7 +75,6 @@ describe ApiClaimedRecordingsController do describe "index" do it "should generate a single output" do - pending controller.current_user = @user get :index response.should be_success @@ -106,11 +105,11 @@ describe ApiClaimedRecordingsController do controller.current_user = @user get :download, id: quick_mix.recording.candidate_claimed_recording.id response.status.should == 302 - response.headers['Location'].include?('recordings/ogg').should be_true + response.headers['Location'].include?('recordings/ogg').should be true get :download, id: quick_mix.recording.candidate_claimed_recording.id, type:'mp3' response.status.should == 302 - response.headers['Location'].include?('recordings/mp3').should be_true + response.headers['Location'].include?('recordings/mp3').should be true end it "final mix, not completed" do @@ -125,11 +124,11 @@ describe ApiClaimedRecordingsController do controller.current_user = @user get :download, id: mix.recording.candidate_claimed_recording.id response.status.should == 302 - response.headers['Location'].include?('recordings/mixed/ogg').should be_true + response.headers['Location'].include?('recordings/mixed/ogg').should be true get :download, id: mix.recording.candidate_claimed_recording.id, type:'mp3' response.status.should == 302 - response.headers['Location'].include?('recordings/mixed/mp3').should be_true + response.headers['Location'].include?('recordings/mixed/mp3').should be true end it "both completed final mix and stream mix" do @@ -139,11 +138,11 @@ describe ApiClaimedRecordingsController do controller.current_user = @user get :download, id: mix.recording.candidate_claimed_recording.id response.status.should == 302 - response.headers['Location'].include?('recordings/mixed/ogg').should be_true + response.headers['Location'].include?('recordings/mixed/ogg').should be true get :download, id: mix.recording.candidate_claimed_recording.id, type:'mp3' response.status.should == 302 - response.headers['Location'].include?('recordings/mixed/mp3').should be_true + response.headers['Location'].include?('recordings/mixed/mp3').should be true end it "completed stream mix, incomplete final mix" do @@ -153,11 +152,11 @@ describe ApiClaimedRecordingsController do controller.current_user = @user get :download, id: mix.recording.candidate_claimed_recording.id response.status.should == 302 - response.headers['Location'].include?('recordings/ogg').should be_true + response.headers['Location'].include?('recordings/ogg').should be true get :download, id: quick_mix.recording.candidate_claimed_recording.id, type:'mp3' response.status.should == 302 - response.headers['Location'].include?('recordings/mp3').should be_true + response.headers['Location'].include?('recordings/mp3').should be true end diff --git a/web/spec/controllers/api_corporate_controller_spec.rb b/web/spec/controllers/api_corporate_controller_spec.rb index cfbe7f5fd..1c97bff2f 100644 --- a/web/spec/controllers/api_corporate_controller_spec.rb +++ b/web/spec/controllers/api_corporate_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiCorporateController do +describe ApiCorporateController, type: :controller do render_views before(:each) do diff --git a/web/spec/controllers/api_favorites_controller_spec.rb b/web/spec/controllers/api_favorites_controller_spec.rb index 64411da0e..58f0c6a27 100644 --- a/web/spec/controllers/api_favorites_controller_spec.rb +++ b/web/spec/controllers/api_favorites_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiFavoritesController do +describe ApiFavoritesController, type: :controller do render_views let(:user) { FactoryGirl.create(:user) } diff --git a/web/spec/controllers/api_feeds_controller_spec.rb b/web/spec/controllers/api_feeds_controller_spec.rb index c0a62ab8b..ff4540fb8 100644 --- a/web/spec/controllers/api_feeds_controller_spec.rb +++ b/web/spec/controllers/api_feeds_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiFeedsController do +describe ApiFeedsController, type: :controller do render_views let(:user) { FactoryGirl.create(:user) } diff --git a/web/spec/controllers/api_icecast_controller_spec.rb b/web/spec/controllers/api_icecast_controller_spec.rb index 2cc8716ee..dca5adbc1 100644 --- a/web/spec/controllers/api_icecast_controller_spec.rb +++ b/web/spec/controllers/api_icecast_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiIcecastController do +describe ApiIcecastController, type: :controller do render_views let(:user) {FactoryGirl.create(:user) } diff --git a/web/spec/controllers/api_jam_tracks_controller_spec.rb b/web/spec/controllers/api_jam_tracks_controller_spec.rb index 25f971ec9..215b5a685 100644 --- a/web/spec/controllers/api_jam_tracks_controller_spec.rb +++ b/web/spec/controllers/api_jam_tracks_controller_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe ApiJamTracksController do +describe ApiJamTracksController, type: :controller do render_views include CarrierWave::Test::Matchers @@ -107,7 +107,7 @@ describe ApiJamTracksController do end it "handle api call 400" do - post :played, { user: @user } + post :played, { id: '', user: @user } expect(response.status).to eq(400) json = JSON.parse(response.body) expect(/JamTrack ID required/).to match(json['message']) diff --git a/web/spec/controllers/api_latency_tests_controller_spec.rb b/web/spec/controllers/api_latency_tests_controller_spec.rb index fb773b3ef..b33ab9689 100644 --- a/web/spec/controllers/api_latency_tests_controller_spec.rb +++ b/web/spec/controllers/api_latency_tests_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiLatencyTestersController do +describe ApiLatencyTestersController, type: :controller do render_views diff --git a/web/spec/controllers/api_links_controller_spec.rb b/web/spec/controllers/api_links_controller_spec.rb index d9f669cac..346e92890 100644 --- a/web/spec/controllers/api_links_controller_spec.rb +++ b/web/spec/controllers/api_links_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiLinksController do +describe ApiLinksController, type: :controller do render_views let(:partner1) {FactoryGirl.create(:affiliate_partner)} diff --git a/web/spec/controllers/api_mixes_controller_spec.rb b/web/spec/controllers/api_mixes_controller_spec.rb index ff420732a..f16596d0a 100644 --- a/web/spec/controllers/api_mixes_controller_spec.rb +++ b/web/spec/controllers/api_mixes_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiMixesController do +describe ApiMixesController, type: :controller do render_views let(:mix) { FactoryGirl.create(:mix) } diff --git a/web/spec/controllers/api_music_sessions_controller_spec.rb b/web/spec/controllers/api_music_sessions_controller_spec.rb index 27565dd55..2e6299d38 100644 --- a/web/spec/controllers/api_music_sessions_controller_spec.rb +++ b/web/spec/controllers/api_music_sessions_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiMusicSessionsController do +describe ApiMusicSessionsController, type: :controller do render_views let(:tracks) { [{'sound' => 'mono', 'client_track_id' => 'abc', 'instrument_id' => 'piano'}] } diff --git a/web/spec/controllers/api_payment_histories_controller_spec.rb b/web/spec/controllers/api_payment_histories_controller_spec.rb index 92c5417cb..1a59d8fa8 100644 --- a/web/spec/controllers/api_payment_histories_controller_spec.rb +++ b/web/spec/controllers/api_payment_histories_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiPaymentHistoriesController do +describe ApiPaymentHistoriesController, type: :controller do render_views let(:user) {FactoryGirl.create(:user)} diff --git a/web/spec/controllers/api_recordings_controller_spec.rb b/web/spec/controllers/api_recordings_controller_spec.rb index c01b4cb0f..399f10e43 100644 --- a/web/spec/controllers/api_recordings_controller_spec.rb +++ b/web/spec/controllers/api_recordings_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiRecordingsController do +describe ApiRecordingsController, type: :controller do render_views describe "recording with backing track" do diff --git a/web/spec/controllers/api_recurly_web_hook_controller_spec.rb b/web/spec/controllers/api_recurly_web_hook_controller_spec.rb index 87cf27f03..ab2619583 100644 --- a/web/spec/controllers/api_recurly_web_hook_controller_spec.rb +++ b/web/spec/controllers/api_recurly_web_hook_controller_spec.rb @@ -2,8 +2,7 @@ require 'spec_helper' require 'jam_ruby/recurly_client' describe ApiRecurlyWebHookController, :type=>:request do - render_views - + let(:success_xml) { ' diff --git a/web/spec/controllers/api_scoring_controller_spec.rb b/web/spec/controllers/api_scoring_controller_spec.rb index 3cb0f2b8f..832b9366b 100644 --- a/web/spec/controllers/api_scoring_controller_spec.rb +++ b/web/spec/controllers/api_scoring_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiScoringController do +describe ApiScoringController, type: :controller do render_views BOGUS_CLIENT_ID = 'nobodyclientid' @@ -62,7 +62,7 @@ describe ApiScoringController do it 'try work with mary login and nothing' do controller.current_user = @mary - get :work, {} + get :work, {clientid: ''} response.should_not be_success json = JSON.parse(response.body, :symbolize_names => true) json.length.should == 1 @@ -124,7 +124,7 @@ describe ApiScoringController do it 'try worklist with nobody login and nobody' do controller.current_user = nil - get :worklist, {} + get :worklist, {clientid: ''} response.should_not be_success json = JSON.parse(response.body, :symbolize_names => true) json.length.should == 1 @@ -133,7 +133,7 @@ describe ApiScoringController do it 'try worklist with mary login and nobody' do controller.current_user = @mary - get :worklist, {} + get :worklist, {clientid: ''} response.should_not be_success json = JSON.parse(response.body, :symbolize_names => true) json.length.should == 1 diff --git a/web/spec/controllers/api_shopping_carts_controller_spec.rb b/web/spec/controllers/api_shopping_carts_controller_spec.rb index c6f196d0d..b0af94f34 100644 --- a/web/spec/controllers/api_shopping_carts_controller_spec.rb +++ b/web/spec/controllers/api_shopping_carts_controller_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe ApiShoppingCartsController do +describe ApiShoppingCartsController, type: :controller do render_views diff --git a/web/spec/controllers/api_user_syncs_controller_spec.rb b/web/spec/controllers/api_user_syncs_controller_spec.rb index a1b039f2f..cdc31d455 100644 --- a/web/spec/controllers/api_user_syncs_controller_spec.rb +++ b/web/spec/controllers/api_user_syncs_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiUserSyncsController do +describe ApiUserSyncsController, type: :controller do render_views diff --git a/web/spec/controllers/api_users_controller_spec.rb b/web/spec/controllers/api_users_controller_spec.rb index 065602e77..11b063a3c 100644 --- a/web/spec/controllers/api_users_controller_spec.rb +++ b/web/spec/controllers/api_users_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ApiUsersController do +describe ApiUsersController, type: :controller do render_views let (:user) { FactoryGirl.create(:user) } diff --git a/web/spec/controllers/sessions_controller_spec.rb b/web/spec/controllers/sessions_controller_spec.rb index 65aad4fff..989ca2789 100644 --- a/web/spec/controllers/sessions_controller_spec.rb +++ b/web/spec/controllers/sessions_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe SessionsController do +describe SessionsController, type: :controller do render_views let(:user) { FactoryGirl.create(:user) } diff --git a/web/spec/controllers/share_tokens_controller_spec.rb b/web/spec/controllers/share_tokens_controller_spec.rb index 7d5de183e..31b4ecd6c 100644 --- a/web/spec/controllers/share_tokens_controller_spec.rb +++ b/web/spec/controllers/share_tokens_controller_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe ShareTokensController do +describe ShareTokensController, type: :controller do render_views let(:user) { FactoryGirl.create(:user) } diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 10f195cee..1e0ccb177 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -125,8 +125,7 @@ end bputs "before loading rails" require 'rspec/rails' -bputs "before connection autorun" - require 'rspec/autorun' +# require 'rspec/autorun' bputs "before load capybara" @@ -163,6 +162,12 @@ bputs "before register capybara" #ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base) RSpec.configure do |config| + + # XXX WE COULD GET RID OF THIS IF WE WANT TO UPDATE ALL OF OUR TESTS + # Using `should` from rspec-expectations' old `:should` syntax without explicitly enabling the syntax is deprecated. Use the new `:expect` syntax or explicitly enable `:should` with `config.expect_with(:rspec) { |c| c.syntax = :should }` instead. Called from /Users/seth/workspace/jam-cloud/web/spec/controllers/api_jam_tracks_controller_spec.rb:37:in `block (3 levels) in '. + #config.expect_with(:rspec) { |c| c.syntax = :should } + + # ## Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: @@ -171,7 +176,7 @@ bputs "before register capybara" # config.mock_with :flexmock # config.mock_with :rr config.mock_with :rspec - config.color_enabled = true + config.color = true # by default, do not run tests marked as 'slow' config.filter_run_excluding slow: true unless ENV['RUN_SLOW_TESTS'] == "1" || ENV['SLOW'] == "1" || ENV['ALL_TESTS'] == "1" @@ -210,7 +215,7 @@ bputs "before register capybara" end end - config.before(:each) do + config.before(:each) do |example| if example.metadata[:js] && (Capybara.current_driver.nil? || Capybara.current_driver.empty? || Capybara.current_driver==:poltergeist) page.driver.resize(1920, 1080) page.driver.headers = { 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' } @@ -234,7 +239,7 @@ bputs "before register capybara" reset_session_mapper end - config.after(:each) do + config.after(:each) do |example| if example.metadata[:js] end