diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb index 66a83897b..bee953300 100644 --- a/ruby/lib/jam_ruby/models/rsvp_request.rb +++ b/ruby/lib/jam_ruby/models/rsvp_request.rb @@ -97,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 diff --git a/ruby/spec/jam_ruby/models/rsvp_request_spec.rb b/ruby/spec/jam_ruby/models/rsvp_request_spec.rb index 20cf8379b..3ef47a907 100644 --- a/ruby/spec/jam_ruby/models/rsvp_request_spec.rb +++ b/ruby/spec/jam_ruby/models/rsvp_request_spec.rb @@ -101,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