VRFS-1749 more session info tests / fix "deprecated" warnings
This commit is contained in:
parent
07864a0f76
commit
a557e9966a
|
|
@ -468,7 +468,8 @@ module JamRuby
|
|||
inner join rsvp_requests rr on rrrs.rsvp_request_id = rr.id
|
||||
inner join users u on u.id = rr.user_id
|
||||
where rrrs.chosen = true and rs.music_session_id = '#{self.id}'
|
||||
order by u.id})
|
||||
order by u.id}
|
||||
)
|
||||
|
||||
users_collapsed_instruments = []
|
||||
user = User.new
|
||||
|
|
@ -481,10 +482,10 @@ module JamRuby
|
|||
user.photo_url = u.photo_url
|
||||
user.first_name = u.first_name
|
||||
user.last_name = u.last_name
|
||||
user["instruments"] = [u.instrument_id]
|
||||
user.instrument_list = [u.instrument_id]
|
||||
users_collapsed_instruments << user
|
||||
else
|
||||
user["instruments"] << u.instrument_id
|
||||
user.instrument_list << u.instrument_id
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -514,7 +515,8 @@ module JamRuby
|
|||
inner join invitations i on u.id = i.receiver_id
|
||||
left join rsvp_requests rr on rr.user_id = i.receiver_id
|
||||
where i.music_session_id = '#{self.id}'
|
||||
and rr.user_id is null})
|
||||
and rr.user_id is null}
|
||||
)
|
||||
end
|
||||
|
||||
def recordings
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ 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
|
||||
|
||||
# contains a list of instrument IDs (used to aggregate instruments under a user for various screens)
|
||||
attr_accessor :instrument_list
|
||||
|
||||
belongs_to :icecast_server_group, class_name: "JamRuby::IcecastServerGroup", inverse_of: :users, foreign_key: 'icecast_server_group_id'
|
||||
|
||||
# authorizations (for facebook, etc -- omniauth)
|
||||
|
|
@ -1240,6 +1243,19 @@ module JamRuby
|
|||
User.where(:email => email).limit(1).pluck(:id).first
|
||||
end
|
||||
|
||||
def has_approved_rsvp(session)
|
||||
approved_slots = RsvpSlot.find_by_sql(%Q{select rs.*
|
||||
from rsvp_slots rs
|
||||
inner join rsvp_requests_rsvp_slots rrrs on rrrs.rsvp_slot_id = rs.id
|
||||
inner join rsvp_requests rr on rr.id = rrrs.rsvp_request_id
|
||||
where rs.music_session_id = '#{session.id}'
|
||||
and rr.user_id = '#{self.id}'
|
||||
and rrrs.chosen = true
|
||||
})
|
||||
|
||||
!approved_slots.blank?
|
||||
end
|
||||
|
||||
# end devise compatibility
|
||||
private
|
||||
def create_remember_token
|
||||
|
|
|
|||
|
|
@ -150,9 +150,6 @@ class ApiMusicSessionsController < ApiController
|
|||
respond_with @music_session, responder: ApiResponder, :location => api_session_detail_url(@music_session)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -41,14 +41,14 @@ class MusicSessionsController < ApplicationController
|
|||
|
||||
# session has started
|
||||
else
|
||||
if @music_session.musician_access
|
||||
if @music_session.approval_required
|
||||
@can_view = false
|
||||
if @music_session.musician_access || current_user.id == @music_session.creator.id
|
||||
@can_view = true
|
||||
else
|
||||
if current_user.has_approved_rsvp(@music_session)
|
||||
@can_view = true
|
||||
else
|
||||
@can_view = false
|
||||
end
|
||||
else
|
||||
@can_view = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
.left.f11.ml10.rsvp-name
|
||||
= rsvp.name
|
||||
.left.ml10
|
||||
- rsvp["instruments"].each do |i|
|
||||
- rsvp.instrument_list.each do |i|
|
||||
%img.instrument-icon{'instrument-id' => i, height:24, width:24}
|
||||
|
||||
%br{:clear => "all"}/
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
|
|||
FactoryGirl.create(:friendship, :user => @rsvp_declined_user, :friend => @session_creator)
|
||||
FactoryGirl.create(:friendship, :user => @session_creator, :friend => @rsvp_declined_user)
|
||||
|
||||
@music_session = FactoryGirl.build(:music_session, :creator => @session_creator, :scheduled_start => Time.now.utc + 2.days)
|
||||
@music_session = FactoryGirl.build(:music_session, :creator => @session_creator, :scheduled_start => Time.now.utc + 2.days, :musician_access => true, :approval_required => true)
|
||||
@music_session.save
|
||||
|
||||
@url = "/sessions/#{@music_session.id}/details"
|
||||
|
|
@ -119,6 +119,8 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
describe "view" do
|
||||
|
||||
########### BEGIN SESSION STARTS ###########
|
||||
|
||||
it "should render for any musician for sessions with open RSVPs before session starts" do
|
||||
|
||||
@music_session.open_rsvps = true
|
||||
|
|
@ -187,46 +189,110 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
|
|||
sign_out_poltergeist
|
||||
end
|
||||
|
||||
# musician_access = false, approval_required = false
|
||||
it "should allow only RSVP approvals to view for 'XXX' option after session starts" do
|
||||
# attempt to access with musician who wasn't invited
|
||||
########### AFTER SESSION STARTS ###########
|
||||
|
||||
# musician_access = false, approval_required = false
|
||||
it "should allow only RSVP approvals to view for 'rsvp_only' option after session starts" do
|
||||
@music_session.musician_access = false
|
||||
@music_session.approval_required = false
|
||||
@music_session.scheduled_start = Time.now.utc - 1.hours
|
||||
@music_session.save!
|
||||
|
||||
# attempt to access with musician who was invited but didn't RSVP
|
||||
sign_in_poltergeist(@session_invitee)
|
||||
visit @url
|
||||
ensure_failure
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who wasn't invited
|
||||
sign_in_poltergeist(@non_session_invitee)
|
||||
visit @url
|
||||
ensure_failure
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed but wasn't approved
|
||||
|
||||
sign_in_poltergeist(@rsvp_declined_user)
|
||||
visit @url
|
||||
ensure_failure
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed and was approved
|
||||
sign_in_poltergeist(@rsvp_approved_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'CANCEL RSVP'})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with session creator
|
||||
sign_in_poltergeist(@session_creator)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
end
|
||||
|
||||
# musician_access = true, approval_required = false
|
||||
it "should allow anyone to view for 'at will' option after session starts" do
|
||||
# attempt to access with musician who wasn't invited
|
||||
|
||||
|
||||
# attempt to access with musician who was invited but didn't RSVP
|
||||
sign_in_poltergeist(@session_invitee)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'RSVP NOW!'})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who wasn't invited
|
||||
sign_in_poltergeist(@non_session_invitee)
|
||||
visit @url
|
||||
ensure_failure # NON-INVITEE SHOULD NOT BE ABLE TO VIEW FOR CLOSED RSVPs
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed but wasn't approved
|
||||
|
||||
sign_in_poltergeist(@rsvp_declined_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed and was approved
|
||||
sign_in_poltergeist(@rsvp_approved_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'CANCEL RSVP'})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with session creator
|
||||
sign_in_poltergeist(@session_creator)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
end
|
||||
|
||||
# musician_access = true, approval_required = true
|
||||
it "should allow anyone to view for 'join by approval' option after session starts" do
|
||||
# attempt to access with musician who wasn't invited
|
||||
|
||||
|
||||
# attempt to access with musician who was invited but didn't RSVP
|
||||
sign_in_poltergeist(@session_invitee)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'RSVP NOW!'})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who wasn't invited
|
||||
sign_in_poltergeist(@non_session_invitee)
|
||||
visit @url
|
||||
ensure_failure # NON-INVITEE SHOULD NOT BE ABLE TO VIEW FOR CLOSED RSVPs
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed but wasn't approved
|
||||
|
||||
sign_in_poltergeist(@rsvp_declined_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with musician who RSVP'ed and was approved
|
||||
sign_in_poltergeist(@rsvp_approved_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'CANCEL RSVP'})
|
||||
sign_out_poltergeist
|
||||
|
||||
# attempt to access with session creator
|
||||
sign_in_poltergeist(@session_creator)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
end
|
||||
|
||||
it "should allow only RSVP approvals or session invitees to add comments" do
|
||||
|
|
|
|||
Loading…
Reference in New Issue