Merge branch 'feature/scheduled_sessions' of bitbucket.org:jamkazam/jam-cloud into feature/scheduled_sessions
This commit is contained in:
commit
8d16bdacfa
|
|
@ -7,7 +7,7 @@ module JamRuby
|
|||
|
||||
validates :canceled, :inclusion => {:in => [nil, true, false]}
|
||||
|
||||
def self.index(music_session, user = nil)
|
||||
def self.index(music_session, user=nil, options={})
|
||||
query = RsvpRequest
|
||||
.includes(:user)
|
||||
.joins(
|
||||
|
|
@ -27,6 +27,12 @@ module JamRuby
|
|||
}
|
||||
)
|
||||
|
||||
if options[:status] == 'approved'
|
||||
query = query.where("rrrs.chosen = true")
|
||||
elsif options[:status] == 'pending'
|
||||
query = query.where("rrrs.chosen is null")
|
||||
end
|
||||
|
||||
query = query.where("rsvp_requests.user_id = ?", user.id) unless user.nil?
|
||||
return query.uniq
|
||||
end
|
||||
|
|
@ -91,6 +97,7 @@ module JamRuby
|
|||
rsvp_request_rsvp_slot = RsvpRequestRsvpSlot.new
|
||||
rsvp_request_rsvp_slot.rsvp_request = @rsvp
|
||||
rsvp_request_rsvp_slot.rsvp_slot = rsvp_slot
|
||||
rsvp_request_rsvp_slot.chosen = true if params[:autoapprove] == true
|
||||
rsvp_request_rsvp_slot.save
|
||||
|
||||
instruments << rsvp_slot.instrument_id
|
||||
|
|
|
|||
|
|
@ -89,8 +89,6 @@ describe RsvpRequest do
|
|||
|
||||
rsvp = RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot1.id, @slot2.id]}, @non_session_invitee)
|
||||
|
||||
request_slots = RsvpRequestRsvpSlot.all
|
||||
|
||||
# accept 1 of the slots
|
||||
rs1 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot1.id)
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot2.id)
|
||||
|
|
@ -103,6 +101,20 @@ describe RsvpRequest do
|
|||
it "should not allow non-invitee to RSVP to session with closed RSVPs" do
|
||||
expect {RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot1.id, @slot2.id]}, @non_session_invitee)}.to raise_error(JamRuby::PermissionError)
|
||||
end
|
||||
|
||||
it "should allow RSVP creation with autoapprove option" do
|
||||
# allow open RSVPs
|
||||
@music_session.open_rsvps = true
|
||||
@music_session.save
|
||||
|
||||
rsvp = RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot1.id, @slot2.id], :autoapprove => true}, @session_creator)
|
||||
|
||||
rs1 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot1.id)
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot2.id)
|
||||
|
||||
rs1.chosen.should == true
|
||||
rs2.chosen.should == true
|
||||
end
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
|
|
@ -133,6 +145,42 @@ describe RsvpRequest do
|
|||
rsvps = RsvpRequest.index(@music_session, @non_session_invitee)
|
||||
rsvps.count.should == 1
|
||||
end
|
||||
|
||||
it "should allow retrieval of RSVps by session and approval status" do
|
||||
# allow open RSVPs
|
||||
@music_session.open_rsvps = true
|
||||
@music_session.save
|
||||
|
||||
approved_rsvp = RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot1.id, @slot2.id]}, @non_session_invitee)
|
||||
|
||||
rs1 = RsvpRequestRsvpSlot.find_by_rsvp_request_id_and_rsvp_slot_id(approved_rsvp.id, @slot1.id)
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_request_id_and_rsvp_slot_id(approved_rsvp.id, @slot2.id)
|
||||
RsvpRequest.update({:id => approved_rsvp.id, :session_id => @music_session.id, :rsvp_responses => [{:request_slot_id => rs1.id, :accept => true}, {:request_slot_id => rs2.id, :accept => false}]}, @session_creator)
|
||||
|
||||
user2 = FactoryGirl.create(:user)
|
||||
declined_rsvp = RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot2.id]}, user2)
|
||||
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_request_id_and_rsvp_slot_id(declined_rsvp, @slot2.id)
|
||||
RsvpRequest.update({:id => declined_rsvp.id, :session_id => @music_session.id, :rsvp_responses => [{:request_slot_id => rs2.id, :accept => false}]}, @session_creator)
|
||||
|
||||
user3 = FactoryGirl.create(:user)
|
||||
pending_rsvp = RsvpRequest.create({:session_id => @music_session.id, :rsvp_slots => [@slot2.id]}, user3)
|
||||
|
||||
rsvps = RsvpRequest.index(@music_session, nil, {:status => "pending"})
|
||||
rsvps.count.should == 1
|
||||
|
||||
rsvps = RsvpRequest.index(@music_session, user3, {:status => "pending"})
|
||||
rsvps.count.should == 1
|
||||
|
||||
rsvps = RsvpRequest.index(@music_session, nil, {:status => "approved"})
|
||||
rsvps.count.should == 1
|
||||
|
||||
rsvps = RsvpRequest.index(@music_session, @non_session_invitee, {:status => "approved"})
|
||||
rsvps.count.should == 1
|
||||
|
||||
rsvps = RsvpRequest.index(@music_session)
|
||||
rsvps.count.should == 3
|
||||
end
|
||||
end
|
||||
|
||||
describe "update" do
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ class ApiRsvpRequestsController < ApiController
|
|||
|
||||
# retrieve all requests for this session
|
||||
if music_session.creator.id == current_user.id
|
||||
@rsvp_requests = RsvpRequest.index(music_session)
|
||||
@rsvp_requests = RsvpRequest.index(music_session, nil, params)
|
||||
|
||||
# scope the response to the current user
|
||||
else
|
||||
@rsvp_requests = RsvpRequest.index(music_session, current_user)
|
||||
@rsvp_requests = RsvpRequest.index(music_session, current_user, params)
|
||||
end
|
||||
|
||||
respond_with @rsvp_requests, responder: ApiResponder, :status => 200
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
describe "view" do
|
||||
|
||||
########### BEGIN SESSION STARTS ###########
|
||||
########### BEFORE SESSION STARTS ###########
|
||||
|
||||
it "should render for any musician for sessions with open RSVPs before session starts" do
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ describe "User Progression", :js => true, :type => :feature, :capybara_feature
|
|||
sleep 1
|
||||
end
|
||||
|
||||
it {user.reload(); user.first_certified_gear_at.should_not be_nil }
|
||||
it pending {user.reload(); user.first_certified_gear_at.should_not be_nil }
|
||||
end
|
||||
|
||||
describe "social promoted" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue