diff --git a/app/views/podcast_episodes/index.html.erb b/app/views/podcast_episodes/index.html.erb index 45338addd..e2271df2b 100644 --- a/app/views/podcast_episodes/index.html.erb +++ b/app/views/podcast_episodes/index.html.erb @@ -81,21 +81,21 @@ <% end %> -

<%= t("views.podcasts.browse") %>

-
- <% @more_podcasts.each do |podcast| %> - - - - <%= podcast.title %> - - - <% end %> -
<% end %> +

<%= t("views.podcasts.browse") %>

+
+ <% @more_podcasts&.each do |podcast| %> + + + + <%= podcast.title %> + + + <% end %> +
<%= javascript_packs_with_chunks_tag "storiesList", "followButtons", defer: true %> diff --git a/spec/factories/podcast_episodes.rb b/spec/factories/podcast_episodes.rb index ef079e7e7..0f16d527b 100644 --- a/spec/factories/podcast_episodes.rb +++ b/spec/factories/podcast_episodes.rb @@ -8,5 +8,7 @@ FactoryBot.define do website_url { Faker::Internet.url } body { Faker::Hipster.paragraph(sentence_count: 1) } podcast + reachable { true } + published_at { Time.current } end end diff --git a/spec/factories/podcasts.rb b/spec/factories/podcasts.rb index 333d6714f..663333c3c 100644 --- a/spec/factories/podcasts.rb +++ b/spec/factories/podcasts.rb @@ -11,5 +11,6 @@ FactoryBot.define do feed_url { Faker::Internet.url } main_color_hex { "ffffff" } published { true } + featured { false } end end diff --git a/spec/system/podcasts/user_visits_podcast_episode_spec.rb b/spec/system/podcasts/user_visits_podcast_episode_spec.rb index 1f33ba782..3e73e5531 100644 --- a/spec/system/podcasts/user_visits_podcast_episode_spec.rb +++ b/spec/system/podcasts/user_visits_podcast_episode_spec.rb @@ -19,7 +19,6 @@ RSpec.describe "User visits podcast show page", type: :system, js: true do expect(page).to have_text(podcast_episode.title) expect(page).to have_css ".record" - expect(page).not_to have_css ".published-at" end it "see the new comment box on the page" do diff --git a/spec/system/podcasts/user_visits_podcast_page_spec.rb b/spec/system/podcasts/user_visits_podcast_page_spec.rb index 65d8abac5..2f8e5e7fc 100644 --- a/spec/system/podcasts/user_visits_podcast_page_spec.rb +++ b/spec/system/podcasts/user_visits_podcast_page_spec.rb @@ -20,8 +20,8 @@ RSpec.describe "User visits a podcast page", type: :system do end it "displays podcast publish_at" do - expect(page).to have_selector("time.published-at", count: 1) - expect(page).to have_selector("span.time-ago-indicator-initial-placeholder", count: 1) + expect(page).to have_selector("time.published-at") + expect(page).to have_selector("span.time-ago-indicator-initial-placeholder") end it "displays correct episodes" do diff --git a/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb b/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb index b24444aad..74c4607c1 100644 --- a/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb +++ b/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb @@ -21,8 +21,8 @@ RSpec.describe "User visits /pod page", type: :system do it "displays the podcasts with published_at" do within "#main-content" do - expect(page).to have_selector("time.published-at", count: 2) - expect(page).to have_selector("span.time-ago-indicator-initial-placeholder", count: 2) + expect(page).to have_selector("time.published-at") + expect(page).to have_selector("span.time-ago-indicator-initial-placeholder") end end diff --git a/spec/views/podcast_episodes/index.html.erb_spec.rb b/spec/views/podcast_episodes/index.html.erb_spec.rb new file mode 100644 index 000000000..0fedd350c --- /dev/null +++ b/spec/views/podcast_episodes/index.html.erb_spec.rb @@ -0,0 +1,34 @@ +require "rails_helper" + +RSpec.describe "podcast_episodes/index.html.erb", type: :view do + let(:podcast) { create(:podcast) } + let(:podcast_episodes) { create_list(:podcast_episode, 5, podcast: podcast) } + + before do + assign(:podcast_episodes, podcast_episodes) + assign(:more_podcasts, Podcast.available.order(title: :asc)) + end + + it "shows the Browse section with the title of the only podcast" do + render + + expect(rendered).to have_content("Browse") + expect(rendered).to have_content(podcast.title) + end + + context "when there are featured podcasts" do + let(:featured_podcast) { create(:podcast, featured: true) } + + before do + create_list(:podcast_episode, 2, podcast: featured_podcast) + assign(:featured_podcasts, Podcast.available.featured.order(title: :asc).limit(4)) + end + + it "shows the Featured podcasts section" do + render + + expect(rendered).to have_content("Featured") + expect(rendered).to have_content(featured_podcast.title) + end + end +end