diff --git a/web/app/assets/javascripts/accounts.js b/web/app/assets/javascripts/accounts.js index 64501695d..90b0c4e5e 100644 --- a/web/app/assets/javascripts/accounts.js +++ b/web/app/assets/javascripts/accounts.js @@ -105,9 +105,11 @@ } function renderAccount() { + app.user().done(function() { rest.getUserDetail() - .done(populateAccount) - .error(app.ajaxError) + .done(populateAccount) + .error(app.ajaxError) + }) } function navToScheduledSessions() { diff --git a/web/app/assets/javascripts/dialog/loginRequiredDialog.js b/web/app/assets/javascripts/dialog/loginRequiredDialog.js new file mode 100644 index 000000000..6795614c1 --- /dev/null +++ b/web/app/assets/javascripts/dialog/loginRequiredDialog.js @@ -0,0 +1,45 @@ +(function(context,$) { + + "use strict"; + context.JK = context.JK || {}; + context.JK.LoginRequiredDialog = function(app) { + var logger = context.JK.logger; + var $dialog = null; + var dialogId = 'login-required-dialog'; + + function beforeShow(data) { + } + + function afterShow(data) { + } + + function afterHide() { + } + + function events() { + $dialog.find('.go-to-jamtracks').click(function() { + app.layout.closeDialog(dialogId) + context.location.href = $(this).attr('href') + }) + } + + function initialize() { + + var dialogBindings = { + 'beforeShow' : beforeShow, + 'afterShow' : afterShow, + 'afterHide': afterHide + }; + + app.bindDialog(dialogId, dialogBindings); + + $dialog = $('#' + dialogId); + + events(); + } + + this.initialize = initialize; + }; + + return this; +})(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/everywhere/everywhere.js b/web/app/assets/javascripts/everywhere/everywhere.js index 4564cd9b0..b8c0f62d5 100644 --- a/web/app/assets/javascripts/everywhere/everywhere.js +++ b/web/app/assets/javascripts/everywhere/everywhere.js @@ -127,6 +127,9 @@ var clientPreferencesDialog = new JK.ClientPreferencesDialog(app); clientPreferencesDialog.initialize(); + + var loginRequiredDialog = new JK.LoginRequiredDialog(app); + loginRequiredDialog.initialize(); } // wait 10 seconds diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index f54feb866..d3c4638c2 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -57,9 +57,11 @@ }) .fail(function(xhr, textStatus, errorMessage) { if (xhr.status === 404) { + logger.warn("unable to list active sessions (404)") // swallow 404 } else { + logger.warn("unable to list active sessions") app.ajaxError(xhr, textStatus, errorMessage); } }) diff --git a/web/app/assets/javascripts/homeScreen.js b/web/app/assets/javascripts/homeScreen.js index 997927dbd..ec7b86d50 100644 --- a/web/app/assets/javascripts/homeScreen.js +++ b/web/app/assets/javascripts/homeScreen.js @@ -6,6 +6,7 @@ context.JK.HomeScreen = function(app) { var logger = context.JK.logger; var isFtueComplete = false; + var $screen = null; function beforeShow(data) { } @@ -86,9 +87,20 @@ var screenBindings = { 'beforeShow': beforeShow }; app.bindScreen('home', screenBindings); events(); + $screen = $('.screen[layout-id="home"]') - $('.profile').on('click', function() { + $screen.find('.profile').on('click', function() { + var $destination = $('[layout-id="profile"]'); + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + // if there is no user and login is required, then stop user from clicknig through + app.layout.showDialog('login-required-dialog') + } + else + { context.location = '/client#/profile/' + context.JK.currentUserId; + } + + }); }; diff --git a/web/app/assets/javascripts/jam_track_utils.js.coffee b/web/app/assets/javascripts/jam_track_utils.js.coffee index 2935665cc..8ba73f592 100644 --- a/web/app/assets/javascripts/jam_track_utils.js.coffee +++ b/web/app/assets/javascripts/jam_track_utils.js.coffee @@ -16,7 +16,7 @@ class JamTrackUtils @rest.getShoppingCarts().done(this.displayCartIcon) displayCartIcon: (carts) => - cartLink = $("a[href='" + "/client#/shoppingCart" + "']") + cartLink = $("#header-shopping-cart") if carts.length > 0 cartLink.removeClass("hidden") else diff --git a/web/app/assets/javascripts/jamkazam.js b/web/app/assets/javascripts/jamkazam.js index db0615510..2bc31b957 100644 --- a/web/app/assets/javascripts/jamkazam.js +++ b/web/app/assets/javascripts/jamkazam.js @@ -132,6 +132,9 @@ logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage); app.notify({title: "Oops!", text: "What you were looking for is gone now."}); } + else if(jqXHR.status === 403) { + logger.debug("not logged in"); + } else if (jqXHR.status === 422) { logger.error("Unexpected ajax error: " + textStatus + ", msg: " + errorMessage + ", response: " + jqXHR.responseText); // present a nicer message @@ -282,20 +285,37 @@ var hash = context.location.hash; + var screen = 'home' try { - context.RouteMap.parse(hash); + var location = context.RouteMap.parse(hash); + screen = location.page.substring(1); // remove leading slash } catch (e) { logger.debug("ignoring bogus screen name: %o", hash) hash = null; } - var url = '/client#/home'; + + var $destination = $('[layout-id="' + screen + '"]'); + + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + logger.debug("not logged in so redirected to login from screen: " + screen) + var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); + if(gon.isNativeClient) { + window.location.href = '/signin' + redirectPath; + } + else { + window.location.href = '/' + redirectPath; + } + return; + } + + var url = '/client#/' + screen; if (hash) { url = hash; } - logger.debug("Changing screen to " + url); + logger.debug("jamkazam: Changing screen to " + url + " (hash=" + hash + ")") ; context.location = url; } @@ -377,7 +397,11 @@ app.notify({title: "Unable to Load User", text: "You should reload the page."}) }); } - } // if userDeferred + } + else { + userDeferred = new $.Deferred(); + userDeferred.reject('not_logged_in'); + } $(document).triggerHandler('JAMKAZAM_READY', {app:app}) diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index 6c40f596d..1179f71b2 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -415,8 +415,15 @@ } var destination = $(evt.currentTarget).attr('layout-link'); - var destinationType = $('[layout-id="' + destination + '"]').attr("layout"); + var $destination = $('[layout-id="' + destination + '"]'); + + var destinationType = $destination.attr("layout"); if (destinationType === "screen") { + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + // there is no user, and this item does not support 'no-login', so warn user + showDialog('login-required-dialog'); + return; + } context.location = '/client#/' + destination; } else if (destinationType === "dialog") { showDialog(destination); @@ -548,7 +555,7 @@ var accepted = screenEvent(previousScreen, 'beforeHide', data); if(accepted === false) return; - logger.debug("Changing screen to " + currentScreen); + logger.debug("layout: changing screen to " + currentScreen); $(document).triggerHandler(EVENTS.SCREEN_CHANGED, {previousScreen: previousScreen, newScreen: currentScreen}) @@ -695,6 +702,7 @@ return null; } logger.debug("opening dialog: " + dialog) + var $overlay = $('.dialog-overlay') if (opts.sizeOverlayToContent) { @@ -727,6 +735,12 @@ function panelHeaderClicked(evt) { evt.preventDefault(); + + if(!context.JK.currentUserId) { + showDialog('login-required-dialog'); + return false; + } + expandedPanel = $(evt.currentTarget).closest('[layout="panel"]').attr("layout-id"); layout(); return false; diff --git a/web/app/assets/javascripts/notificationPanel.js b/web/app/assets/javascripts/notificationPanel.js index 7c3e608de..c6e1f25bc 100644 --- a/web/app/assets/javascripts/notificationPanel.js +++ b/web/app/assets/javascripts/notificationPanel.js @@ -213,7 +213,7 @@ }) .fail(function() { isLoading = false; - app.ajaxError(); + app.ajaxError(arguments); }) } @@ -1375,7 +1375,9 @@ events(); - populate(); + app.user().done(function(){ + populate(); + }) }; this.initialize = initialize; diff --git a/web/app/assets/javascripts/scheduled_session.js.erb b/web/app/assets/javascripts/scheduled_session.js.erb index 969f9449d..cf75275e1 100644 --- a/web/app/assets/javascripts/scheduled_session.js.erb +++ b/web/app/assets/javascripts/scheduled_session.js.erb @@ -1054,7 +1054,7 @@ context.JK.GenreSelectorHelper.render('#create-session-genre'); - inviteMusiciansUtil.loadFriends(); + //inviteMusiciansUtil.loadFriends(); context.JK.dropdown($screen.find('#session-musician-access')); context.JK.dropdown($screen.find('#session-fans-access')); diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index d60d59868..cf733c451 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -13,6 +13,7 @@ var notificationPanel = null; var chatPanel = null; var me = null; + var $sidebar = null; function initializeSearchPanel() { $('#search_text_type').change(function() { @@ -39,7 +40,9 @@ function initializeFriendsPanel() { $('#sidebar-search-header').hide(); - refreshFriends(); + app.user().done(function() { + refreshFriends(); + }) return false; } @@ -406,11 +409,24 @@ me = this; invitationDialog = invitationDialogInstance; textMessageDialog = textMessageDialogInstance; - events(); - initializeSearchPanel(); - initializeFriendsPanel(); - initializeChatPanel(); - initializeNotificationsPanel(); + $sidebar = $('#sidebar-div') + app.user() + .done(function() { + events(); + initializeSearchPanel(); + initializeFriendsPanel(); + initializeChatPanel(); + initializeNotificationsPanel(); + }) + .fail(function(arg1) { + if(arg1 == "not_logged_in") { + $('#search-input').attr('disabled', 'disabled') + $('.sidebar .invite-friend-row').click(function() { + app.layout.showDialog('login-required-dialog') + }); + $sidebar.addClass('not-logged-in') + } + }) }; this.refreshFriends = refreshFriends; diff --git a/web/app/assets/stylesheets/client/home.css.scss b/web/app/assets/stylesheets/client/home.css.scss index d9b7d9d45..9263fa2d7 100644 --- a/web/app/assets/stylesheets/client/home.css.scss +++ b/web/app/assets/stylesheets/client/home.css.scss @@ -8,6 +8,10 @@ background-repeat: no-repeat; background-position: bottom left; border: 1px solid $translucent1; + + &.not-logged-in { + opacity:0.6; + } } .homecard.createsession { background-image: url(/assets/content/bkg_home_create.jpg); diff --git a/web/app/assets/stylesheets/client/sidebar.css.scss b/web/app/assets/stylesheets/client/sidebar.css.scss index 17c975616..59a3bdfb5 100644 --- a/web/app/assets/stylesheets/client/sidebar.css.scss +++ b/web/app/assets/stylesheets/client/sidebar.css.scss @@ -5,6 +5,10 @@ background-color: $ColorElementPrimary; + &.not-logged-in { + opacity:0.6; + } + .panel-header { margin:0px; padding:0px; diff --git a/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss b/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss new file mode 100644 index 000000000..bc27a60ed --- /dev/null +++ b/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss @@ -0,0 +1,12 @@ +#login-required-dialog { + + width:455px; + + p { + margin:0 0 20px 0; + } + + .buttons { + margin-top:20px; + } +} \ No newline at end of file diff --git a/web/app/controllers/api_genres_controller.rb b/web/app/controllers/api_genres_controller.rb index c413bf1f2..293552737 100644 --- a/web/app/controllers/api_genres_controller.rb +++ b/web/app/controllers/api_genres_controller.rb @@ -1,8 +1,5 @@ class ApiGenresController < ApiController - # have to be signed in currently to see this screen - before_filter :api_signed_in_user - respond_to :json def index diff --git a/web/app/controllers/api_instruments_controller.rb b/web/app/controllers/api_instruments_controller.rb index fc2c44fd9..c5f10bd49 100644 --- a/web/app/controllers/api_instruments_controller.rb +++ b/web/app/controllers/api_instruments_controller.rb @@ -1,8 +1,5 @@ class ApiInstrumentsController < ApiController - # have to be signed in currently to see this screen - before_filter :api_signed_in_user - respond_to :json def index diff --git a/web/app/helpers/sessions_helper.rb b/web/app/helpers/sessions_helper.rb index 3545c3d05..6665b8c00 100644 --- a/web/app/helpers/sessions_helper.rb +++ b/web/app/helpers/sessions_helper.rb @@ -26,6 +26,10 @@ module SessionsHelper !current_user.nil? end + def logged_in_not_logged_in_class + signed_in? ? "logged-in" : "not-logged-in" + end + def current_user=(user) @current_user = user end diff --git a/web/app/views/clients/_header.html.erb b/web/app/views/clients/_header.html.erb index 855f0e988..de9015e66 100644 --- a/web/app/views/clients/_header.html.erb +++ b/web/app/views/clients/_header.html.erb @@ -13,8 +13,8 @@ <% if Rails.application.config.jam_tracks_available %> - - + <% end %> diff --git a/web/app/views/clients/_home.html.slim b/web/app/views/clients/_home.html.slim index 8130e82cc..2c07e10b2 100644 --- a/web/app/views/clients/_home.html.slim +++ b/web/app/views/clients/_home.html.slim @@ -1,4 +1,4 @@ -.screen layout="screen" layout-id="home" +.screen.no-login-required layout="screen" layout-id="home" -if Rails.configuration.show_jamblaster_notice #jamblaster-notice a href='https://www.youtube.com/watch?v=gAJAIHMyois' rel="external" @@ -15,23 +15,23 @@ / individual spells span those spaces -if @nativeClient .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" h2 bands .homebox-info /! 1 session invitation, 19 public sessions active @@ -40,33 +40,33 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" h2 account .homebox-info /! free service level -else .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" h2 bands .homebox-info -if jamtracks @@ -75,11 +75,11 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" h2 account .homebox-info /! free service level diff --git a/web/app/views/clients/_jamtrack.html.haml b/web/app/views/clients/_jamtrack.html.haml index 2573197b3..5041a66ca 100644 --- a/web/app/views/clients/_jamtrack.html.haml +++ b/web/app/views/clients/_jamtrack.html.haml @@ -1,4 +1,4 @@ -%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary'} +%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary no-login-required'} .content .content-head .content-icon= image_tag("content/icon_jamtracks.png", {:height => 19, :width => 19}) diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index 7586d0e9b..6a232252c 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -108,20 +108,7 @@ JK.currentUserName = null; JK.currentUserMusician = null; JK.currentUserAdmin = false; - - // you need to be logged in to use this part of the interface. - // save original URL, and redirect to the home page - logger.debug("redirecting back to / because not logged in") - - var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); - if(gon.isNativeClient) { - window.location.href = '/signin' + redirectPath; - } - else { - window.location.href = '/' + redirectPath; - } - - <% end %> + <% end %> // Some things can't be initialized until we're connected. Put them here. @@ -288,6 +275,8 @@ JK.ClientUpdateInstance.check() JK.app.initialRouting(); + + JK.hideCurtain(300); } @@ -303,10 +292,10 @@ JK.RecordingUtils.init(); - // Let's get things rolling... - if (JK.currentUserId) { + JK.app.initialize(); - JK.app.initialize(); + // Let's get things rolling... + if (JK.currentUserId) { JK.JamServer.registerMessageCallback(JK.MessageType.CLIENT_UPDATE, function(header, payload) { // do a client update early check upon initialization @@ -314,7 +303,7 @@ }); - JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); + JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); JK.JamServer.connect() // singleton here defined in JamServer.js .done(function() { @@ -327,6 +316,9 @@ // this ensures that there is always a CurrentSessionModel, even if it's for a non-active session JK.CurrentSessionModel = new JK.SessionModel(JK.app, JK.JamServer, window.jamClient, null); } + else { + _initAfterConnect(false); + } JK.bindHoverEvents(); }) diff --git a/web/app/views/dialogs/_dialogs.html.haml b/web/app/views/dialogs/_dialogs.html.haml index 2b7ac1206..164eb93f8 100644 --- a/web/app/views/dialogs/_dialogs.html.haml +++ b/web/app/views/dialogs/_dialogs.html.haml @@ -34,3 +34,4 @@ = render 'dialogs/adjustGearSpeedDialog' = render 'dialogs/openJamTrackDialog' = render 'dialogs/openBackingTrackDialog' += render 'dialogs/loginRequiredDialog' diff --git a/web/app/views/dialogs/_loginRequiredDialog.html.slim b/web/app/views/dialogs/_loginRequiredDialog.html.slim new file mode 100644 index 000000000..4b979e68d --- /dev/null +++ b/web/app/views/dialogs/_loginRequiredDialog.html.slim @@ -0,0 +1,20 @@ +.dialog.dialog-overlay-sm layout='dialog' layout-id='login-required-dialog' id='login-required-dialog' + .content-head + = image_tag "content/icon_alert.png", {:width => 24, :height => 24, :class => 'content-icon' } + h1 Login Required + + .dialog-inner + p + a href="/signup" Sign Up + |  or  + a href="/signin" Sign In + |  to access most functionality on this page. + p + | However, you can browse for  + a class="go-to-jamtracks" href='/client#/jamtrack' JamTracks + |  without logging in. + br + .clearall + .buttons + .right + a.button-orange class='btnClose' layout-action='close' CLOSE \ No newline at end of file diff --git a/web/spec/controllers/api_jam_tracks_controller_spec.rb b/web/spec/controllers/api_jam_tracks_controller_spec.rb index 5ec41f318..7cecfc136 100644 --- a/web/spec/controllers/api_jam_tracks_controller_spec.rb +++ b/web/spec/controllers/api_jam_tracks_controller_spec.rb @@ -60,19 +60,6 @@ describe ApiJamTracksController do json["next"].should be_nil json["jamtracks"].length.should == 2 end - - it "lists owned tracks" do - get :downloads - response.should be_success - json = JSON.parse(response.body) - json['downloads'].should have(0).items - - right = JamTrackRight.create(:user=>@user, :jam_track=>@jam_track) - get :downloads - response.should be_success - json = JSON.parse(response.body) - json['downloads'].should have(1).items - end it "finds a download" do #get "/download/#{right.id}/" diff --git a/web/spec/features/authentication_pages_spec.rb b/web/spec/features/authentication_pages_spec.rb index 7aea9cb9d..70aae8a2b 100644 --- a/web/spec/features/authentication_pages_spec.rb +++ b/web/spec/features/authentication_pages_spec.rb @@ -62,7 +62,8 @@ describe "Authentication", :js => true, :type => :feature, :capybara_feature => find('.userinfo .sign-out a').trigger(:click) end - it { find('h1', text: 'Play music together over the Internet as if in the same room') } + # after logging out, we keep you at /client + it { find('#profile a.signin', text: 'Sign Up') } end end end diff --git a/web/spec/features/in_session_spec.rb b/web/spec/features/in_session_spec.rb index ef96b1deb..a17f0d16a 100644 --- a/web/spec/features/in_session_spec.rb +++ b/web/spec/features/in_session_spec.rb @@ -28,7 +28,9 @@ describe "In a Session", :js => true, :type => :feature, :capybara_feature => tr sign_in_poltergeist finder visit "/client#/findSession" expect(page).to have_selector('#no-active-sessions') # verify private session is not found - sign_out_poltergeist(validate: true) + #sign_out_poltergeist(validate: true) + visit "/" + should_be_at_root end in_client(user) do set_session_access :public diff --git a/web/spec/features/profile_menu_spec.rb b/web/spec/features/profile_menu_spec.rb index caf48209d..c70240b4f 100644 --- a/web/spec/features/profile_menu_spec.rb +++ b/web/spec/features/profile_menu_spec.rb @@ -53,7 +53,7 @@ describe "Profile Menu", :js => true, :type => :feature, :capybara_feature => tr click_link 'Sign Out' end - it { should_be_at_root } + it { should_be_at_logged_out_client } end describe "Download App link" do diff --git a/web/spec/features/signin_spec.rb b/web/spec/features/signin_spec.rb index 689b8251b..ad4f7dfec 100644 --- a/web/spec/features/signin_spec.rb +++ b/web/spec/features/signin_spec.rb @@ -175,7 +175,7 @@ describe "signin" do click_button "SIGN IN" end - find('h1', text: 'Play music together over the Internet as if in the same room') + should_be_at_logged_out_client end # if a cookie with the default domain is found with another, delete the one with the default domain @@ -201,7 +201,7 @@ describe "signin" do click_button "SIGN IN" end - find('h1', text: 'Play music together over the Internet as if in the same room') + should_be_at_logged_out_client delete_called.should be_true end @@ -211,6 +211,23 @@ describe "signin" do sign_in_poltergeist(user) sign_out_poltergeist + + wait_until_curtain_gone + + # musicians homecard should be disabled + find('.homecard.musicians.not-logged-in').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) + + # profile homecard should be disabled (this one is handled in homeScreen.js instead of in layout.js) + find('.homecard.profile.not-logged-in').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) + + # sidebar should be disabled + find('[layout-id="panelSearch"] [layout-panel="expanded"] [layout-panel="header"]').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index 8982fd5a1..7a89d9b23 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -200,7 +200,7 @@ end def sign_out_poltergeist(options = {}) open_user_dropdown click_link 'Sign Out' - should_be_at_signin if options[:validate] + should_be_at_logged_out_client if options[:validate] end def open_user_dropdown @@ -221,6 +221,11 @@ def should_be_at_signin find('h1', text: 'sign in or register') end +def should_be_at_logged_out_client + find('#profile a.signin', text: 'Sign Up') + find('.musicians.not-logged-in') +end + def leave_music_session_sleep_delay # add a buffer to ensure WSG has enough time to expire sleep_dur = (Rails.application.config.websocket_gateway_connect_time_stale_browser +