* allowing tests to be skipped, and mostly done with VRFS-1200

This commit is contained in:
Seth Call 2014-02-20 22:23:44 +00:00
parent 1472944648
commit f3c09f65c2
9 changed files with 93 additions and 49 deletions

View File

@ -1 +1,2 @@
ALTER TABLE music_sessions_history ADD COLUMN fan_access BOOLEAN NOT NULL;
ALTER TABLE music_sessions_history ADD COLUMN fan_access BOOLEAN NOT NULL DEFAULT TRUE;

View File

@ -3,6 +3,7 @@
echo "updating dependencies" echo "updating dependencies"
bundle install --path vendor/bundle bundle install --path vendor/bundle
if [ -z $SKIP_TESTS ]; then
echo "running rspec tests" echo "running rspec tests"
bundle exec rspec bundle exec rspec
@ -12,6 +13,9 @@ else
echo "tests failed." echo "tests failed."
exit 1 exit 1
fi fi
else
echo "skipping tests"
fi
echo "build complete" echo "build complete"

View File

@ -9,5 +9,6 @@ module JamRuby
belongs_to :claimed_recording, :class_name => "JamRuby::ClaimedRecording", :foreign_key => "claimed_recording_id" belongs_to :claimed_recording, :class_name => "JamRuby::ClaimedRecording", :foreign_key => "claimed_recording_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id" belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id"
validates :favorite, :inclusion => {:in => [true, false]}
end end
end end

View File

@ -103,6 +103,16 @@
}); });
} }
function updateFavorite(claimedRecordingId, favorite) {
return $.ajax({
url: '/api/favorites/' + claimedRecordingId,
type: "POST",
data : JSON.stringify({favorite: favorite}),
dataType : 'json',
contentType: 'application/json'
});
}
function validateBand(band) { function validateBand(band) {
return $.ajax({ return $.ajax({
type: "POST", type: "POST",
@ -906,6 +916,7 @@
this.getBandPhotoFilepickerPolicy = getBandPhotoFilepickerPolicy; this.getBandPhotoFilepickerPolicy = getBandPhotoFilepickerPolicy;
this.getBand = getBand; this.getBand = getBand;
this.validateBand = validateBand; this.validateBand = validateBand;
this.updateFavorite = updateFavorite;
this.createBandInvitation = createBandInvitation; this.createBandInvitation = createBandInvitation;
this.updateBandInvitation = updateBandInvitation; this.updateBandInvitation = updateBandInvitation;
this.removeBandMember = removeBandMember; this.removeBandMember = removeBandMember;

View File

@ -34,16 +34,16 @@ class ApiController < ApplicationController
def respond_with_model(model, options = {}) def respond_with_model(model, options = {})
if model.errors.any? if model.errors.any?
response.status = :unprocessable_entity response.status = :unprocessable_entity
respond_with model respond_with model, layout: nil
else else
status = options[:new] && options[:new] == true ? 201 : 200 status = options[:new] && options[:new] == true ? 201 : 200
redirect_on_success = options[:location] redirect_on_success = options[:location]
if redirect_on_success if redirect_on_success
location = redirect_on_success.call location = redirect_on_success.call
raise "location must return something" unless location # development time error raise "location must return something" unless location # development time error
respond_with model, responder: ApiResponder, status: status, location: location respond_with model, responder: ApiResponder, status: status, location: location, layout: nil
else else
respond_with model, responder: ApiResponder, status: status respond_with model, responder: ApiResponder, status: status, layout: nil
end end
end end
end end

View File

@ -15,7 +15,12 @@ class ApiFavoritesController < ApiController
render "api_favorites/index", :layout => nil render "api_favorites/index", :layout => nil
end end
def remove_favorite def update
RecordingLiker.find_by_liker_id_and_claimed_recording_id(curren_user.id, params[:claimed_recording_id]) id = params[:id]
like = RecordingLiker.find_by_liker_id_and_claimed_recording_id!(current_user.id, id)
like.favorite = params[:favorite] if params.has_key? :favorite
like.save
respond_with_model(like)
end end
end end

View File

@ -348,6 +348,7 @@ SampleApp::Application.routes.draw do
# favorites # favorites
match '/favorites' => 'api_favorites#index', :via => :get match '/favorites' => 'api_favorites#index', :via => :get
match '/favorites/:id' => 'api_favorites#update', :via => :post
end end
end end

View File

@ -10,11 +10,13 @@ describe ApiFavoritesController do
let(:claimed_recording) {FactoryGirl.create(:claimed_recording) } let(:claimed_recording) {FactoryGirl.create(:claimed_recording) }
before(:each) do before(:each) do
RecordingLiker.delete_all
ClaimedRecording.delete_all ClaimedRecording.delete_all
controller.current_user = nil controller.current_user = nil
end end
describe "index" do
it "insists on login" do it "insists on login" do
get :index get :index
response.status.should == 403 response.status.should == 403
@ -46,3 +48,21 @@ describe ApiFavoritesController do
json[:since].should be_nil json[:since].should be_nil
end end
end end
describe "update" do
it "insists on login" do
post :update, {id: '1'}
response.status.should == 403
end
it "requires user param" do
controller.current_user = user
post :update, {id: claimed_recording.id}
response.status.should == 404
end
end
end

View File

@ -25,31 +25,32 @@ require 'jam_ruby'
# uncomment this to see active record logs # uncomment this to see active record logs
# ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base) # ActiveRecord::Base.logger = Logger.new(STDOUT) if defined?(ActiveRecord::Base)
puts "1"
#puts "1"
include JamRuby include JamRuby
puts "2" #puts "2"
# put ActionMailer into test mode # put ActionMailer into test mode
ActionMailer::Base.delivery_method = :test ActionMailer::Base.delivery_method = :test
puts "3" #puts "3"
RecordedTrack.observers.disable :all # only a few tests want this observer active RecordedTrack.observers.disable :all # only a few tests want this observer active
puts "4" #puts "4"
# a way to kill tests if they aren't running. capybara is hanging intermittently, I think # a way to kill tests if they aren't running. capybara is hanging intermittently, I think
tests_started = false tests_started = false
Thread.new { #Thread.new {
puts "thread starting" # puts "thread starting"
sleep 30 # sleep 30
puts "thread waking" # puts "thread waking"
unless tests_started # unless tests_started
puts "tests are hung. exiting..." # puts "tests are hung. exiting..."
exit 20 # exit 20
end # end
} #}
Spork.prefork do Spork.prefork do
# Loading more in this block will cause your tests to run faster. However, # Loading more in this block will cause your tests to run faster. However,