From 7d1773bc6b01caad8666ef07a9b2f2ac326fd0cd Mon Sep 17 00:00:00 2001 From: Roman Chvanikov Date: Tue, 17 Sep 2019 16:48:24 +0300 Subject: [PATCH] Rename SubscriptionNotificationController list and get actions to index and show --- .../subscription_notification_controller.ex | 4 ++-- lib/pleroma/web/router.ex | 4 ++-- ...bscription_notification_controller_test.exs | 18 +++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/pleroma/web/pleroma_api/subscription_notification_controller.ex b/lib/pleroma/web/pleroma_api/subscription_notification_controller.ex index 969ce0179..fa8307668 100644 --- a/lib/pleroma/web/pleroma_api/subscription_notification_controller.ex +++ b/lib/pleroma/web/pleroma_api/subscription_notification_controller.ex @@ -10,7 +10,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationController do alias Pleroma.SubscriptionNotification alias Pleroma.Web.PleromaAPI.PleromaAPI - def list(%{assigns: %{user: user}} = conn, params) do + def index(%{assigns: %{user: user}} = conn, params) do notifications = PleromaAPI.get_subscription_notifications(user, params) conn @@ -18,7 +18,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationController do |> render("index.json", %{notifications: notifications, for: user}) end - def get(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do + def show(%{assigns: %{user: user}} = conn, %{"id" => id} = _params) do with {:ok, notification} <- SubscriptionNotification.get(user, id) do render(conn, "show.json", %{subscription_notification: notification, for: user}) else diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex index 1fff94b38..502c67e74 100644 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@ -273,8 +273,8 @@ defmodule Pleroma.Web.Router do post("/clear", SubscriptionNotificationController, :clear) post("/dismiss", SubscriptionNotificationController, :dismiss) delete("/destroy_multiple", SubscriptionNotificationController, :destroy_multiple) - get("/", SubscriptionNotificationController, :list) - get("/:id", SubscriptionNotificationController, :get) + get("/", SubscriptionNotificationController, :index) + get("/:id", SubscriptionNotificationController, :show) end end diff --git a/test/web/pleroma_api/subscription_notification_controller_test.exs b/test/web/pleroma_api/subscription_notification_controller_test.exs index 781d27ead..c6a71732d 100644 --- a/test/web/pleroma_api/subscription_notification_controller_test.exs +++ b/test/web/pleroma_api/subscription_notification_controller_test.exs @@ -33,7 +33,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do test "list of notifications", %{conn: conn, user: user, subscriber: subscriber} do status_text = "Hello" {:ok, _activity} = CommonAPI.post(user, %{"status" => status_text}) - path = subscription_notification_path(conn, :list) + path = subscription_notification_path(conn, :index) conn = conn @@ -50,7 +50,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do {:ok, _activity} = CommonAPI.post(user, %{"status" => status_text}) [notification] = Repo.all(SubscriptionNotification) - path = subscription_notification_path(conn, :get, notification) + path = subscription_notification_path(conn, :show, notification) conn = conn @@ -101,7 +101,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn = build_conn() |> assign(:user, subscriber) - |> get(subscription_notification_path(conn, :list)) + |> get(subscription_notification_path(conn, :index)) assert json_response(conn, 200) == [] @@ -136,7 +136,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn_res = get( conn, - subscription_notification_path(conn, :list, %{ + subscription_notification_path(conn, :index, %{ "limit" => 2, "min_id" => notification1_id }) @@ -149,7 +149,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn_res = get( conn, - subscription_notification_path(conn, :list, %{ + subscription_notification_path(conn, :index, %{ "limit" => 2, "since_id" => notification1_id }) @@ -162,7 +162,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn_res = get( conn, - subscription_notification_path(conn, :list, %{ + subscription_notification_path(conn, :index, %{ "limit" => 2, "max_id" => notification4_id }) @@ -195,7 +195,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn = assign(conn, :user, user1) - conn_res = get(conn, subscription_notification_path(conn, :list)) + conn_res = get(conn, subscription_notification_path(conn, :index)) result = json_response(conn_res, 200) @@ -205,7 +205,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do conn2 = assign(conn, :user, user2) - conn_res = get(conn2, subscription_notification_path(conn, :list)) + conn_res = get(conn2, subscription_notification_path(conn, :index)) result = json_response(conn_res, 200) @@ -220,7 +220,7 @@ defmodule Pleroma.Web.PleromaAPI.SubscriptionNotificationControllerTest do assert json_response(conn_destroy, 200) == %{} - conn_res = get(conn2, subscription_notification_path(conn, :list)) + conn_res = get(conn2, subscription_notification_path(conn, :index)) result = json_response(conn_res, 200)