From 69b4342731793d539a89bc2a759d98287e4d4127 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 23 Feb 2014 21:04:02 -0500 Subject: [PATCH 1/7] remove puts statements --- ruby/lib/jam_ruby/models/music_session_history.rb | 2 -- ruby/lib/jam_ruby/models/notification.rb | 1 - 2 files changed, 3 deletions(-) diff --git a/ruby/lib/jam_ruby/models/music_session_history.rb b/ruby/lib/jam_ruby/models/music_session_history.rb index f728493b5..553c03bac 100644 --- a/ruby/lib/jam_ruby/models/music_session_history.rb +++ b/ruby/lib/jam_ruby/models/music_session_history.rb @@ -173,8 +173,6 @@ module JamRuby hist.end_history if hist - puts "**************NOTIFICATION SESSION ENDED**************" - Notification.send_session_ended(session_id) end diff --git a/ruby/lib/jam_ruby/models/notification.rb b/ruby/lib/jam_ruby/models/notification.rb index ab6708ca4..6bb3ec67a 100644 --- a/ruby/lib/jam_ruby/models/notification.rb +++ b/ruby/lib/jam_ruby/models/notification.rb @@ -357,7 +357,6 @@ module JamRuby # publish to all users who have a notification for this session # TODO: do this in BULK or in async block notifications.each do |n| - puts "*************SENDING SESSION_ENDED TO #{n.target_user_id}***************" msg = @@message_factory.session_ended(n.target_user_id, session_id) @@mq_router.publish_to_user(n.target_user_id, msg) end From b2718de7cf38ce6cc30ca3123d032f6abd52d6b2 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 23 Feb 2014 21:05:31 -0500 Subject: [PATCH 2/7] VRFS-1223 allow unauthenticated users to view hover bubbles but hide action buttons --- web/app/assets/javascripts/hoverBand.js | 7 +++++++ web/app/assets/javascripts/hoverFan.js | 8 ++++++++ web/app/assets/javascripts/hoverMusician.js | 8 ++++++++ web/app/assets/javascripts/hoverRecording.js | 8 ++++++++ web/app/assets/javascripts/hoverSession.js | 8 ++++++++ web/app/controllers/api_users_controller.rb | 2 +- 6 files changed, 40 insertions(+), 1 deletion(-) diff --git a/web/app/assets/javascripts/hoverBand.js b/web/app/assets/javascripts/hoverBand.js index fc6ca414c..f1324b217 100644 --- a/web/app/assets/javascripts/hoverBand.js +++ b/web/app/assets/javascripts/hoverBand.js @@ -63,6 +63,7 @@ }); $(hoverSelector).append('

Band Detail

' + bandHtml); + toggleActionButtons(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -77,6 +78,12 @@ }); }; + function toggleActionButtons() { + if (!context.JK.currentUserId) { + $("#btnFollow", hoverSelector).hide(); + } + } + this.hideBubble = function() { $(hoverSelector).hide(); }; diff --git a/web/app/assets/javascripts/hoverFan.js b/web/app/assets/javascripts/hoverFan.js index b23342180..8e5d0b367 100644 --- a/web/app/assets/javascripts/hoverFan.js +++ b/web/app/assets/javascripts/hoverFan.js @@ -62,6 +62,7 @@ }); $(hoverSelector).append('

Fan Detail

' + fanHtml); + toggleActionButtons(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -76,6 +77,13 @@ }); }; + function toggleActionButtons() { + if (!context.JK.currentUserId) { + $("#btnFriend", hoverSelector).hide(); + $("#btnFollow", hoverSelector).hide(); + } + } + this.hideBubble = function() { $(hoverSelector).hide(); }; diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index 5a1e6d427..d73226fde 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -81,6 +81,7 @@ }); $(hoverSelector).append('

Musician Detail

' + musicianHtml); + toggleActionButtons(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -95,6 +96,13 @@ }); }; + function toggleActionButtons() { + if (!context.JK.currentUserId) { + $("#btnFriend", hoverSelector).hide(); + $("#btnFollow", hoverSelector).hide(); + } + } + this.hideBubble = function() { $(hoverSelector).hide(); }; diff --git a/web/app/assets/javascripts/hoverRecording.js b/web/app/assets/javascripts/hoverRecording.js index a3c43508a..e6fe325f3 100644 --- a/web/app/assets/javascripts/hoverRecording.js +++ b/web/app/assets/javascripts/hoverRecording.js @@ -55,6 +55,7 @@ }); $(hoverSelector).append('

Recording Detail

' + recordingHtml); + toggleActionButtons(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -69,6 +70,13 @@ }); }; + function toggleActionButtons() { + if (!context.JK.currentUserId) { + $("#btnLike", hoverSelector).hide(); + $("#btnShare", hoverSelector).hide(); + } + } + this.hideBubble = function() { $(hoverSelector).hide(); }; diff --git a/web/app/assets/javascripts/hoverSession.js b/web/app/assets/javascripts/hoverSession.js index 055d8cf17..373bd0cc6 100644 --- a/web/app/assets/javascripts/hoverSession.js +++ b/web/app/assets/javascripts/hoverSession.js @@ -50,6 +50,7 @@ }); $(hoverSelector).append('

Session Detail

