* VRFS-1887 - make the RSVP text helpful as to the state of the session relative to the viewing user
This commit is contained in:
parent
f693470c63
commit
afa2fa58cf
|
|
@ -19,9 +19,6 @@ module JamRuby
|
|||
# updating_password corresponds to a lost_password
|
||||
attr_accessor :updating_password, :updating_email, :updated_email, :update_email_confirmation_url, :administratively_created, :current_password, :setting_password, :confirm_current_password, :updating_avatar, :updating_progression_field, :mods_json
|
||||
|
||||
# checks if user has submitted RSVP to a session
|
||||
attr_accessor :has_rsvp
|
||||
|
||||
belongs_to :icecast_server_group, class_name: "JamRuby::IcecastServerGroup", inverse_of: :users, foreign_key: 'icecast_server_group_id'
|
||||
|
||||
# authorizations (for facebook, etc -- omniauth)
|
||||
|
|
@ -1254,6 +1251,7 @@ module JamRuby
|
|||
User.where(:email => email).limit(1).pluck(:id).first
|
||||
end
|
||||
|
||||
# checks if user has submitted RSVP to a session
|
||||
def has_rsvp(session)
|
||||
slots = RsvpSlot.find_by_sql(%Q{select rs.*
|
||||
from rsvp_slots rs
|
||||
|
|
|
|||
|
|
@ -506,17 +506,32 @@ FactoryGirl.define do
|
|||
cancel_all false
|
||||
association :user, :factory => :user
|
||||
|
||||
# creates *number* slots for a new rsvp_request
|
||||
# creates *number* slots for a new rsvp_request (the case were you are too lazy / don't care to set up slots)
|
||||
factory :rsvp_request_for_multiple_slots do
|
||||
ignore do
|
||||
music_session nil
|
||||
number nil
|
||||
number 1
|
||||
chosen nil
|
||||
end
|
||||
|
||||
after(:create) { |rsvp_request, evaluator |
|
||||
evaluator.number.times do |i|
|
||||
slot = FactoryGirl.create(:rsvp_slot, music_session: evaluator.music_session, instrument: Instrument.order(:id).limit(1).offset(i).first, proficiency_level: 1)
|
||||
FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:true, rsvp_request: rsvp_request, rsvp_slot:slot)
|
||||
FactoryGirl.create(:rsvp_request_rsvp_slot, chosen: evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# creates a rsvp_request for the specified slots (helps when you already have a slot(s), and need to request to them)
|
||||
factory :rsvp_request_for_slots do
|
||||
ignore do
|
||||
slots nil
|
||||
chosen nil
|
||||
end
|
||||
|
||||
after(:create) { |rsvp_request, evaluator |
|
||||
evaluator.slots.each do |slot|
|
||||
FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ describe MusicSession do
|
|||
|
||||
it "handles 2 instruments for a single request correctly" do
|
||||
|
||||
rsvp_request = FactoryGirl.create(:rsvp_request_for_multiple_slots, user: some_user, music_session: music_session1, number: 2)
|
||||
rsvp_request = FactoryGirl.create(:rsvp_request_for_multiple_slots, user: some_user, music_session: music_session1, number: 2, chosen:true)
|
||||
|
||||
approved_rsvps = music_session1.approved_rsvps
|
||||
approved_rsvps.length.should == 2
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@
|
|||
}
|
||||
|
||||
if(session['is_unstructured_rsvp?']) {
|
||||
openSlots = true;
|
||||
openSlots = true; // unstructured RSVP means there are always open slots
|
||||
openSlotsHtml += sessionUtils.createOpenSlot($openSlotsTemplate, {description: 'Any Instrument'})
|
||||
}
|
||||
|
||||
|
|
@ -188,15 +188,7 @@
|
|||
var showRsvpLink = true;
|
||||
var noLinkText = '';
|
||||
|
||||
if (!openRsvps && !hasInvitation) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = '<span class="text">You need an invitation to RSVP to this session.</span>';
|
||||
}
|
||||
else if(!openSlots) {
|
||||
showRsvpLink = false
|
||||
noLinkText = '<span class="text">No more openings in this session.</span>';
|
||||
}
|
||||
else if(approvedRsvpId) {
|
||||
if(approvedRsvpId) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = $('<span class="text">You have been confirmed for this session. <a href="#">Cancel</a></span>');
|
||||
noLinkText.find('a').click(function() {
|
||||
|
|
@ -228,6 +220,16 @@
|
|||
return false;
|
||||
});
|
||||
}
|
||||
else if(!openSlots) {
|
||||
showRsvpLink = false
|
||||
noLinkText = '<span class="text">No more openings in this session.</span>';
|
||||
}
|
||||
else if (!openRsvps && !hasInvitation) {
|
||||
showRsvpLink = false;
|
||||
noLinkText = '<span class="text">You need an invitation to RSVP to this session.</span>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// notation files
|
||||
if (session.music_notations) {
|
||||
|
|
|
|||
|
|
@ -517,6 +517,36 @@ FactoryGirl.define do
|
|||
factory :rsvp_request, class: JamRuby::RsvpRequest do
|
||||
canceled false
|
||||
cancel_all false
|
||||
|
||||
# creates *number* slots for a new rsvp_request
|
||||
factory :rsvp_request_for_multiple_slots do
|
||||
ignore do
|
||||
music_session nil
|
||||
number 1
|
||||
chosen nil
|
||||
end
|
||||
|
||||
after(:create) { |rsvp_request, evaluator |
|
||||
evaluator.number.times do |i|
|
||||
slot = FactoryGirl.create(:rsvp_slot, music_session: evaluator.music_session, instrument: Instrument.order(:id).limit(1).offset(i).first, proficiency_level: 1)
|
||||
FactoryGirl.create(:rsvp_request_rsvp_slot, chosen: evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# creates a rsvp_request for the specified slots
|
||||
factory :rsvp_request_for_slots do
|
||||
ignore do
|
||||
slots nil
|
||||
chosen nil
|
||||
end
|
||||
|
||||
after(:create) { |rsvp_request, evaluator |
|
||||
evaluator.slots.each do |slot|
|
||||
FactoryGirl.create(:rsvp_request_rsvp_slot, chosen:evaluator.chosen, rsvp_request: rsvp_request, rsvp_slot:slot)
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
factory :rsvp_request_rsvp_slot, class: JamRuby::RsvpRequestRsvpSlot do
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
|
|||
end
|
||||
|
||||
it "RSVP text shows correctly" do
|
||||
music_session = FactoryGirl.create(:music_session, creator: user, is_unstructured_rsvp: true)
|
||||
music_session = FactoryGirl.create(:music_session, creator: user)
|
||||
|
||||
fast_signin(user, Nav.find_session)
|
||||
|
||||
|
|
@ -187,11 +187,34 @@ describe "Find Session", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
sign_out
|
||||
|
||||
# create a slot so the session can be joined
|
||||
rsvp_slot = FactoryGirl.create(:rsvp_slot, music_session: music_session)
|
||||
go_to_root
|
||||
|
||||
fast_signin(finder, Nav.find_session)
|
||||
find("#sessions-scheduled .rsvp-link")
|
||||
|
||||
# now manipulate the database to make different states for the rsvp link/text area in find sessions
|
||||
# make a request (not yet chosen)
|
||||
rsvp_request = FactoryGirl.create(:rsvp_request_for_slots, chosen: nil, user: finder, slots: [rsvp_slot])
|
||||
|
||||
# first state: an unconfirmed RSVP
|
||||
go_to_root
|
||||
fast_signin(finder, Nav.find_session)
|
||||
find("#sessions-scheduled .rsvp-msg span.text", text: "You have RSVP'ed to this session. ")
|
||||
|
||||
rsvp_request.rsvp_requests_rsvp_slots[0].chosen = true
|
||||
rsvp_request.rsvp_requests_rsvp_slots[0].save!
|
||||
|
||||
# second state: a connfirmed RSVP
|
||||
go_to_root
|
||||
fast_signin(finder, Nav.find_session)
|
||||
find("#sessions-scheduled .rsvp-msg span.text", text: "You have been confirmed for this session. ")
|
||||
|
||||
|
||||
# need to now CANCEL, and check what it says: // VRFS-1891
|
||||
|
||||
# also need to check that it is open_rsvp = false.
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue