allow session organizer to create RSVP for self without having invitation
This commit is contained in:
parent
7f6a5e75ff
commit
74d5053a8a
|
|
@ -53,7 +53,7 @@ module JamRuby
|
|||
# verify invitation exists for this user and session
|
||||
invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, user.id)
|
||||
|
||||
if invitation.first.nil? && !music_session.open_rsvps
|
||||
if invitation.first.nil? && !music_session.open_rsvps && music_session.creator.id != user.id
|
||||
raise PermissionError, "Only a session invitee can create an RSVP for this session."
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,9 @@ describe RsvpRequest do
|
|||
# accept 1 of the slots
|
||||
rs1 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot1.id)
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_slot_id(@slot2.id)
|
||||
rs1.chosen.should == nil
|
||||
rs2.chosen.should == nil
|
||||
|
||||
RsvpRequest.update({:id => 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)
|
||||
|
||||
# attempt to create a request for the already accepted slot
|
||||
|
|
@ -102,7 +105,7 @@ describe RsvpRequest 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
|
||||
it "should allow RSVP creation with autoapprove option for open RSVP sessions" do
|
||||
# allow open RSVPs
|
||||
@music_session.open_rsvps = true
|
||||
@music_session.save
|
||||
|
|
@ -115,6 +118,16 @@ describe RsvpRequest do
|
|||
rs1.chosen.should == true
|
||||
rs2.chosen.should == true
|
||||
end
|
||||
|
||||
it "should allow RSVP creation with autoapprove option for closed RSVP sessions" do
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue