• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / backend / 18dc689a4df4836fc6967bf0f74dc252964bd175-PR-1180

08 Sep 2024 06:14PM UTC coverage: 79.088% (-15.3%) from 94.372%
18dc689a4df4836fc6967bf0f74dc252964bd175-PR-1180

Pull #1180

github

josh1248
Change appropriate routes into admin scope
Pull Request #1180: Transfer groundControl (and admin panel) from staff to admin route

7 of 12 new or added lines in 1 file covered. (58.33%)

499 existing lines in 25 files now uncovered.

2602 of 3290 relevant lines covered (79.09%)

1023.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/lib/cadet_web/admin_controllers/admin_sourcecast_controller.ex
1
defmodule CadetWeb.AdminSourcecastController do
2
  use CadetWeb, :controller
3
  use PhoenixSwagger
4

5
  alias Cadet.Courses
6

7
  def create(conn, %{"sourcecast" => sourcecast}) do
UNCOV
8
    result = Courses.upload_sourcecast_file(conn.assigns.course_reg, sourcecast)
×
9

UNCOV
10
    case result do
×
11
      {:ok, _nil} ->
UNCOV
12
        send_resp(conn, 200, "OK")
×
13

14
      {:error, {status, message}} ->
15
        conn
16
        |> put_status(status)
UNCOV
17
        |> text(message)
×
18
    end
19
  end
20

21
  def create(conn, _params) do
UNCOV
22
    send_resp(conn, :bad_request, "Missing or invalid parameter(s)")
×
23
  end
24

25
  def delete(conn, %{"id" => id}) do
UNCOV
26
    result = Courses.delete_sourcecast_file(id)
×
27

UNCOV
28
    case result do
×
29
      {:ok, _nil} ->
UNCOV
30
        send_resp(conn, 200, "OK")
×
31

32
      {:error, {status, message}} ->
33
        conn
34
        |> put_status(status)
UNCOV
35
        |> text(message)
×
36
    end
37
  end
38

39
  swagger_path :create do
1✔
40
    post("/sourcecast")
41
    description("Uploads sourcecast")
42
    summary("Upload sourcecast")
43
    consumes("multipart/form-data")
44
    security([%{JWT: []}])
45

46
    parameters do
47
      public(
48
        :body,
49
        :boolean,
50
        "Uploads as public sourcecast when 'public' is specified regardless of truthy or falsy"
51
      )
52

53
      sourcecast(:body, Schema.ref(:Sourcecast), "sourcecast object", required: true)
54
    end
55

56
    response(200, "Success")
57
    response(400, "Invalid or missing parameter(s)")
58
    response(401, "Unauthorised")
59
  end
60

61
  swagger_path :delete do
1✔
62
    PhoenixSwagger.Path.delete("/sourcecast/{id}")
63
    description("Deletes sourcecast by id")
64
    summary("Delete sourcecast")
65
    security([%{JWT: []}])
66

67
    parameters do
68
      id(:path, :integer, "sourcecast id", required: true)
69
    end
70

71
    response(200, "Success")
72
    response(400, "Invalid or missing parameter(s)")
73
    response(401, "Unauthorised")
74
  end
75

76
  def swagger_definitions do
77
    %{
1✔
78
      Sourcecast:
79
        swagger_schema do
1✔
80
          properties do
1✔
81
            title(:string, "title", required: true)
82
            playbackData(:string, "playback data", required: true)
83
            description(:string, "description", required: false)
84
            uid(:string, "uid", required: false)
85

86
            # Note: this is technically an invalid type in Swagger/OpenAPI 2.0,
87
            # but represents that a string or integer could be returned.
88
            audio(:file, "audio file", required: true)
1✔
89
          end
90
        end
91
    }
92
  end
93
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc