Skip to content

Commit

Permalink
Add auto-discovery links for Atom feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
floehopper committed Jan 9, 2024
1 parent 7331c86 commit f4d3101
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/views/artists/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
)
%>

<% content_for(:auto_discovery) do %>
<%= auto_discovery_link_tag(:atom, { format: :atom }, { title: 'Artists on jam.coop' }) %>
<% end %>

<%= render('shared/page_header', text: 'Artists') %>

<div class="pt-4 grid grid-cols-3 gap-4">
Expand Down
4 changes: 4 additions & 0 deletions app/views/artists/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
)
%>

<% content_for(:auto_discovery) do %>
<%= auto_discovery_link_tag(:atom, { format: :atom }, { title: "#{@artist.name} albums on jam.coop" }) %>
<% end %>

<div class="flex flex-row border-b-2 border-b-slate-100 pb-6">
<div class="basis-1/4 mr-4 m:mr-0">
<div class="aspect-w-1 aspect-h-1">
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_importmap_tags %>
<%= hotwire_livereload_tags if Rails.env.development? %>
<%= content_for(:auto_discovery) %>
</head>

<body class="bg-slate-100">
Expand Down
14 changes: 14 additions & 0 deletions test/controllers/artists_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ class ArtistsControllerTestSignedOut < ActionDispatch::IntegrationTest
assert_select 'p', { text: @artist.name }
end

test '#index includes auto-discovery link for atom feed' do
get artists_url

url = artists_url(format: :atom)
assert_select "head link[rel='alternate'][type='application/atom+xml'][href='#{url}']"
end

test '#index with atom format should render atom feed' do
@artist.update!(name: 'Older Artist')
@artist.albums << create(:album, publication_status: :published)
Expand Down Expand Up @@ -184,6 +191,13 @@ class ArtistsControllerTestSignedOut < ActionDispatch::IntegrationTest
assert_select 'p', { text: 'Album Title (pending)', count: 0 }
end

test '#show includes auto-discovery link for atom feed' do
get artist_url(@artist)

url = artist_url(@artist, format: :atom)
assert_select "head link[rel='alternate'][type='application/atom+xml'][href='#{url}']"
end

test '#show with atom format should render atom feed' do
@artist.albums << create(:album, title: 'Older', publication_status: :published, released_on: 2.days.ago)
@artist.albums << create(:album, title: 'Newer', publication_status: :published, released_on: 1.day.ago)
Expand Down

0 comments on commit f4d3101

Please sign in to comment.