aboutsummaryrefslogtreecommitdiff
path: root/test/web/pleroma_api/controllers/scrobble_controller_test.exs
diff options
context:
space:
mode:
authorkPherox <admin@mail.kr-kp.com>2019-10-01 01:39:22 +0900
committerkPherox <admin@mail.kr-kp.com>2019-10-01 01:40:33 +0900
commita0f101ee806af06bcd4271cd8d57d11ff85ea11a (patch)
tree2cd3c5d1a645be1395c57ec5616f31afb4b68da7 /test/web/pleroma_api/controllers/scrobble_controller_test.exs
parent8ca4f145a51e92c9f3a6c374ceddfac22ea300d9 (diff)
parent7c9b023a918c84b60ae6547289a083c671a3659b (diff)
downloadpleroma-a0f101ee806af06bcd4271cd8d57d11ff85ea11a.tar.gz
Merge remote-tracking branch 'upstream/develop' into fix-prameter-name-of-accounts-update-credentials
Diffstat (limited to 'test/web/pleroma_api/controllers/scrobble_controller_test.exs')
-rw-r--r--test/web/pleroma_api/controllers/scrobble_controller_test.exs63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/web/pleroma_api/controllers/scrobble_controller_test.exs b/test/web/pleroma_api/controllers/scrobble_controller_test.exs
new file mode 100644
index 000000000..881f8012c
--- /dev/null
+++ b/test/web/pleroma_api/controllers/scrobble_controller_test.exs
@@ -0,0 +1,63 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.PleromaAPI.ScrobbleControllerTest do
+ use Pleroma.Web.ConnCase
+
+ alias Pleroma.Web.CommonAPI
+ import Pleroma.Factory
+
+ describe "POST /api/v1/pleroma/scrobble" do
+ test "works correctly", %{conn: conn} do
+ user = insert(:user)
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> post("/api/v1/pleroma/scrobble", %{
+ "title" => "lain radio episode 1",
+ "artist" => "lain",
+ "album" => "lain radio",
+ "length" => "180000"
+ })
+
+ assert %{"title" => "lain radio episode 1"} = json_response(conn, 200)
+ end
+ end
+
+ describe "GET /api/v1/pleroma/accounts/:id/scrobbles" do
+ test "works correctly", %{conn: conn} do
+ user = insert(:user)
+
+ {:ok, _activity} =
+ CommonAPI.listen(user, %{
+ "title" => "lain radio episode 1",
+ "artist" => "lain",
+ "album" => "lain radio"
+ })
+
+ {:ok, _activity} =
+ CommonAPI.listen(user, %{
+ "title" => "lain radio episode 2",
+ "artist" => "lain",
+ "album" => "lain radio"
+ })
+
+ {:ok, _activity} =
+ CommonAPI.listen(user, %{
+ "title" => "lain radio episode 3",
+ "artist" => "lain",
+ "album" => "lain radio"
+ })
+
+ conn =
+ conn
+ |> get("/api/v1/pleroma/accounts/#{user.id}/scrobbles")
+
+ result = json_response(conn, 200)
+
+ assert length(result) == 3
+ end
+ end
+end