* allowing tests to be skipped, and mostly done with VRFS-1200
This commit is contained in:
parent
1472944648
commit
f3c09f65c2
|
|
@ -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;
|
||||||
12
ruby/build
12
ruby/build
|
|
@ -3,14 +3,18 @@
|
||||||
echo "updating dependencies"
|
echo "updating dependencies"
|
||||||
bundle install --path vendor/bundle
|
bundle install --path vendor/bundle
|
||||||
|
|
||||||
echo "running rspec tests"
|
if [ -z $SKIP_TESTS ]; then
|
||||||
bundle exec rspec
|
echo "running rspec tests"
|
||||||
|
bundle exec rspec
|
||||||
|
|
||||||
if [ "$?" = "0" ]; then
|
if [ "$?" = "0" ]; then
|
||||||
echo "tests completed"
|
echo "tests completed"
|
||||||
else
|
else
|
||||||
echo "tests failed."
|
echo "tests failed."
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "skipping tests"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "build complete"
|
echo "build complete"
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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;
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -10,39 +10,59 @@ 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
|
||||||
|
|
||||||
|
|
||||||
it "insists on login" do
|
describe "index" do
|
||||||
get :index
|
it "insists on login" do
|
||||||
response.status.should == 403
|
get :index
|
||||||
|
response.status.should == 403
|
||||||
|
end
|
||||||
|
|
||||||
|
it "requires user param" do
|
||||||
|
controller.current_user = user
|
||||||
|
expect { get :index }.to raise_error "user must be specified"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "can return nothing" do
|
||||||
|
controller.current_user = user
|
||||||
|
get :index, { user: user}
|
||||||
|
|
||||||
|
json = JSON.parse(response.body, :symbolize_names => true)
|
||||||
|
json[:entries].length.should == 0
|
||||||
|
json[:since].should be_nil
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns one thing" do
|
||||||
|
claimed_recording.touch
|
||||||
|
like = FactoryGirl.create(:recording_like, user: user, claimed_recording: claimed_recording, recording: claimed_recording.recording, favorite: true)
|
||||||
|
|
||||||
|
controller.current_user = user
|
||||||
|
get :index, { user: user}
|
||||||
|
|
||||||
|
json = JSON.parse(response.body, :symbolize_names => true)
|
||||||
|
json[:entries].length.should == 1
|
||||||
|
json[:since].should be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "requires user param" do
|
|
||||||
controller.current_user = user
|
describe "update" do
|
||||||
expect { get :index }.to raise_error "user must be specified"
|
|
||||||
|
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
|
||||||
|
|
||||||
it "can return nothing" do
|
|
||||||
controller.current_user = user
|
|
||||||
get :index, { user: user}
|
|
||||||
|
|
||||||
json = JSON.parse(response.body, :symbolize_names => true)
|
|
||||||
json[:entries].length.should == 0
|
|
||||||
json[:since].should be_nil
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns one thing" do
|
|
||||||
claimed_recording.touch
|
|
||||||
like = FactoryGirl.create(:recording_like, user: user, claimed_recording: claimed_recording, recording: claimed_recording.recording, favorite: true)
|
|
||||||
|
|
||||||
controller.current_user = user
|
|
||||||
get :index, { user: user}
|
|
||||||
|
|
||||||
json = JSON.parse(response.body, :symbolize_names => true)
|
|
||||||
json[:entries].length.should == 1
|
|
||||||
json[:since].should be_nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue