mirror of
https://github.com/kieraneglin/pinchflat.git
synced 2026-01-23 02:24:24 +00:00
Added OPML Endpoint for podcast rss feeds (#512)
* Added OPML Endpoint for podcast rss feeds * changed opml route and added controller test for opml endpoint * add copy opml feed button * add copy opml feed button - correct url * fix html indenting * add indentation to opml Co-authored-by: Kieran <kieran.eglin@gmail.com> * use convention for unused controller params Co-authored-by: Kieran <kieran.eglin@gmail.com> * add test for opml_sources helper function * change opml endpoint to be more inline with the other routes --------- Co-authored-by: robs <git@robs.social> Co-authored-by: Kieran <kieran.eglin@gmail.com>
This commit is contained in:
parent
a2a70fcce2
commit
c9bd1ea7bd
9 changed files with 151 additions and 12 deletions
34
test/pinchflat/podcasts/opml_feed_builder_test.exs
Normal file
34
test/pinchflat/podcasts/opml_feed_builder_test.exs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
defmodule Pinchflat.Podcasts.OpmlFeedBuilderTest do
|
||||
use Pinchflat.DataCase
|
||||
|
||||
import Pinchflat.SourcesFixtures
|
||||
|
||||
alias Pinchflat.Podcasts.OpmlFeedBuilder
|
||||
|
||||
setup do
|
||||
source = source_fixture()
|
||||
|
||||
{:ok, source: source}
|
||||
end
|
||||
|
||||
describe "build/2" do
|
||||
test "returns an XML document", %{source: source} do
|
||||
res = OpmlFeedBuilder.build("http://example.com", [source])
|
||||
|
||||
assert String.contains?(res, ~s(<?xml version="1.0" encoding="UTF-8"?>))
|
||||
end
|
||||
|
||||
test "escapes illegal characters" do
|
||||
source = source_fixture(%{custom_name: "A & B"})
|
||||
res = OpmlFeedBuilder.build("http://example.com", [source])
|
||||
|
||||
assert String.contains?(res, ~s(A & B))
|
||||
end
|
||||
|
||||
test "build podcast link with URL base", %{source: source} do
|
||||
res = OpmlFeedBuilder.build("http://example.com", [source])
|
||||
|
||||
assert String.contains?(res, ~s(http://example.com/sources/#{source.uuid}/feed.xml))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -6,6 +6,16 @@ defmodule Pinchflat.Podcasts.PodcastHelpersTest do
|
|||
|
||||
alias Pinchflat.Podcasts.PodcastHelpers
|
||||
|
||||
describe "opml_sources" do
|
||||
test "returns sources not marked for deletion" do
|
||||
source = source_fixture()
|
||||
source_fixture(%{marked_for_deletion_at: DateTime.utc_now()})
|
||||
assert [found_source] = PodcastHelpers.opml_sources()
|
||||
assert found_source.custom_name == source.custom_name
|
||||
assert found_source.uuid == source.uuid
|
||||
end
|
||||
end
|
||||
|
||||
describe "persisted_media_items_for/2" do
|
||||
test "returns media items with files that exist on-disk" do
|
||||
source = source_fixture()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,20 @@ defmodule PinchflatWeb.PodcastControllerTest do
|
|||
import Pinchflat.MediaFixtures
|
||||
import Pinchflat.SourcesFixtures
|
||||
|
||||
describe "opml_feed" do
|
||||
test "renders the XML document", %{conn: conn} do
|
||||
source = source_fixture()
|
||||
|
||||
conn = get(conn, ~p"/sources/opml" <> ".xml")
|
||||
|
||||
assert conn.status == 200
|
||||
assert {"content-type", "application/opml+xml; charset=utf-8"} in conn.resp_headers
|
||||
assert {"content-disposition", "inline"} in conn.resp_headers
|
||||
assert conn.resp_body =~ ~s"http://www.example.com/sources/#{source.uuid}/feed.xml"
|
||||
assert conn.resp_body =~ "text=\"Cool and good internal name!\""
|
||||
end
|
||||
end
|
||||
|
||||
describe "rss_feed" do
|
||||
test "renders the XML document", %{conn: conn} do
|
||||
source = source_fixture()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue