Merge branch 'feature/scheduled_sessions' of bitbucket.org:jamkazam/jam-cloud into feature/scheduled_sessions
This commit is contained in:
commit
839605255d
|
|
@ -10,6 +10,8 @@ module JamRuby
|
|||
|
||||
attr_accessor :legal_terms, :language_description, :scheduled_start_time, :access_description
|
||||
|
||||
attr_accessor :approved_rsvps, :open_slots, :pending_invitations
|
||||
|
||||
self.table_name = "music_sessions"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
|
@ -467,7 +469,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
|
||||
|
|
@ -480,10 +483,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
|
||||
|
||||
|
|
@ -513,7 +516,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)
|
||||
|
|
@ -1251,6 +1254,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
|
||||
|
|
|
|||
|
|
@ -162,9 +162,6 @@ class ApiMusicSessionsController < ApiController
|
|||
respond_with @music_session, responder: ApiResponder, :location => api_session_detail_url(@music_session)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ class MusicSessionsController < ApplicationController
|
|||
|
||||
def session_info
|
||||
@can_view = true
|
||||
@can_comment = false
|
||||
|
||||
# check whether user is logged in
|
||||
if current_user.nil?
|
||||
|
|
@ -28,27 +27,20 @@ class MusicSessionsController < ApplicationController
|
|||
if @music_session.scheduled_start > Time.now.utc
|
||||
if @music_session.creator.id == current_user.id || @music_session.open_rsvps || has_invitation
|
||||
@can_view = true
|
||||
@can_comment = true
|
||||
else
|
||||
@can_view = false
|
||||
@can_comment = false
|
||||
end
|
||||
|
||||
# only allow comments for invitees before the session has started
|
||||
unless has_invitation
|
||||
@can_comment = true
|
||||
end
|
||||
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
object @rsvp_request
|
||||
|
||||
attributes :id, :canceled, :cancel_all, :created_at
|
||||
attributes :id, :user_id, :canceled, :cancel_all, :created_at
|
||||
|
||||
child(:user => :user) {
|
||||
attributes :id, :name, :photo_url
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
%span.f12 Session Creator
|
||||
%br/
|
||||
%br/
|
||||
- if current_user.id != @music_session.creator.id
|
||||
- if current_user.id != @music_session.creator.id || (@open_slots.blank? && !@approved_rsvps.include?(current_user))
|
||||
.f12.call-to-action
|
||||
%br/
|
||||
%a.button-orange{:id => "btn-action"}
|
||||
|
|
@ -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"
|
||||
|
|
@ -108,9 +108,6 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
|
|||
|
||||
# right sidebar - Pending Invitations
|
||||
find('div[user-id="' + @session_invitee.id + '"]')
|
||||
|
||||
# comments
|
||||
find('#txtSessionInfoComment')
|
||||
end
|
||||
|
||||
def ensure_failure
|
||||
|
|
@ -119,6 +116,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,55 +186,123 @@ 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
|
||||
end
|
||||
sign_in_poltergeist(@rsvp_approved_user)
|
||||
visit @url
|
||||
ensure_success({:show_cta => true, :button_text => 'CANCEL RSVP'})
|
||||
sign_out_poltergeist
|
||||
|
||||
it "should allow only RSVP approvals or session invitees to add comments" do
|
||||
# attempt to access with session creator
|
||||
sign_in_poltergeist(@session_creator)
|
||||
visit @url
|
||||
ensure_success({:show_cta => false})
|
||||
sign_out_poltergeist
|
||||
end
|
||||
|
||||
it "should show no call to action button if user has not RSVPed and all slots are taken" do
|
||||
end
|
||||
pending
|
||||
rs2 = RsvpRequestRsvpSlot.find_by_rsvp_request_id_and_rsvp_slot_id(@rsvp1.id, @slot2.id)
|
||||
|
||||
it "should show no call to action button for session organizer" do
|
||||
# approve slot 2 as well to make all slots taken for this session
|
||||
RsvpRequest.update({:id => @rsvp1.id, :session_id => @music_session.id, :rsvp_responses => [{:request_slot_id => rs2.id, :accept => true}]}, @session_creator)
|
||||
|
||||
sign_in_poltergeist(@session_invitee)
|
||||
visit @url
|
||||
expect {find('#btn-action')}.to raise_error(Capybara::ElementNotFound)
|
||||
sign_out_poltergeist
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue