-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for various artists album
- Loading branch information
Showing
37 changed files
with
209 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class Artists::AlbumsController < ApplicationController | ||
before_action :require_login | ||
before_action :find_artist | ||
before_action :find_albums | ||
|
||
def index | ||
raise BlackCandyError::NotFound if @albums.empty? | ||
end | ||
|
||
private | ||
def find_albums | ||
@albums = @artist.albums | ||
end | ||
|
||
def find_artist | ||
@artist = Artist.find(params[:artist_id]) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class Artists::AppearsOnAlbumsController < Artists::AlbumsController | ||
private | ||
def find_albums | ||
@albums = @artist.appears_on_albums | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<% if albums.present? %> | ||
<div class='cards'> | ||
<div class='heading heading--expand display__space-between display__full-width display__align-center'> | ||
<div class='heading__body'> | ||
<div class='heading__body__text heading__body__text--main'> | ||
<%= title %> | ||
</div> | ||
</div> | ||
<% if local_assigns[:all_albums_link] && all_albums_link.present? %> | ||
<%= link_to t('text.see_all'), all_albums_link %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<div class='cards'> | ||
<%= render partial: 'albums/album', collection: albums, cached: true %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% cache artist do %> | ||
<div class='cards'> | ||
<div class='heading heading--expand'> | ||
<div class='heading__image'> | ||
<%= image_tag image_url_for(artist), class: 'image' %> | ||
</div> | ||
<div class='heading__body'> | ||
<div class='heading__body__text heading__body__text--main'><%= artist.title %></div> | ||
<div class='heading__body__text'> | ||
<span><%= artist.all_albums.size %> <%= t('label.albums') %></span> | ||
<span>,</span> | ||
<span><%= artist.songs.size %> <%= t('label.songs')%></span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class='line'></div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render partial: 'artists/info', locals: { artist: @artist } %> | ||
<%= render partial: 'artists/albums', locals: { title: t('label.albums'), albums: @albums } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<%= render partial: 'artists/info', locals: { artist: @artist } %> | ||
<%= render partial: 'artists/albums', locals: { title: t('label.appears_on'), albums: @albums } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,11 @@ | ||
<% cache @artist do %> | ||
<div class='cards'> | ||
<div class='heading heading--expand'> | ||
<div class='heading__image'> | ||
<%= image_tag image_url_for(@artist), class: 'image' %> | ||
</div> | ||
<div class='heading__body'> | ||
<div class='heading__body__text heading__body__text--main'><%= @artist.title %></div> | ||
<div class='heading__body__text'> | ||
<span><%= @albums.size %> <%= t('label.albums') %></span> | ||
<span>,</span> | ||
<span><%= @artist.songs.size %> <%= t('label.songs')%></span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class='line'></div> | ||
<% end %> | ||
<div data-controller='infinite-scroll' data-infinite-scroll-next-url='<%= pagy_next_url(@pagy) %>'> | ||
<div class='cards' id='js-albums-content'> | ||
<%= render partial: 'albums/album', collection: @albums, cached: true %> | ||
</div> | ||
<div data-target='infinite-scroll.trigger' class='display__justify-align-center'> | ||
<% if @pagy.next %> | ||
<%= loader_tag %> | ||
<% end %> | ||
</div> | ||
</div> | ||
<%= render partial: 'info', locals: { artist: @artist} %> | ||
<%= render partial: 'albums', locals: { | ||
title: t('label.albums'), | ||
albums: @albums, | ||
all_albums_link: @albums_pagy.next.present? ? artist_albums_path(@artist) : '' } %> | ||
<%= render partial: 'albums', locals: { | ||
title: t('label.appears_on'), | ||
albums: @appears_on_albums, | ||
all_albums_link: @appears_on_albums_pagy.next.present? ? artist_appears_on_albums_path(@artist) : '' } %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddIsVariousToArtists < ActiveRecord::Migration[6.0] | ||
def change | ||
add_column(:artists, :is_various, :boolean, default: false) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class Artists::AlbumsControllerTest < ActionDispatch::IntegrationTest | ||
test 'should get index' do | ||
assert_login_access(url: artist_albums_path(artists :artist1)) do | ||
assert_response :success | ||
end | ||
end | ||
|
||
test 'should redirect to not found page when artists have no albums' do | ||
empty_artist = Artist.create | ||
|
||
assert_login_access(url: artist_albums_path(empty_artist)) do | ||
assert_response :not_found | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
test/controllers/artists/appears_on_albums_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class Artists::AppearsOnAlbumsControllerTest < ActionDispatch::IntegrationTest | ||
test 'should get index' do | ||
assert_login_access(url: artist_appears_on_albums_path(artists :artist1)) do | ||
assert_response :success | ||
end | ||
end | ||
|
||
test 'should redirect to not found page when artists have no albums' do | ||
assert artists(:artist2).appears_on_albums.empty? | ||
assert_login_access(url: artist_appears_on_albums_path(artists :artist2)) do | ||
assert_response :not_found | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,6 @@ album2: | |
album3: | ||
name: 'album3' | ||
artist: 'artist2' | ||
album4: | ||
name: 'album4' | ||
artist: 'various_artists' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ artist1: | |
|
||
artist2: | ||
name: 'artist2' | ||
|
||
various_artists: | ||
is_various: true |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.