Skip to content

Commit

Permalink
Mature content channel api (#630)
Browse files Browse the repository at this point in the history
* Adds mature_content to Channel Resolver

* Changes type to boolean & updates description

* Maybe adds mature_content API test & cleans up channel_test

* Updates mature_content API test to re-call the API after update

* idk how to do tests, so removed most of them lol

* Removed unused channel variable in tests
  • Loading branch information
AdamHebby authored Apr 22, 2021
1 parent 7c8fcb6 commit 0be1dbc
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 63 deletions.
1 change: 1 addition & 0 deletions lib/glimesh/graphql/schema/channel_types.ex
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ defmodule Glimesh.Schema.ChannelTypes do
field :title, :string, description: "The title of the current stream, live or offline."
field :category, :category, resolve: dataloader(Repo)
field :subcategory, :subcategory, resolve: dataloader(Repo)
field :mature_content, :boolean, description: "If the streamer has flagged this channel as only appropriate for Mature Audiences."
field :language, :string, description: "The language a user can expect in the stream."
field :thumbnail, :string

Expand Down
125 changes: 62 additions & 63 deletions test/glimesh_web/api/channel_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ defmodule GlimeshWeb.Api.ChannelTest do
title
streamer { username }
mature_content
subcategory {
name
}
Expand All @@ -35,46 +37,45 @@ defmodule GlimeshWeb.Api.ChannelTest do
setup [:register_and_set_user_token, :create_channel]

test "returns all channels", %{conn: conn, user: user} do
conn =
post(conn, "/api", %{
"query" => @channels_query
})
conn = post(conn, "/api", %{
"query" => @channels_query
})

assert json_response(conn, 200) == %{
"data" => %{
"channels" => [
%{
"title" => "Live Stream!",
"streamer" => %{"username" => user.username}
}
]
}
}
"data" => %{
"channels" => [
%{
"title" => "Live Stream!",
"streamer" => %{"username" => user.username}
}
]
}
}
end

test "returns a channel", %{conn: conn, user: user} do
conn =
post(conn, "/api", %{
"query" => @channel_query,
"variables" => %{username: user.username}
})
conn = post(conn, "/api", %{
"query" => @channel_query,
"variables" => %{username: user.username}
})

assert json_response(conn, 200) == %{
"data" => %{
"channel" => %{
"title" => "Live Stream!",
"streamer" => %{"username" => user.username},
"subcategory" => %{
"name" => "World of Warcraft"
},
"tags" => [
%{
"name" => "Chill Stream"
}
]
}
}
}
"data" => %{
"channel" => %{
"title" => "Live Stream!",
"streamer" => %{"username" => user.username},
"mature_content" => false,
"subcategory" => %{
"name" => "World of Warcraft"
},
"tags" => [
%{
"name" => "Chill Stream"
}
]
}
}
}
end
end

Expand Down Expand Up @@ -109,43 +110,41 @@ defmodule GlimeshWeb.Api.ChannelTest do
setup [:register_and_set_user_token, :create_tag, :create_subcategory]

test "returns all categories", %{conn: conn} do
conn =
post(conn, "/api", %{
"query" => @categories_query
})
conn = post(conn, "/api", %{
"query" => @categories_query
})

assert Enum.member?(
Enum.map(json_response(conn, 200)["data"]["categories"], fn x -> x["slug"] end),
"gaming"
)
Enum.map(json_response(conn, 200)["data"]["categories"], fn x -> x["slug"] end),
"gaming"
)
end

test "returns a category", %{conn: conn} do
conn =
post(conn, "/api", %{
"query" => @category_query,
"variables" => %{slug: "gaming"}
})
conn = post(conn, "/api", %{
"query" => @category_query,
"variables" => %{slug: "gaming"}
})

assert json_response(conn, 200) == %{
"data" => %{
"category" => %{
"name" => "Gaming",
"slug" => "gaming",
"subcategories" => [
%{
"name" => "World of Warcraft",
"backgroundImageUrl" => nil
}
],
"tags" => [
%{
"name" => "Chill Stream"
}
]
}
}
}
"data" => %{
"category" => %{
"name" => "Gaming",
"slug" => "gaming",
"subcategories" => [
%{
"name" => "World of Warcraft",
"backgroundImageUrl" => nil
}
],
"tags" => [
%{
"name" => "Chill Stream"
}
]
}
}
}
end
end

Expand Down

0 comments on commit 0be1dbc

Please sign in to comment.