require 'spec_helper' describe "Find Session", :js => true, :type => :feature, :capybara_feature => true, :slow => true do subject { page } let(:user) { FactoryGirl.create(:user) } let(:finder) { FactoryGirl.create(:user) } before(:each) do UserMailer.deliveries.clear ActiveMusicSession.delete_all SessionInfoComment.delete_all Notification.delete_all RsvpRequestRsvpSlot.delete_all RsvpRequest.delete_all RsvpSlot.delete_all Invitation.delete_all MusicSession.delete_all end describe "basic" do before(:each) do emulate_client sign_in_poltergeist user visit "/client#/findSession" FactoryGirl.create(:friendship, :user => user, :friend => finder) end # when no sessions have been created: it "shows there are no sessions" do # verify no sessions are found expect(page).to have_selector('#no-active-sessions') expect(page).to have_selector('#no-scheduled-sessions') end it "finds another public session" do create_join_session(user, [finder]) end describe "listing behavior" do describe "active sessions" do let!(:session1) { FactoryGirl.create(:single_user_session) } it "find one active session" do find('#btn-refresh').trigger(:click) page.assert_selector('div#sessions-active .found-session', count: 1) end it "find many active sessions" do 20.times do FactoryGirl.create(:single_user_session) end find('#btn-refresh').trigger(:click) page.assert_selector('div#sessions-active .found-session', count: 20) # attempt to scroll down--the end of session list should show, and there should now be 21 items # page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element # find('#end-of-session-list') # page.all('div#sessions-active .found-session').count.should == 21 end end describe "scheduled sessions" do let!(:scheduled_session) {FactoryGirl.create(:music_session) } it "find one scheduled session" do find('#btn-refresh').trigger(:click) page.assert_selector('div#sessions-scheduled .found-session', count: 1) end it "finds many scheduled sessions" do 20.times do FactoryGirl.create(:music_session) end find('#btn-refresh').trigger(:click) page.assert_selector('div#sessions-scheduled .found-session', count: 20) page.execute_script('jQuery("#findSession .content-body-scroller").scrollTo("100%",100)') #scroll to the bottom of the element find('#end-of-ss-list') page.assert_selector('div#sessions-scheduled .found-session', count: 21) end end end end describe "active sessions" do it "should render session details" do # name # genre # description # notation files # musicians in session # approved RSVPs # open slots # latency tag # chat language # musician access # fan access # legal policy end it "should allow user to join if invited" do end it "should allow user to join if musician_access is true" do end it "should allow user to join if invited and musician_access is false" do end end describe "scheduled sessions" do it "should render session details" do # name # genre # description # notation files # approved RSVPs # open slots # latency tag # chat language # musician access # fan access # legal policy end it "should allow user to RSVP if invited" do end it "should allow user to RSVP if open_rsvps is true" do end it "should allow user to RSVP if invited and open_rsvps is false" do end end describe "rsvp behavior" do before(:each) do stub_const("APP_CONFIG", web_config) end it "handles is_unstructured_rsvp sessions correctly" do # create an unstructured session music_session = FactoryGirl.create(:music_session, creator: user, is_unstructured_rsvp: true) fast_signin(finder, Nav.find_session) # verify it says the right thing in the 'Still Needed' section find("#sessions-scheduled tr.found-session div.instruments", text: 'Any Instrument (Any Skill Level)') # bring up the RSVP dialog find('.rsvp-link').trigger(:click) # select the only option (Any Instrument) find('.rsvp-instruments input[value="unstructured"]').trigger(:click) # submit the RSVP find('#btnSubmitRsvp').trigger(:click) # TODO: verify that the UI works - after VRFS-1892 end it "RSVP text shows correctly" do music_session = FactoryGirl.create(:music_session, creator: user) fast_signin(user, Nav.find_session) find("#sessions-scheduled .rsvp-msg span.text", text: "You have been confirmed for this session. ") 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