diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8ed230dd..edced5ab 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --auto-gen-only-exclude --exclude-limit 1000` -# on 2023-07-28 20:36:01 UTC using RuboCop version 1.55.0. +# on 2023-09-20 00:10:58 UTC using RuboCop version 1.56.3. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -13,7 +13,7 @@ Lint/EmptyBlock: - 'spec/features/playlists_spec.rb' - 'spec/models/show_spec.rb' -# Offense count: 10 +# Offense count: 9 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: Exclude: @@ -25,20 +25,20 @@ Metrics/ClassLength: Exclude: - 'app/controllers/playlists_controller.rb' -# Offense count: 4 +# Offense count: 2 # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: Exclude: - 'app/controllers/playlists_controller.rb' -# Offense count: 8 +# Offense count: 7 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: - 'app/controllers/playlists_controller.rb' - 'spec/support/feature_helpers.rb' -# Offense count: 4 +# Offense count: 2 # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/PerceivedComplexity: Exclude: diff --git a/Gemfile.lock b/Gemfile.lock index e12392ab..4eafcf11 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -301,11 +301,11 @@ GEM unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-capybara (2.18.0) + rubocop-capybara (2.19.0) rubocop (~> 1.41) - rubocop-factory_bot (2.23.1) + rubocop-factory_bot (2.24.0) rubocop (~> 1.33) - rubocop-performance (1.19.0) + rubocop-performance (1.19.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.21.1) @@ -384,7 +384,7 @@ GEM waveformjson (0.1.0) ruby-audio webrick (1.8.1) - websocket (1.2.9) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/app/assets/javascripts/classes/player.js.coffee b/app/assets/javascripts/classes/player.js.coffee index bf159803..69250531 100644 --- a/app/assets/javascripts/classes/player.js.coffee +++ b/app/assets/javascripts/classes/player.js.coffee @@ -204,7 +204,7 @@ class @Player setCurrentPlaylist: (track_id) -> $.ajax type: 'post' - url: '/reset-playlist' + url: '/override-playlist' data: { 'track_id': track_id } success: (r) => @playlist = r.playlist diff --git a/app/assets/javascripts/classes/playlist.js.coffee b/app/assets/javascripts/classes/playlist.js.coffee index 9b00d5a8..65c6fa5c 100644 --- a/app/assets/javascripts/classes/playlist.js.coffee +++ b/app/assets/javascripts/classes/playlist.js.coffee @@ -16,7 +16,7 @@ class @Playlist $('#active_playlist').sortable({ placeholder: "ui-state-highlight", update: => - this.updatePlaylist 'Track moved in playlist' + this.updatePlaylist() }) updatePlaylist: (success_msg) -> @@ -28,7 +28,7 @@ class @Playlist $(this).find('.position_num').html "#{idx+1}" ) $.ajax({ - url: '/update-current-playlist', + url: '/reposition-playlist', type: 'post', data: { 'track_ids': track_ids }, success: (r) => @@ -114,7 +114,7 @@ class @Playlist $('#playlist_title').html '(Untitled Playlist)' this._updatePlaylistStats() $('#empty_playlist_msg').show() - unless supress_feedback then @Util.feedback { notice: 'Actve Playlist is now empty' } + unless supress_feedback then @Util.feedback { notice: 'Actve playlist is now empty' } }) bookmarkPlaylist: -> @@ -144,6 +144,7 @@ class @Playlist handleSaveModal: -> if name = $('#playlist_data').attr 'data-name' @$save_action_existing.attr 'disabled', false + @$save_action_existing.attr 'selected', true @$playlist_name_input.val name @$playlist_slug_input.val $('#playlist_data').attr 'data-slug' else @@ -200,7 +201,7 @@ class @Playlist _getPlaylist: -> $.ajax({ - url: '/get-playlist', + url: '/load-playlist', success: (r) => if r.playlist && r.playlist.length > 0 $('#empty_playlist_msg').hide() diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index e5712c6f..8597b5b2 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -666,7 +666,8 @@ html { #playlist_mode_notice { display: none; position: absolute; - left: 66px; + width: 170px; + left: 756px; top: 86px; border-radius: 5px; background-color: #d0f7d0; @@ -675,6 +676,7 @@ html { font-size: 16px; text-align: center; padding: 3px; + font-weight: bold; } #logo { position: absolute; diff --git a/app/controllers/playlists_controller.rb b/app/controllers/playlists_controller.rb index 59308a19..7d0b234d 100644 --- a/app/controllers/playlists_controller.rb +++ b/app/controllers/playlists_controller.rb @@ -1,58 +1,53 @@ # frozen_string_literal: true class PlaylistsController < ApplicationController - before_action :init_session_playlist - before_action :authenticate_user!, - only: %i[save_playlist destroy_playlist bookmark_playlist unbookmark_playlist] - - def active_playlist - @num_tracks = 0 - @duration = 0 - @invalid_playlist_slug = false - - if params[:slug] - if (playlist = Playlist.where(slug: params[:slug]).first) - activate_saved_playlist(playlist) - else - @invalid_playlist_slug = true - end + EMPTY_PLAYLIST = { + tracks: [], + shuffled_tracks: [], + id: 0, + name: '', + slug: '', + user_id: 0, + username: '', + loop: false, + shuffle: false + }.freeze + + before_action :init_session + before_action :authenticate_user!, only: %i[save destroy bookmark unbookmark] + + def active + if (playlist = Playlist.find_by(slug: params[:slug])) + activate_stored(playlist) end - if session[:playlist] - tracks_by_id = - Track.where(id: session[:playlist]) - .includes(:show, track_tags: :tag) - .index_by(&:id) - @tracks = session[:playlist].map { |id| tracks_by_id[id] } - @tracks_likes = user_likes_for_tracks(@tracks) - @duration = @tracks.sum(&:duration) - end - - @saved_playlists = Playlist.where(user: current_user).order(name: :asc) if current_user + track_ids = session[:playlist][:tracks] + tracks_by_id = Track.where(id: track_ids).includes(:show, track_tags: :tag).index_by(&:id) + @tracks = track_ids.map { |id| tracks_by_id[id] } + @tracks_likes = user_likes_for_tracks(@tracks) + @duration = @tracks&.sum(&:duration) + @stored = Playlist.where(user: current_user).order(name: :asc) if current_user render layout: false if request.xhr? end - def saved_playlists + def stored + @playlists = [] + if current_user bookmarked_ids = PlaylistBookmark.where(user: current_user).map(&:playlist_id) - @playlists = + rel = case params[:filter] when 'phriends' then Playlist.where(id: bookmarked_ids) when 'mine' then Playlist.where(user: current_user) else Playlist.where('user_id = ? OR id IN (?)', current_user.id, bookmarked_ids) end - @playlists = - @playlists.includes(:user) - .order(order_by_for_saved_playlists) - .page(params[:page]) - else - @playlists = [] + @playlists = rel.includes(:user).order(order_by_for_stored_playlists).page(params[:page]) end render layout: false if request.xhr? end - def save_playlist + def save save_action = params[:save_action].in?(%w[new existing]) ? params[:save_action] : 'new' if save_action == 'new' @@ -78,7 +73,11 @@ def save_playlist render_good_playlist(playlist) end - def destroy_playlist + def load + render json: { playlist: session[:playlist][:tracks] } + end + + def destroy if current_user && params[:id] && (playlist = fetch_playlist) playlist.destroy return render json: { success: true, msg: 'Playlist deleted' } @@ -87,13 +86,9 @@ def destroy_playlist render json: { success: false, msg: 'Invalid delete request' } end - def fetch_playlist - Playlist.find_by(id: params[:id], user: current_user) - end - - def bookmark_playlist + def bookmark if current_user && params[:id].present? - if PlaylistBookmark.where(playlist_id: params[:id], user: current_user).first.present? + if PlaylistBookmark.find_by(playlist_id: params[:id], user: current_user).present? return render json: { success: false, msg: 'Playlist already bookmarked' } end @@ -104,10 +99,10 @@ def bookmark_playlist render json: { success: false, msg: "Error fetching ID #{params[:id]}" } end - def unbookmark_playlist + def unbookmark if current_user && params[:id] && - (bookmark = PlaylistBookmark.where(playlist_id: params[:id], user: current_user).first) + (bookmark = PlaylistBookmark.find_by(playlist_id: params[:id], user: current_user)) bookmark.destroy return render json: { success: true, msg: 'Playlist unbookmarked' } end @@ -115,96 +110,102 @@ def unbookmark_playlist render json: { success: false, msg: 'Playlist not bookmarked' } end - def clear_playlist - clear_saved_playlist - render json: { success: true } - end + # Force an entire show into the playlist based on a track from the show + def override + clear_session - def reset_playlist - clear_saved_playlist + session[:playlist][:tracks] = + Track.includes(:show).find_by(id: params[:track_id]).show.tracks.order(:position).pluck(:id) + shuffle_tracks - success = false - if (track = Track.where(id: params[:track_id]).first) - session[:playlist] = track.show.tracks.order(:position).map(&:id) - session[:playlist_shuffled] = session[:playlist].shuffle - success = true - end + render json: { success: true, playlist: session[:playlist][:tracks] } + end - render json: { success:, playlist: session[:playlist] } + def clear + clear_session + render json: { success: true, playlist: [] } end - def update_active_playlist - clear_saved_playlist - session[:playlist] = params[:track_ids]&.map(&:to_i)&.take(100) || [] - session[:playlist_shuffled] = session[:playlist].shuffle - render json: { success: true, msg: session[:playlist] } + def reposition + session[:playlist][:tracks] = params[:track_ids]&.map(&:to_i)&.take(100) || [] + shuffle_tracks + render json: { success: true } end - def add_track_to_playlist - if session[:playlist].include?(params[:track_id].to_i) + def add_track + if session[:playlist][:tracks].include?(params[:track_id].to_i) return render json: { success: false, msg: 'Track already in playlist' } end - if session[:playlist].size > 99 - render json: { success: false, msg: 'Playlists are limited to 100 tracks' } + if session[:playlist][:tracks].size > 99 + msg = "Playlists are limited to #{Playlist::MAX_TRACKS} tracks" + render json: { success: false, msg: } elsif (track = Track.find(params[:track_id])) - session[:playlist] << track.id - session[:playlist_shuffled].insert(rand(0..session[:playlist_shuffled].size), track.id) + session[:playlist][:tracks] << track.id + session[:playlist][:shuffled_tracks].size + num_tracks = session[:playlist][:tracks].size + session[:playlist][:shuffled_tracks].insert(rand(0..num_tracks), track.id) render json: { success: true } else render json: { success: false, msg: 'Invalid track provided for playlist' } end end - def add_show_to_playlist - clear_saved_playlist - + def add_show if (show = Show.published.find_by(id: params[:show_id])) - - session[:playlist] += show.tracks.sort_by(&:position).map(&:id) - session[:playlist] = session[:playlist].uniq.take(100) - - render json: { success: true, msg: 'Tracks added to playlist' } + session[:playlist][:tracks] += show.tracks.sort_by(&:position).map(&:id) + session[:playlist][:tracks] = session[:playlist][:tracks].uniq.take(Playlist::MAX_TRACKS) + render json: { success: true, msg: 'Tracks from show added to playlist' } else render json: { success: false, msg: 'Invalid show provided for playlist' } end end def next_track_id - session[:playlist] = params[:playlist].split(',').map(&:to_i) if params[:playlist].present? + if params[:playlist].present? + session[:playlist][:tracks] = params[:playlist].split(',').map(&:to_i) + end - return render json: { success: false, msg: 'No active playlist' } if session[:playlist].blank? + if session[:playlist][:tracks].none? + return render json: { success: false, msg: 'No active playlist' } + end - playlist_track_ids = session[:shuffle] ? session[:playlist_shuffled] : session[:playlist] + prefix = session[:playlist][:shuffle] ? 'shuffled_' : nil + track_ids = session[:playlist]["#{prefix}tracks".to_sym] - if playlist_track_ids.last == params[:track_id].to_i - if session[:loop] - render json: { success: true, track_id: playlist_track_ids.first } + if track_ids.last == params[:track_id].to_i + if session[:playlist][:loop] + render json: { success: true, track_id: track_ids.first } else render json: { success: false, msg: 'End of playlist' } end - elsif (idx = playlist_track_ids.find_index(params[:track_id].to_i)) - render json: { success: true, track_id: playlist_track_ids[idx + 1] } + elsif (idx = track_ids.find_index(params[:track_id].to_i)) + render json: { success: true, track_id: track_ids[idx + 1] } else render json: { success: false, msg: 'track_id not in playlist' } end end def previous_track_id - session[:playlist] = params[:playlist].split(',').map(&:to_i) if params[:playlist].present? + if params[:playlist].present? + session[:playlist][:tracks] = params[:playlist].split(',').map(&:to_i) + end - return render json: { success: false, msg: 'No active playlist' } if session[:playlist].blank? + if session[:playlist][:tracks].none? + return render json: { success: false, msg: 'No active playlist' } + end - playlist_track_ids = session[:shuffle] ? session[:playlist_shuffled] : session[:playlist] + prefix = session[:playlist][:shuffle] ? 'shuffled_' : nil + track_ids = session[:playlist]["#{prefix}tracks".to_sym] - if playlist_track_ids.first == params[:track_id].to_i + if track_ids.first == params[:track_id].to_i if session[:loop] - render json: { success: true, track_id: playlist_track_ids.last } + render json: { success: true, track_id: track_ids.last } else render json: { success: false, msg: 'Beginning of playlist' } end - elsif (idx = playlist_track_ids.find_index(params[:track_id].to_i)) - render json: { success: true, track_id: playlist_track_ids[idx - 1] } + elsif (idx = track_ids.find_index(params[:track_id].to_i)) + render json: { success: true, track_id: track_ids[idx - 1] } else render json: { success: false, msg: 'track_id not in playlist' } end @@ -243,7 +244,7 @@ def random_show end def random_song_track - if (song = Song.where(id: params[:song_id]).first) + if (song = Song.find_by(id: params[:song_id])) track = song.tracks.sample show = Show.published.find_by(id: track.show_id) render json: { success: true, url: "/#{show.date}", track_id: track.id } @@ -252,12 +253,12 @@ def random_song_track end end - def playlist - render json: { playlist: session[:playlist] } - end - private + def fetch_playlist + Playlist.find_by(id: params[:id], user: current_user) + end + def render_bad_playlist(playlist) render json: { success: false, msg: playlist.errors.full_messages.join(', ') } end @@ -274,70 +275,53 @@ def render_good_playlist(playlist) def refresh_playlist(playlist) create_playlist_tracks(playlist) - activate_saved_playlist(playlist) + activate_stored(playlist) end - def order_by_for_saved_playlists + def order_by_for_stored_playlists params[:sort] = 'name' unless params[:sort].in?(%w[name duration]) "#{params[:sort]} asc" end def create_playlist_tracks(playlist) - session[:playlist].each_with_index do |track_id, idx| - PlaylistTrack.create( - playlist_id: playlist.id, - track_id:, - position: idx + 1 - ) + session[:playlist][:tracks].each_with_index do |track_id, idx| + PlaylistTrack.create(playlist:, track_id:, position: idx + 1) end playlist.update(duration: playlist.tracks.sum(&:duration)) end - def activate_saved_playlist(playlist) + def activate_stored(playlist) update_playlist(playlist) retrieve_bookmark(playlist) if current_user end def update_playlist(playlist) track_ids = playlist.playlist_tracks.order(position: :asc).pluck(:track_id) - session.update( - playlist: track_ids, - playlist_shuffled: track_ids.shuffle, - playlist_id: playlist.id, - playlist_name: playlist.name, - playlist_slug: playlist.slug, - playlist_user_id: playlist.user.id, - playlist_username: playlist.user.username + session[:playlist].merge!( + tracks: track_ids, + shuffled_tracks: track_ids.shuffle, + id: playlist.id, + name: playlist.name, + slug: playlist.slug, + user_id: playlist.user.id, + username: playlist.user.username ) end def retrieve_bookmark(playlist) - bookmark = PlaylistBookmark.where(playlist_id: playlist.id, user: current_user).first + bookmark = PlaylistBookmark.find_by(playlist_id: playlist.id, user: current_user) session[:playlist_is_bookmarked] = bookmark.present? end - def clear_saved_playlist - session.update( - playlist: [], - playlist_shuffled: [], - playlist_id: 0, - playlist_name: '', - playlist_slug: '', - playlist_user_id: '', - playlist_username: '', - playlist_is_bookmarked: false - ) + def clear_session + session.update(playlist: EMPTY_PLAYLIST.dup) + end + + def init_session + session[:playlist] ||= EMPTY_PLAYLIST.dup end - def init_session_playlist - session[:playlist] ||= [] - session[:playlist_shuffled] ||= [] - session[:playlist_id] ||= 0 - session[:playlist_name] ||= '' - session[:playlist_slug] ||= '' - session[:playlist_user_id] ||= '' - session[:playlist_username] ||= '' - session[:loop] ||= false - session[:shuffle] ||= false + def shuffle_tracks + session[:playlist][:shuffled_tracks] = session[:playlist][:tracks].shuffle end end diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index a95b2415..5888db8b 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -117,8 +117,8 @@ def user_dropdown_links def playlists_sub_links { - 'Active' => [active_playlist_path, ['active_playlist']], - 'Saved' => [saved_playlists_path, ['saved_playlists']] + 'Active' => [active_playlist_path, ['active']], + 'Saved' => [stored_playlists_path, ['stored']] }.map do |name, props| css = '' css = 'active' if props.second.include?(params[:action]) diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb index 963e85f1..2910a8d1 100644 --- a/app/helpers/sort_helper.rb +++ b/app/helpers/sort_helper.rb @@ -95,7 +95,7 @@ def venues_sort_items } end - def saved_playlist_sort_items + def stored_playlist_sort_items { ' Name' => 'name', ' Duration' => 'duration' diff --git a/app/models/playlist.rb b/app/models/playlist.rb index e4960b11..c03eb510 100644 --- a/app/models/playlist.rb +++ b/app/models/playlist.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true class Playlist < ApplicationRecord + MAX_TRACKS = 100 + has_many :playlist_tracks, dependent: :destroy has_many :tracks, through: :playlist_tracks has_many :playlist_bookmarks, dependent: :destroy @@ -16,6 +18,7 @@ class Playlist < ApplicationRecord message: 'must be between 5 and 50 lowercase letters, numbers, or dashes' }, uniqueness: true + validate :limit_total_tracks def as_json_api { @@ -36,4 +39,11 @@ def as_json_api_basic updated_at: updated_at.iso8601 } end + + private + + def limit_total_tracks + return unless playlist_tracks.count > MAX_TRACKS + errors.add(:tracks, "can't have more than #{MAX_TRACKS} tracks") + end end diff --git a/app/views/playlists/active_playlist.html.slim b/app/views/playlists/active.html.slim similarity index 77% rename from app/views/playlists/active_playlist.html.slim rename to app/views/playlists/active.html.slim index fd1f91f9..0f5498c3 100644 --- a/app/views/playlists/active_playlist.html.slim +++ b/app/views/playlists/active.html.slim @@ -1,19 +1,19 @@ = render partial: 'layouts/global_nav' #content - #playlist_data data-id=session[:playlist_id] data-name=session[:playlist_name] data-slug=session[:playlist_slug] data-user-id=session[:playlist_user_id] data-username=session[:playlist_username] + #playlist_data data-id=session[:playlist][:id] data-name=session[:playlist][:name] data-slug=session[:playlist][:slug] data-user-id=session[:playlist][:user_id] data-username=session[:playlist][:username] #title_box - h1.playlist_title = session[:playlist_id] > 0 ? session[:playlist_name] : '(Untitled Playlist)' - - if session[:playlist_id] > 0 - h3 Author: #{session[:playlist_username]} + h1.playlist_title = session[:playlist][:id].positive? ? session[:playlist][:name] : '(Untitled Playlist)' + - if session[:playlist][:id].positive? + h3 Author: #{session[:playlist][:username]} h3#active_playlist_tracks_label Tracks: #{@tracks.size} h3#active_playlist_duration_label Length: #{duration_readable(@duration, 'letters')} br - unless user_signed_in? p.instructions - = link_to 'Sign in', new_user_session_path + = link_to 'Sign in', new_user_session_path, class: 'non-remote' | to create and share custom playlists! button#playlist_mode_btn.btn.btn-success type='button' @@ -22,7 +22,7 @@ br - if user_signed_in? - - if session[:playlist_id] && session[:playlist_id] > 0 && session[:playlist_user_id] != current_user.id + - if session[:playlist][:id].positive? && session[:playlist][:user_id] != current_user.id button#duplicate_playlist_btn.btn type='button' i.icon-file | DUPLICATE @@ -34,8 +34,8 @@ | SAVE br - - if session[:playlist_id] && session[:playlist_id] > 0 - - if current_user.id == session[:playlist_user_id] + - if session[:playlist][:id].positive? + - if current_user.id == session[:playlist][:user_id] button#delete_playlist_btn.btn type='button' i.icon-remove | DELETE diff --git a/app/views/playlists/saved_playlists.html.slim b/app/views/playlists/stored.html.slim similarity index 72% rename from app/views/playlists/saved_playlists.html.slim rename to app/views/playlists/stored.html.slim index dbb9c3ed..c5bde40c 100644 --- a/app/views/playlists/saved_playlists.html.slim +++ b/app/views/playlists/stored.html.slim @@ -6,18 +6,21 @@ - if user_signed_in? h3 Lists: #{number_with_delimiter(@playlists.size)} = render partial: 'display_filter' - = render partial: 'shared/sort_filter', locals: { item_hash: saved_playlist_sort_items } + = render partial: 'shared/sort_filter', locals: { item_hash: stored_playlist_sort_items } #content_box - if !user_signed_in? - .callout_box You must sign in to manage saved playlists + .callout_box + |> You must + => link_to 'sign in', new_user_session_path, class: 'non-remote' + | to create and share custom playlists! - else ul.item_list.clickable - @playlists.each do |playlist| li h2.wide-350 a.non-remote href="/play/#{playlist.slug}" = playlist.name - h3 = duration_readable(playlist.duration, 'letters') + h3.alt = duration_readable(playlist.duration, 'letters') h4.narrow-100 by #{playlist.user.username} = render partial: 'shared/context_menu_for_playlist', locals: { playlist: playlist } = clear_both diff --git a/config/routes.rb b/config/routes.rb index 99062b02..05b33564 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,19 +39,19 @@ post '/toggle-like' => 'likes#toggle_like', as: 'toggle_like' # Playlists / player - get '/playlist' => 'playlists#active_playlist', as: 'active_playlist' - get '/play/:slug' => 'playlists#active_playlist', as: 'activate_playlist' - get '/playlists' => 'playlists#saved_playlists', as: 'saved_playlists' - get '/get-playlist' => 'playlists#playlist' - post '/save-playlist' => 'playlists#save_playlist' - post '/bookmark-playlist' => 'playlists#bookmark_playlist' - post '/unbookmark-playlist' => 'playlists#unbookmark_playlist' - post '/delete-playlist' => 'playlists#destroy_playlist' - post '/reset-playlist/' => 'playlists#reset_playlist' - post '/clear-playlist/' => 'playlists#clear_playlist' - post '/update-current-playlist' => 'playlists#update_active_playlist' - post '/add-track' => 'playlists#add_track_to_playlist' - post '/add-show' => 'playlists#add_show_to_playlist' + get '/playlist' => 'playlists#active', as: 'active_playlist' + get '/play/:slug' => 'playlists#active', as: 'activate_playlist' + get '/playlists' => 'playlists#stored', as: 'stored_playlists' + get '/load-playlist' => 'playlists#load' + post '/save-playlist' => 'playlists#save' + post '/bookmark-playlist' => 'playlists#bookmark' + post '/unbookmark-playlist' => 'playlists#unbookmark' + post '/delete-playlist' => 'playlists#destroy' + post '/clear-playlist' => 'playlists#clear' + post '/override-playlist' => 'playlists#override' + post '/reposition-playlist' => 'playlists#reposition' + post '/add-track' => 'playlists#add_track' + post '/add-show' => 'playlists#add_show' get '/next-track(/:track_id)' => 'playlists#next_track_id' get '/previous-track/:track_id' => 'playlists#previous_track_id' post '/submit-playback-loop' => 'playlists#submit_playback_loop' diff --git a/spec/features/auth/reset_password_spec.rb b/spec/features/auth/reset_password_spec.rb index ea3254bd..1815d81b 100644 --- a/spec/features/auth/reset_password_spec.rb +++ b/spec/features/auth/reset_password_spec.rb @@ -27,7 +27,7 @@ # User enters a new password, twice fill_in('user[password]', with: new_password) fill_in('user[password_confirmation]', with: new_password) - click_on('Change My Password') + click_link('Change My Password') # User's password is changed expect(user.reload.valid_password?(new_password)).to be(true) diff --git a/spec/features/playlists_spec.rb b/spec/features/playlists_spec.rb index 3ffd9988..02a75ddb 100644 --- a/spec/features/playlists_spec.rb +++ b/spec/features/playlists_spec.rb @@ -85,7 +85,7 @@ let!(:playlist) { create(:playlist, user:) } it 'opening a saved playlist' do - visit saved_playlists_path + visit stored_playlists_path click_link(playlist.name) expect(page).to have_current_path("/play/#{playlist.slug}") diff --git a/spec/features/show_context_menus_spec.rb b/spec/features/show_context_menus_spec.rb index da164c9b..2e08165b 100644 --- a/spec/features/show_context_menus_spec.rb +++ b/spec/features/show_context_menus_spec.rb @@ -14,7 +14,7 @@ expect_content('Lookup at phish.net') click_link('Add to playlist') - expect_content('Tracks added to playlist') + expect_content('Tracks from show added to playlist') click_link('Share') expect_content('Link copied to clipboard')