' + sessionHtml); + toggleActionButtons(); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -64,6 +65,13 @@ }); }; + function toggleActionButtons() { + if (!context.JK.currentUserId) { + $("#btnLike", hoverSelector).hide(); + $("#btnShare", hoverSelector).hide(); + } + } + this.hideBubble = function() { $(hoverSelector).hide(); }; diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 9227ceb93..23b32f885 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -1,6 +1,6 @@ class ApiUsersController < ApiController - before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring] + before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring] before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete, :liking_create, :liking_destroy, # likes :following_create, :following_show, :following_destroy, # followings From 1e75e2ffeb14b57fd953cb67e250d88ac95e45e8 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sun, 23 Feb 2014 22:57:24 -0500 Subject: [PATCH 3/7] fix play button issue --- web/app/assets/stylesheets/web/recordings.css.scss | 4 ++++ web/app/assets/stylesheets/web/sessions.css.scss | 6 +++++- web/app/views/music_sessions/show.html.erb | 2 +- web/app/views/recordings/show.html.erb | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/app/assets/stylesheets/web/recordings.css.scss b/web/app/assets/stylesheets/web/recordings.css.scss index 2e3ac9e24..4bd55f50e 100644 --- a/web/app/assets/stylesheets/web/recordings.css.scss +++ b/web/app/assets/stylesheets/web/recordings.css.scss @@ -55,4 +55,8 @@ position:absolute; top:3px; right:4px; +} + +#btnPlayPause { + position: relative; } \ No newline at end of file diff --git a/web/app/assets/stylesheets/web/sessions.css.scss b/web/app/assets/stylesheets/web/sessions.css.scss index 1e790e03a..ef513c304 100644 --- a/web/app/assets/stylesheets/web/sessions.css.scss +++ b/web/app/assets/stylesheets/web/sessions.css.scss @@ -16,4 +16,8 @@ font-size:15px; color:#cccc00; margin-left:20px; -}*/ \ No newline at end of file +}*/ + +#btnPlayPause { + position: relative; +} \ No newline at end of file diff --git a/web/app/views/music_sessions/show.html.erb b/web/app/views/music_sessions/show.html.erb index bcd627b73..a662c1c8e 100644 --- a/web/app/views/music_sessions/show.html.erb +++ b/web/app/views/music_sessions/show.html.erb @@ -53,7 +53,7 @@
<% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %> - + <%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %> <% end %> diff --git a/web/app/views/recordings/show.html.erb b/web/app/views/recordings/show.html.erb index cec8f1caa..229d6d275 100644 --- a/web/app/views/recordings/show.html.erb +++ b/web/app/views/recordings/show.html.erb @@ -52,7 +52,7 @@
<% if @claimed_recording.has_mix? %> - + <%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %> <% end %> From ccee2e15b3b3719a01e745805fa2c75d2eb58fdc Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Mon, 24 Feb 2014 01:10:09 -0500 Subject: [PATCH 4/7] VRFS-1210 VRFS-1212 VRFS-1223 bug fixes --- web/app/assets/javascripts/bandProfile.js | 76 +++++++++---------- web/app/assets/javascripts/hoverBand.js | 38 ++++++---- web/app/assets/javascripts/hoverFan.js | 32 ++++++-- web/app/assets/javascripts/hoverMusician.js | 27 +++++-- web/app/assets/javascripts/jam_rest.js | 8 +- web/app/assets/javascripts/profile.js | 11 +-- web/app/assets/javascripts/searchResults.js | 16 ++-- web/app/controllers/api_users_controller.rb | 4 +- web/app/views/api_search/index.rabl | 12 +++ web/app/views/clients/_hoverBand.html.erb | 53 +++++++++---- web/app/views/clients/_hoverFan.html.erb | 57 +++++++++++--- web/app/views/clients/_hoverMusician.html.erb | 74 +++++++++++++----- web/app/views/music_sessions/show.html.erb | 2 +- web/config/routes.rb | 4 +- web/spec/requests/users_api_spec.rb | 4 +- 15 files changed, 286 insertions(+), 132 deletions(-) diff --git a/web/app/assets/javascripts/bandProfile.js b/web/app/assets/javascripts/bandProfile.js index 20ff38afc..7027661ea 100644 --- a/web/app/assets/javascripts/bandProfile.js +++ b/web/app/assets/javascripts/bandProfile.js @@ -47,55 +47,53 @@ /****************** MAIN PORTION OF SCREEN *****************/ function addFollowing(isBand, id) { - var newFollowing = {}; + var newFollowing = {}; - if (!isBand) { - newFollowing.user_id = id; - } - else { - newFollowing.band_id = id; - } + if (!isBand) { + newFollowing.user_id = id; + } + else { + newFollowing.band_id = id; + } - rest.addFollowing(newFollowing) - .done(function() { - if (isBand) { - var newCount = parseInt($("#band-profile-follower-stats").text()) + 1; - var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; - $('#band-profile-follower-stats').html(newCount + text); - configureBandFollowingButton(true); - } - else { - configureMemberFollowingButton(true, id); - } - }) - .fail(app.ajaxError); + rest.addFollowing(newFollowing) + .done(function() { + if (isBand) { + var newCount = parseInt($("#band-profile-follower-stats").text()) + 1; + var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; + $('#band-profile-follower-stats').html(newCount + text); + configureBandFollowingButton(true); + } + else { + configureMemberFollowingButton(true, id); + } + renderActive(); + }) + .fail(app.ajaxError); } function removeFollowing(isBand, id) { - var following = {}; - following.target_entity_id = id; - - rest.removeFollowing(following) - .done(function() { - renderActive(); // refresh stats - if (isBand) { - var newCount = parseInt($("#band-profile-follower-stats").text()) - 1; - var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; - $('#band-profile-follower-stats').html(newCount + text); - configureBandFollowingButton(false); - } - else { - configureMemberFollowingButton(false, id); - } - }) - .fail(app.ajaxError); + rest.removeFollowing(id) + .done(function() { + if (isBand) { + var newCount = parseInt($("#band-profile-follower-stats").text()) - 1; + var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower"; + $('#band-profile-follower-stats').html(newCount + text); + configureBandFollowingButton(false); + } + else { + configureMemberFollowingButton(false, id); + } + renderActive(); + }) + .fail(app.ajaxError); } function configureBandFollowingButton(following) { $('#btn-follow-band').unbind("click"); if (following) { - $('#btn-follow-band').text('STOP FOLLOWING'); + $('#btn-follow-band').text('UNFOLLOW'); $('#btn-follow-band').click(function() { removeFollowing(true, bandId); return false; @@ -121,7 +119,7 @@ $btnFollowMember.unbind("click"); if (following) { - $btnFollowMember.text('UN-FOLLOW'); + $btnFollowMember.text('UNFOLLOW'); $btnFollowMember.click(function() { removeFollowing(false, userId); return false; diff --git a/web/app/assets/javascripts/hoverBand.js b/web/app/assets/javascripts/hoverBand.js index f1324b217..2b98e8e62 100644 --- a/web/app/assets/javascripts/hoverBand.js +++ b/web/app/assets/javascripts/hoverBand.js @@ -49,21 +49,23 @@ }); var bandHtml = context.JK.fillTemplate(template, { - avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url), - name: response.name, - location: response.location, - genres: genres.join(', '), - musicians: musicianHtml, - like_count: response.liker_count, - follower_count: response.follower_count, - recording_count: response.recording_count, - session_count: response.session_count, - biography: response.biography, - profile_url: "/client#/bandProfile/" + response.id + bandId: response.id, + avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url), + name: response.name, + location: response.location, + genres: genres.join(', '), + musicians: musicianHtml, + like_count: response.liker_count, + follower_count: response.follower_count, + recording_count: response.recording_count, + session_count: response.session_count, + biography: response.biography, + followAction: response.is_following ? "removeBandFollowing" : "addBandFollowing", + profile_url: "/client#/bandProfile/" + response.id }); $(hoverSelector).append('

Band Detail

' + bandHtml); - toggleActionButtons(); + configureActionButtons(response); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -78,9 +80,17 @@ }); }; - function toggleActionButtons() { + function configureActionButtons(band) { + var btnFollowSelector = "#btnFollow"; + + // if unauthenticated or authenticated user is viewing his own profile if (!context.JK.currentUserId) { - $("#btnFollow", hoverSelector).hide(); + $(btnFollowSelector, hoverSelector).hide(); + } + else { + if (band.is_following) { + $(btnFollowSelector, hoverSelector).html('UNFOLLOW'); + } } } diff --git a/web/app/assets/javascripts/hoverFan.js b/web/app/assets/javascripts/hoverFan.js index 8e5d0b367..44d6ba075 100644 --- a/web/app/assets/javascripts/hoverFan.js +++ b/web/app/assets/javascripts/hoverFan.js @@ -56,13 +56,15 @@ location: response.location, friend_count: response.friend_count, follower_count: response.follower_count, + friendAction: response.is_friend ? "removeFanFriend" : (response.pending_friend_request ? "" : "sendFanFriendRequest"), + followAction: response.is_following ? "removeFanFollowing" : "addFanFollowing", biography: response.biography, followings: response.followings && response.followings.length > 0 ? followingHtml : "N/A", profile_url: "/client#/profile/" + response.id }); $(hoverSelector).append('

Fan Detail

' + fanHtml); - toggleActionButtons(); + configureActionButtons(response); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -77,10 +79,30 @@ }); }; - function toggleActionButtons() { - if (!context.JK.currentUserId) { - $("#btnFriend", hoverSelector).hide(); - $("#btnFollow", hoverSelector).hide(); + function configureActionButtons(user) { + var btnFriendSelector = "#btnFriend"; + var btnFollowSelector = "#btnFollow"; + + if (!context.JK.currentUserId || context.JK.currentUserId === user.id) { + $(btnFriendSelector, hoverSelector).hide(); + $(btnFollowSelector, hoverSelector).hide(); + } + else { + if (user.is_friend) { + $(btnFriendSelector, hoverSelector).html('DISCONNECT'); + } + + if (user.is_following) { + $(btnFollowSelector, hoverSelector).html('UNFOLLOW'); + + $(btnFollowSelector, hoverSelector).click(function(evt) { + rest.removeFollowing(user.id); + }); + } + + if (user.pending_friend_request) { + $(btnFriendSelector, hoverSelector).hide(); + } } } diff --git a/web/app/assets/javascripts/hoverMusician.js b/web/app/assets/javascripts/hoverMusician.js index d73226fde..449e12380 100644 --- a/web/app/assets/javascripts/hoverMusician.js +++ b/web/app/assets/javascripts/hoverMusician.js @@ -75,13 +75,15 @@ session_count: response.session_count, session_display: sessionDisplayStyle, session_id: sessionId, + friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"), + followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing", biography: response.biography, followings: response.followings && response.followings.length > 0 ? followingHtml : "N/A", profile_url: "/client#/profile/" + response.id }); $(hoverSelector).append('

Musician Detail

' + musicianHtml); - toggleActionButtons(); + configureActionButtons(response); }) .fail(function(xhr) { if(xhr.status >= 500) { @@ -96,10 +98,25 @@ }); }; - function toggleActionButtons() { - if (!context.JK.currentUserId) { - $("#btnFriend", hoverSelector).hide(); - $("#btnFollow", hoverSelector).hide(); + function configureActionButtons(user) { + var btnFriendSelector = "#btnFriend"; + var btnFollowSelector = "#btnFollow"; + + // if unauthenticated or authenticated user is viewing his own profile + if (!context.JK.currentUserId || context.JK.currentUserId === user.id) { + $(btnFriendSelector, hoverSelector).hide(); + $(btnFollowSelector, hoverSelector).hide(); + } + else { + if (user.is_friend) { + $(btnFriendSelector, hoverSelector).html('DISCONNECT'); + } + if (user.is_following) { + $(btnFollowSelector, hoverSelector).html('UNFOLLOW'); + } + if (user.pending_friend_request) { + $(btnFriendSelector, hoverSelector).hide(); + } } } diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 92fe43939..4363a11d8 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -451,7 +451,7 @@ }); } - function removeLike(options) { + function removeLike(likableId, options) { var id = getId(options); return $.ajax({ type: "DELETE", @@ -476,15 +476,13 @@ }); } - function removeFollowing(options) { + function removeFollowing(followableId, options) { var id = getId(options); - return $.ajax({ type: "DELETE", dataType: "json", contentType: 'application/json', - url: "/api/users/" + id + "/followings", - data: JSON.stringify(options), + url: "/api/users/" + id + "/followings/" + followableId, processData: false }); } diff --git a/web/app/assets/javascripts/profile.js b/web/app/assets/javascripts/profile.js index ff15ff574..2b5a9d509 100644 --- a/web/app/assets/javascripts/profile.js +++ b/web/app/assets/javascripts/profile.js @@ -193,10 +193,10 @@ function configureFriendButton() { if (isFriend()) { - $('#btn-add-friend').text('REMOVE FRIEND'); + $('#btn-add-friend').text('DISCONNECT'); } else { - $('#btn-add-friend').text('ADD FRIEND'); + $('#btn-add-friend').text('CONNECT'); } } @@ -213,10 +213,7 @@ } function removeFollowing(isBand, id) { - var following = {}; - following.target_entity_id = id; - - rest.removeFollowing(following) + rest.removeFollowing(id) .done(function() { if (!isBand) { updateFollowingCount(-1); @@ -242,7 +239,7 @@ function configureFollowingButton() { if (isFollowing()) { - $('#btn-follow-user').text('STOP FOLLOWING'); + $('#btn-follow-user').text('UNFOLLOW'); } else { $('#btn-follow-user').text('FOLLOW'); diff --git a/web/app/assets/javascripts/searchResults.js b/web/app/assets/javascripts/searchResults.js index 884c2dbda..2f32a697d 100644 --- a/web/app/assets/javascripts/searchResults.js +++ b/web/app/assets/javascripts/searchResults.js @@ -117,23 +117,23 @@ selector = isSidebar ? '#sidebar-search-results' : '#search-results'; $(selector).append(invitationSentHtml); - // wire up button click handler if search result is not a friend or the current use + // wire up button click handler if search result is not a friend or the current user if (isSidebar) { var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']'); - if (!val.is_friend && val.id !== context.JK.currentUserId) { - $sidebar.find('.btn-connect-friend').click(sendFriendRequest); + if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) { + // hide the button if the search result is already a friend + $sidebar.find('.btn-connect-friend').hide(); } else { - // hide the button if the search result is already a friend - $sidebar.find('.btn-connect-friend').hide(); + $sidebar.find('.btn-connect-friend').click(sendFriendRequest); } } else { - if (!val.is_friend && val.id !== context.JK.currentUserId) { - $('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest); + if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) { + $('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide(); } else { - $('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide(); + $('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest); } } resultDivVisibility(val, isSidebar); diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index 23b32f885..697bc2c95 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -202,7 +202,7 @@ class ApiUsersController < ApiController end def liking_destroy - User.delete_liking(params[:id], params[:target_entity_id]) + User.delete_liking(params[:id], params[:likable_id]) respond_with responder: ApiResponder, :status => 204 end @@ -230,7 +230,7 @@ class ApiUsersController < ApiController end def following_destroy - User.delete_following(params[:id], params[:target_entity_id]) + User.delete_following(params[:id], params[:followable_id]) respond_with responder: ApiResponder, :status => 204 end diff --git a/web/app/views/api_search/index.rabl b/web/app/views/api_search/index.rabl index 8164c4549..b6a902199 100644 --- a/web/app/views/api_search/index.rabl +++ b/web/app/views/api_search/index.rabl @@ -23,6 +23,10 @@ if @search.musicians_text_search? musician.friends?(current_user) end + node :pending_friend_request do |musician| + musician.pending_friend_request?(current_user) + end + child :musician_instruments => :instruments do attributes :instrument_id, :description, :proficiency_level, :priority end @@ -50,6 +54,10 @@ if @search.musicians_filter_search? @search.is_follower?(musician) end + node :pending_friend_request do |musician| + @search.pending_friend_request?(musician) + end + node :biography do |musician| musician.biography.nil? ? "" : musician.biography end @@ -112,6 +120,10 @@ if @search.fans_text_search? node :is_friend do |fan| fan.friends?(current_user) end + + node :pending_friend_request do |musician| + @search.pending_friend_request?(musician) + end } end diff --git a/web/app/views/clients/_hoverBand.html.erb b/web/app/views/clients/_hoverBand.html.erb index ee8f0c5ff..7ee0fe2c2 100644 --- a/web/app/views/clients/_hoverBand.html.erb +++ b/web/app/views/clients/_hoverBand.html.erb @@ -5,25 +5,49 @@ @@ -54,9 +92,9 @@


diff --git a/web/app/views/music_sessions/show.html.erb b/web/app/views/music_sessions/show.html.erb index a662c1c8e..12705cbee 100644 --- a/web/app/views/music_sessions/show.html.erb +++ b/web/app/views/music_sessions/show.html.erb @@ -53,7 +53,7 @@
<% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %> - + <%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %> <% end %> diff --git a/web/config/routes.rb b/web/config/routes.rb index 3fa2edf92..79286139c 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -161,7 +161,7 @@ SampleApp::Application.routes.draw do # user likes match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index' match '/users/:id/likings' => 'api_users#liking_create', :via => :post - match '/users/:id/likings' => 'api_users#liking_destroy', :via => :delete + match '/users/:id/likings/:likable_id' => 'api_users#liking_destroy', :via => :delete # user followers match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index' @@ -169,7 +169,7 @@ SampleApp::Application.routes.draw do # user followings match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index' match '/users/:id/followings' => 'api_users#following_create', :via => :post - match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete + match '/users/:id/followings/:followable_id' => 'api_users#following_destroy', :via => :delete # favorites match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index' diff --git a/web/spec/requests/users_api_spec.rb b/web/spec/requests/users_api_spec.rb index 80d8bd5a8..6e3df944a 100644 --- a/web/spec/requests/users_api_spec.rb +++ b/web/spec/requests/users_api_spec.rb @@ -56,7 +56,7 @@ describe "User API", :type => :api do def delete_user_like(authenticated_user, source_user, target_user) login(authenticated_user.email, authenticated_user.password, 200, true) - delete "/api/users/#{source_user.id}/likings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json' + delete "/api/users/#{source_user.id}/likings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json' return last_response end @@ -99,7 +99,7 @@ describe "User API", :type => :api do def delete_user_following(authenticated_user, source_user, target_user) login(authenticated_user.email, authenticated_user.password, 200, true) - delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json' + delete "/api/users/#{source_user.id}/followings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json' return last_response end From 0522c20e608ed74efea379be10834c1920000f77 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 24 Feb 2014 16:55:56 +0000 Subject: [PATCH 5/7] * VRFS-1100 - can only download 100 times before 404 given for client downloads, VRFS-862 - quick change to unblock --- db/manifest | 1 + db/up/track_download_counts.sql | 5 ++ ruby/lib/jam_ruby/models/claimed_recording.rb | 2 +- ruby/lib/jam_ruby/models/mix.rb | 16 +++++- ruby/lib/jam_ruby/models/recorded_track.rb | 14 +++++ ruby/spec/factories.rb | 20 ++++++- ruby/spec/jam_ruby/models/mix_spec.rb | 10 ++++ ruby/spec/spec_helper.rb | 3 ++ ruby/spec/support/utilities.rb | 4 ++ web/app/assets/javascripts/ftue.js | 2 +- web/app/assets/javascripts/shareDialog.js | 7 --- web/app/controllers/api_controller.rb | 3 +- web/app/controllers/api_mixes_controller.rb | 13 ++++- .../controllers/api_recordings_controller.rb | 13 ++++- web/app/views/api_mixes/download.rabl | 1 + web/app/views/layouts/web.erb | 1 - web/config/application.rb | 4 +- ...spec.rb => api_claimed_recordings_spec.rb} | 0 ...ec.rb => api_corporate_controller_spec.rb} | 1 - .../controllers/api_mixes_controller_spec.rb | 53 +++++++++++++++++++ ...c.rb => api_recordings_controller_spec.rb} | 48 +++++++++++++++++ web/spec/factories.rb | 19 +++++++ web/spec/features/recordings_spec.rb | 4 +- web/spec/spec_helper.rb | 10 ++-- 24 files changed, 228 insertions(+), 26 deletions(-) create mode 100644 db/up/track_download_counts.sql create mode 100644 web/app/views/api_mixes/download.rabl rename web/spec/controllers/{claimed_recordings_spec.rb => api_claimed_recordings_spec.rb} (100%) rename web/spec/controllers/{corporate_controller_spec.rb => api_corporate_controller_spec.rb} (96%) create mode 100644 web/spec/controllers/api_mixes_controller_spec.rb rename web/spec/controllers/{recordings_controller_spec.rb => api_recordings_controller_spec.rb} (70%) diff --git a/db/manifest b/db/manifest index 00a8e8bb2..2741cfc1a 100755 --- a/db/manifest +++ b/db/manifest @@ -121,3 +121,4 @@ scores_mod_connections.sql scores_create_schemas_and_extensions.sql scores_create_tables.sql remove_is_downloadable.sql +track_download_counts.sql \ No newline at end of file diff --git a/db/up/track_download_counts.sql b/db/up/track_download_counts.sql new file mode 100644 index 000000000..f08d001a9 --- /dev/null +++ b/db/up/track_download_counts.sql @@ -0,0 +1,5 @@ +ALTER TABLE recorded_tracks ADD COLUMN download_count INTEGER NOT NULL DEFAULT 0; +ALTER TABLE recorded_tracks ADD COLUMN last_downloaded_at TIMESTAMP; + +ALTER TABLE mixes ADD COLUMN download_count INTEGER NOT NULL DEFAULT 0; +ALTER TABLE mixes ADD COLUMN last_downloaded_at TIMESTAMP; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/claimed_recording.rb b/ruby/lib/jam_ruby/models/claimed_recording.rb index e7f8fbc4b..607eb053c 100644 --- a/ruby/lib/jam_ruby/models/claimed_recording.rb +++ b/ruby/lib/jam_ruby/models/claimed_recording.rb @@ -20,6 +20,7 @@ module JamRuby validates_uniqueness_of :user_id, :scope => :recording_id validate :user_belongs_to_recording + before_create :generate_share_token SHARE_TOKEN_LENGTH = 8 @@ -67,7 +68,6 @@ module JamRuby !ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording_id).nil? end - def remove_non_alpha_num(token) token.gsub(/[^0-9A-Za-z]/, '') end diff --git a/ruby/lib/jam_ruby/models/mix.rb b/ruby/lib/jam_ruby/models/mix.rb index 216145a2e..0d2282b0c 100644 --- a/ruby/lib/jam_ruby/models/mix.rb +++ b/ruby/lib/jam_ruby/models/mix.rb @@ -10,14 +10,24 @@ module JamRuby attr_accessible :ogg_url, :should_retry, as: :admin attr_accessor :is_skip_mount_uploader + attr_writer :current_user belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :mixes, :foreign_key => 'recording_id' + validates :download_count, presence: true + validate :verify_download_count + skip_callback :save, :before, :store_picture!, if: :is_skip_mount_uploader mount_uploader :ogg_url, MixUploader + def verify_download_count + if (self.download_count < 0 || self.download_count > APP_CONFIG.max_audio_downloads) && !@current_user.admin + errors.add(:download_count, "must be less than or equal to 100") + end + end + before_validation do # this should be an activeadmin only path, because it's using the mount_uploader (whereas the client does something completely different) if !is_skip_mount_uploader && ogg_url.present? && ogg_url.respond_to?(:file) && ogg_url_changed? @@ -67,7 +77,6 @@ module JamRuby !ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording_id).nil? end - def errored(reason, detail) self.error_reason = reason self.error_detail = detail @@ -148,6 +157,11 @@ module JamRuby Mix.construct_filename(self.created_at, self.recording_id, self.id, type) end + def update_download_count(count=1) + self.download_count = self.download_count + count + self.last_downloaded_at = Time.now + end + private def delete_s3_files diff --git a/ruby/lib/jam_ruby/models/recorded_track.rb b/ruby/lib/jam_ruby/models/recorded_track.rb index 21e15cf6e..0dc498996 100644 --- a/ruby/lib/jam_ruby/models/recorded_track.rb +++ b/ruby/lib/jam_ruby/models/recorded_track.rb @@ -12,6 +12,7 @@ module JamRuby attr_writer :is_skip_mount_uploader attr_accessible :discard, :user, :user_id, :instrument_id, :sound, :client_id, :track_id, :client_track_id, :url, as: :admin + attr_writer :current_user SOUND = %w(mono stereo) MAX_PART_FAILURES = 3 @@ -31,11 +32,13 @@ module JamRuby validates :length, length: {minimum: 1, maximum: 1024 * 1024 * 256 }, if: :upload_starting? # 256 megs max. is this reasonable? surely... validates :user, presence: true validates :instrument, presence: true + validates :download_count, presence: true before_destroy :delete_s3_files validate :validate_fully_uploaded validate :validate_part_complete validate :validate_too_many_upload_failures + validate :verify_download_count before_save :sanitize_active_admin skip_callback :save, :before, :store_picture!, if: :is_skip_mount_uploader? @@ -97,6 +100,12 @@ module JamRuby end end + def verify_download_count + if (self.download_count < 0 || self.download_count > APP_CONFIG.max_audio_downloads) && !@current_user.admin + errors.add(:download_count, "must be less than or equal to 100") + end + end + def sanitize_active_admin self.user_id = nil if self.user_id == '' end @@ -187,6 +196,11 @@ module JamRuby RecordedTrack.construct_filename(self.created_at, self.recording.id, self.client_track_id) end + def update_download_count(count=1) + self.download_count = self.download_count + count + self.last_downloaded_at = Time.now + end + private def delete_s3_files diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 69bb70a09..a0a6cdbfd 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -171,10 +171,28 @@ FactoryGirl.define do association :user, factory: :user before(:create) { |claimed_recording| - claimed_recording.recording = FactoryGirl.create(:recording_with_track, owner: claimed_recording.user) unless claimed_recording.recording } + + end + + factory :mix, :class => JamRuby::Mix do + started_at Time.now + completed_at Time.now + ogg_md5 'abc' + ogg_length 1 + sequence(:ogg_url) { |n| "recordings/ogg/#{n}" } + mp3_md5 'abc' + mp3_length 1 + sequence(:mp3_url) { |n| "recordings/mp3/#{n}" } + completed true + + before(:create) {|mix| + user = FactoryGirl.create(:user) + mix.recording = FactoryGirl.create(:recording_with_track, owner: user) + mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording) + } end factory :musician_instrument, :class => JamRuby::MusicianInstrument do diff --git a/ruby/spec/jam_ruby/models/mix_spec.rb b/ruby/spec/jam_ruby/models/mix_spec.rb index 150b305e8..7296140a1 100755 --- a/ruby/spec/jam_ruby/models/mix_spec.rb +++ b/ruby/spec/jam_ruby/models/mix_spec.rb @@ -63,6 +63,16 @@ describe Mix do recordings.length.should == 0 end + + describe "download count" do + it "will fail if too high" do + mix = FactoryGirl.create(:mix) + mix.current_user = mix.recording.owner + mix.update_download_count(APP_CONFIG.max_audio_downloads + 1) + mix.save + mix.errors[:download_count].should == ["must be less than or equal to 100"] + end + end end diff --git a/ruby/spec/spec_helper.rb b/ruby/spec/spec_helper.rb index 60f32513b..f1df45da8 100644 --- a/ruby/spec/spec_helper.rb +++ b/ruby/spec/spec_helper.rb @@ -13,6 +13,9 @@ SpecDb::recreate_database # initialize ActiveRecord's db connection ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"]) +# so jam_ruby models that use APP_CONFIG in metadata will load. this is later stubbed pre test run +APP_CONFIG = app_config + require 'jam_ruby' require 'factory_girl' require 'rubygems' diff --git a/ruby/spec/support/utilities.rb b/ruby/spec/support/utilities.rb index ef2e28292..ab6c023f3 100644 --- a/ruby/spec/support/utilities.rb +++ b/ruby/spec/support/utilities.rb @@ -101,6 +101,10 @@ def app_config '315576000' end + def max_audio_downloads + 100 + end + private def audiomixer_workspace_path diff --git a/web/app/assets/javascripts/ftue.js b/web/app/assets/javascripts/ftue.js index 2823888ef..e51581602 100644 --- a/web/app/assets/javascripts/ftue.js +++ b/web/app/assets/javascripts/ftue.js @@ -487,7 +487,7 @@ * Load available drivers and populate the driver select box. */ function loadAudioDrivers() { - var drivers = jamClient.FTUEGetDevices(); + var drivers = jamClient.FTUEGetDevices(false); var driverOptionFunc = function (driverKey, index, list) { optionsHtml += '
<%= render "clients/invitationDialog" %> - <%= render "clients/shareDialog" %> <%= render "users/signupDialog" %> <%= render "users/signinDialog" %> <%= render "users/videoDialog" %> diff --git a/web/config/application.rb b/web/config/application.rb index 24aef184f..71a3114be 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -204,6 +204,8 @@ if defined?(Bundler) config.twitter_app_id = ENV['TWITTER_APP_ID'] || 'nQj2oEeoJZxECC33tiTuIg' config.twitter_app_secret = ENV['TWITTER_APP_SECRET'] || 'Azcy3QqfzYzn2fsojFPYXcn72yfwa0vG6wWDrZ3KT8' - config.autocheck_create_session_agreement = false; + config.autocheck_create_session_agreement = false + + config.max_audio_downloads = 100 end end diff --git a/web/spec/controllers/claimed_recordings_spec.rb b/web/spec/controllers/api_claimed_recordings_spec.rb similarity index 100% rename from web/spec/controllers/claimed_recordings_spec.rb rename to web/spec/controllers/api_claimed_recordings_spec.rb diff --git a/web/spec/controllers/corporate_controller_spec.rb b/web/spec/controllers/api_corporate_controller_spec.rb similarity index 96% rename from web/spec/controllers/corporate_controller_spec.rb rename to web/spec/controllers/api_corporate_controller_spec.rb index aa44fdab1..cfbe7f5fd 100644 --- a/web/spec/controllers/corporate_controller_spec.rb +++ b/web/spec/controllers/api_corporate_controller_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' describe ApiCorporateController do render_views - before(:each) do CorpMailer.deliveries.clear end diff --git a/web/spec/controllers/api_mixes_controller_spec.rb b/web/spec/controllers/api_mixes_controller_spec.rb new file mode 100644 index 000000000..ff420732a --- /dev/null +++ b/web/spec/controllers/api_mixes_controller_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe ApiMixesController do + render_views + + let(:mix) { FactoryGirl.create(:mix) } + + before(:each) do + controller.current_user = nil + end + + describe "download" do + + it "is possible" do + controller.current_user = mix.recording.owner + get :download, {id: mix.id} + response.status.should == 302 + + mix.reload + mix.download_count.should == 1 + + get :download, {id: mix.id} + response.status.should == 302 + + mix.reload + mix.download_count.should == 2 + end + + + it "prevents download after limit is reached" do + mix.download_count = APP_CONFIG.max_audio_downloads + mix.save! + controller.current_user = mix.recording.owner + get :download, {format:'json', id: mix.id} + response.status.should == 404 + JSON.parse(response.body, symbolize_names: true)[:message].should == "download limit surpassed" + end + + + it "lets admins surpass limit" do + mix.download_count = APP_CONFIG.max_audio_downloads + mix.save! + mix.recording.owner.admin = true + mix.recording.owner.save! + + controller.current_user = mix.recording.owner + get :download, {format:'json', id: mix.id} + response.status.should == 302 + mix.reload + mix.download_count.should == 101 + end + end +end diff --git a/web/spec/controllers/recordings_controller_spec.rb b/web/spec/controllers/api_recordings_controller_spec.rb similarity index 70% rename from web/spec/controllers/recordings_controller_spec.rb rename to web/spec/controllers/api_recordings_controller_spec.rb index 02858f128..c3be0c9ca 100644 --- a/web/spec/controllers/recordings_controller_spec.rb +++ b/web/spec/controllers/api_recordings_controller_spec.rb @@ -101,6 +101,8 @@ describe ApiRecordingsController do end describe "download" do + let(:mix) { FactoryGirl.create(:mix) } + it "should only allow a user to download a track if they have claimed the recording" do post :start, { :format => 'json', :music_session_id => @music_session.id } response_body = JSON.parse(response.body) @@ -108,5 +110,51 @@ describe ApiRecordingsController do post :stop, { :format => 'json', :id => recording.id } response.should be_success end + + + it "is possible" do + mix.touch + recorded_track = mix.recording.recorded_tracks[0] + controller.current_user = mix.recording.owner + get :download, {id: recorded_track.recording.id, track_id: recorded_track.client_track_id} + response.status.should == 302 + + recorded_track.reload + recorded_track.download_count.should == 1 + + get :download, {id: recorded_track.recording.id, track_id: recorded_track.client_track_id} + response.status.should == 302 + + recorded_track.reload + recorded_track.download_count.should == 2 + end + + + it "prevents download after limit is reached" do + mix.touch + recorded_track = mix.recording.recorded_tracks[0] + recorded_track.download_count = APP_CONFIG.max_audio_downloads + recorded_track.save! + controller.current_user = recorded_track.user + get :download, {format:'json', id: recorded_track.recording.id, track_id: recorded_track.client_track_id} + response.status.should == 404 + JSON.parse(response.body, symbolize_names: true)[:message].should == "download limit surpassed" + end + + + it "lets admins surpass limit" do + mix.touch + recorded_track = mix.recording.recorded_tracks[0] + recorded_track.download_count = APP_CONFIG.max_audio_downloads + recorded_track.save! + recorded_track.user.admin = true + recorded_track.user.save! + + controller.current_user = recorded_track.user + get :download, {format:'json', id: recorded_track.recording.id, track_id: recorded_track.client_track_id} + response.status.should == 302 + recorded_track.reload + recorded_track.download_count.should == 101 + end end end diff --git a/web/spec/factories.rb b/web/spec/factories.rb index 3e83166a6..78839e8a0 100644 --- a/web/spec/factories.rb +++ b/web/spec/factories.rb @@ -374,4 +374,23 @@ FactoryGirl.define do factory :music_session_like, :class => JamRuby::MusicSessionLiker do end + + + factory :mix, :class => JamRuby::Mix do + started_at Time.now + completed_at Time.now + ogg_md5 'abc' + ogg_length 1 + sequence(:ogg_url) { |n| "recordings/ogg/#{n}" } + mp3_md5 'abc' + mp3_length 1 + sequence(:mp3_url) { |n| "recordings/mp3/#{n}" } + completed true + + before(:create) {|mix| + user = FactoryGirl.create(:user) + mix.recording = FactoryGirl.create(:recording_with_track, owner: user) + mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording) + } + end end diff --git a/web/spec/features/recordings_spec.rb b/web/spec/features/recordings_spec.rb index 573199fbb..57416c2d6 100644 --- a/web/spec/features/recordings_spec.rb +++ b/web/spec/features/recordings_spec.rb @@ -39,7 +39,7 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature in_client(creator) do find('#session-leave').trigger(:click) - find('#btn-accept').trigger(:click) + find('#btn-accept-leave-session').trigger(:click) expect(page).to have_selector('h2', text: 'feed') end @@ -76,7 +76,7 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature in_client(creator) do find('#session-leave').trigger(:click) - find('#btn-accept').trigger(:click) + find('#btn-accept-leave-session').trigger(:click) expect(page).to have_selector('h2', text: 'feed') end diff --git a/web/spec/spec_helper.rb b/web/spec/spec_helper.rb index 298ff151a..092c564e0 100644 --- a/web/spec/spec_helper.rb +++ b/web/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'simplecov' require 'rubygems' -require 'spork' +#require 'spork' require 'omniauth' #uncomment the following line to use spork with the debugger #require 'spork/ext/ruby-debug' @@ -40,7 +40,7 @@ Thread.new { end } -Spork.prefork do +#Spork.prefork do # Loading more in this block will cause your tests to run faster. However, # if you change any configuration or code from libraries loaded here, you'll # need to restart spork for it take effect. @@ -155,12 +155,12 @@ Spork.prefork do wipe_s3_test_bucket end end -end +#end -Spork.each_run do +#Spork.each_run do # This code will be run each time you run your specs. -end +#end From 002560a332dc73f9d98b3bf1ce8fe063b01022b8 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 24 Feb 2014 18:05:29 +0000 Subject: [PATCH 6/7] * fixing pending tests --- web/app/assets/stylesheets/client/header.css.scss | 2 +- web/app/views/api_search/index.rabl | 9 +++------ web/spec/requests/music_sessions_api_spec.rb | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/web/app/assets/stylesheets/client/header.css.scss b/web/app/assets/stylesheets/client/header.css.scss index 85cf5d498..2812d087f 100644 --- a/web/app/assets/stylesheets/client/header.css.scss +++ b/web/app/assets/stylesheets/client/header.css.scss @@ -1,5 +1,5 @@ @charset "UTF-8"; -@import "compass/utilities/text/replacement"; +@import "compass/typography/text/replacement"; .header { height: 55px; diff --git a/web/app/views/api_search/index.rabl b/web/app/views/api_search/index.rabl index b6a902199..4d0dc0317 100644 --- a/web/app/views/api_search/index.rabl +++ b/web/app/views/api_search/index.rabl @@ -31,10 +31,7 @@ if @search.musicians_text_search? attributes :instrument_id, :description, :proficiency_level, :priority end } -end -if @search.musicians_filter_search? - node :city do |user| current_user.try(:location) end @@ -55,7 +52,7 @@ if @search.musicians_filter_search? end node :pending_friend_request do |musician| - @search.pending_friend_request?(musician) + musician.pending_friend_request?(musician) end node :biography do |musician| @@ -121,8 +118,8 @@ if @search.fans_text_search? fan.friends?(current_user) end - node :pending_friend_request do |musician| - @search.pending_friend_request?(musician) + node :pending_friend_request do |fan| + fan.pending_friend_request?(current_user) end } end diff --git a/web/spec/requests/music_sessions_api_spec.rb b/web/spec/requests/music_sessions_api_spec.rb index 282263d84..00e83efb3 100755 --- a/web/spec/requests/music_sessions_api_spec.rb +++ b/web/spec/requests/music_sessions_api_spec.rb @@ -524,6 +524,7 @@ describe "Music Session API ", :type => :api do # this test was created to stop duplication of tracks # but ultimately it should be fine to create a session, and then 'join' it with no ill effects # https://jamkazam.atlassian.net/browse/VRFS-254 + user.admin = true client = FactoryGirl.create(:connection, :user => user) post '/api/sessions.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(201) @@ -543,7 +544,6 @@ describe "Music Session API ", :type => :api do track["instrument_id"].should == "electric guitar" track["sound"].should == "mono" - post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json' last_response.status.should eql(201) From a90b909ac35926c4f2e6aa9a8c27726cda2e0bff Mon Sep 17 00:00:00 2001 From: Seth Call Date: Mon, 24 Feb 2014 18:54:19 +0000 Subject: [PATCH 7/7] * fixing account identity tests and search tests --- .../assets/javascripts/accounts_identity.js | 2 +- web/app/assets/javascripts/layout.js | 2 + .../views/clients/_account_identity.html.erb | 2 +- web/spec/features/account_spec.rb | 78 ++++++++++--------- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/web/app/assets/javascripts/accounts_identity.js b/web/app/assets/javascripts/accounts_identity.js index 66a1d80a6..7d7ef1019 100644 --- a/web/app/assets/javascripts/accounts_identity.js +++ b/web/app/assets/javascripts/accounts_identity.js @@ -209,7 +209,7 @@ var password_confirmation_errors = context.JK.format_errors("password_confirmation", errors) if(current_password_errors != null) { - $('#account-edit-password-form #account-forgot-password').closest('div.field').addClass('error').end().after(current_password_errors); + $('#account-edit-password-form input[name=current_password]').closest('div.field').addClass('error').end().after(current_password_errors); } if(password_errors != null) { diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index 1ed20ff15..d8d164ac5 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -500,6 +500,8 @@ var accepted = screenEvent(previousScreen, 'beforeHide', data); if(accepted === false) return; + logger.debug("Changing screen to " + currentScreen); + screenEvent(currentScreen, 'beforeShow', data); // For now -- it seems we want it open always. diff --git a/web/app/views/clients/_account_identity.html.erb b/web/app/views/clients/_account_identity.html.erb index f54f5f3d5..439ae6138 100644 --- a/web/app/views/clients/_account_identity.html.erb +++ b/web/app/views/clients/_account_identity.html.erb @@ -1,5 +1,5 @@ -
+
diff --git a/web/spec/features/account_spec.rb b/web/spec/features/account_spec.rb index c9c9d1932..d4c6d08cd 100644 --- a/web/spec/features/account_spec.rb +++ b/web/spec/features/account_spec.rb @@ -28,7 +28,7 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do end it { - should have_selector('h2', text: 'identity:' ) + find('#account-identity h2', text: 'identity:') should have_selector('form#account-edit-email-form h4', text: 'Update your email address:') should have_selector('form#account-edit-password-form h4', text: 'Update your password:') } @@ -46,7 +46,7 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do end it { - should have_selector('h1', text: 'my account'); + find('h1', text: 'my account') should have_selector('#notification h2', text: 'Confirmation Email Sent') } end @@ -68,58 +68,60 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do describe "unsuccessfully" do before(:each) do + find('#account-identity h2', text: 'identity:') find("#account-edit-password-submit").trigger(:click) end it { - should have_selector('h2', text: 'identity:') - should have_selector('div.field.error input[name=current_password] ~ ul li', text: "can't be blank") - should have_selector('div.field.error input[name=password] ~ ul li', text: "is too short (minimum is 6 characters)") - should have_selector('div.field.error input[name=password_confirmation] ~ ul li', text: "can't be blank") + find('#account-identity h2', text: 'identity:') + find('#account-identity div.field.error input[name=current_password] ~ ul li', text: "can't be blank") + find('#account-identity div.field.error input[name=password] ~ ul li', text: "is too short (minimum is 6 characters)") + find('#account-identity div.field.error input[name=password_confirmation] ~ ul li', text: "can't be blank") } end end - describe "profile" - - before(:each) do - find("#account-edit-profile-link").trigger(:click) - find('a.small', text: 'Change Avatar') - end - - describe "successfully" do + describe "profile" do before(:each) do - fill_in "first_name", with: "Bobby" - fill_in "last_name", with: "Toes" - find('input[name=subscribe_email]').set(false) - find("#account-edit-profile-submit").trigger(:click) + find("#account-edit-profile-link").trigger(:click) + find('a.small', text: 'Change Avatar') end - it { - user.subscribe_email.should be_true - should have_selector('h1', text: 'my account') - should have_selector('#notification h2', text: 'Profile Changed') - user.reload - user.subscribe_email.should be_false - user.first_name.should == "Bobby" - user.last_name.should == "Toes" - } - end + describe "successfully" do - describe "unsuccessfully" do + before(:each) do + fill_in "first_name", with: "Bobby" + fill_in "last_name", with: "Toes" + find('input[name=subscribe_email]').set(false) + find("#account-edit-profile-submit").trigger(:click) + end - before(:each) do - fill_in "first_name", with: "" - fill_in "last_name", with: "" - find("#account-edit-profile-submit").trigger(:click) + it { + user.subscribe_email.should be_true + should have_selector('h1', text: 'my account') + should have_selector('#notification h2', text: 'Profile Changed') + user.reload + user.subscribe_email.should be_false + user.first_name.should == "Bobby" + user.last_name.should == "Toes" + } end - it { - should have_selector('h2', text: 'profile:') - should have_selector('div.field.error input[name=first_name] ~ ul li', text: "can't be blank") - should have_selector('div.field.error input[name=last_name] ~ ul li', text: "can't be blank") - } + describe "unsuccessfully" do + + before(:each) do + fill_in "first_name", with: "" + fill_in "last_name", with: "" + find("#account-edit-profile-submit").trigger(:click) + end + + it { + should have_selector('h2', text: 'profile:') + should have_selector('div.field.error input[name=first_name] ~ ul li', text: "can't be blank") + should have_selector('div.field.error input[name=last_name] ~ ul li', text: "can't be blank") + } + end end end end