Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON response for API of favorite playlist song #310

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.call(@song, :id, :name)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.call(@song, :id, :name)
18 changes: 15 additions & 3 deletions test/controllers/api/v1/favorite_playlist/songs_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@ class Api::V1::FavoritePlaylist::SongsControllerTest < ActionDispatch::Integrati
end

test "should add songs to playlist" do
post api_v1_favorite_playlist_songs_url, params: {song_id: 3}, headers: api_token_header(@user)
post api_v1_favorite_playlist_songs_url, params: {song_id: 3}, as: :json, headers: api_token_header(@user)
response = @response.parsed_body

assert_response :success
assert_equal 3, response["id"]
assert_equal [3, 1, 2], @playlist.reload.song_ids
end

test "should remove songs from playlist" do
delete api_v1_favorite_playlist_songs_url, params: {song_id: 1}, headers: api_token_header(@user)
delete api_v1_favorite_playlist_songs_url, params: {song_id: 1}, as: :json, headers: api_token_header(@user)
response = @response.parsed_body

assert_response :success
assert_equal 1, response["id"]
assert_equal [2], @playlist.reload.song_ids

delete api_v1_favorite_playlist_songs_url, params: {song_id: 2}, headers: api_token_header(@user)
delete api_v1_favorite_playlist_songs_url, params: {song_id: 2}, as: :json, headers: api_token_header(@user)
response = @response.parsed_body

assert_response :success
assert_equal 2, response["id"]
assert_equal [], @playlist.reload.song_ids
end

Expand Down