diff --git a/app/assets/stylesheets/podcast-episodes-show.scss b/app/assets/stylesheets/podcast-episodes-show.scss
index 6259b233c..168af32df 100644
--- a/app/assets/stylesheets/podcast-episodes-show.scss
+++ b/app/assets/stylesheets/podcast-episodes-show.scss
@@ -65,8 +65,7 @@
@media screen and ( min-width: 680px ){
font-size:40px;
line-height:44px;
-
- margin-bottom:48px;
+ margin-bottom:28px;
}
@media screen and ( min-width: 800px ){
font-size:44px;
@@ -82,8 +81,7 @@
@media screen and ( min-width: 680px ){
font-size:30px;
line-height:33px;
-
- margin-bottom:40px;
+ margin-bottom:20px;
}
@media screen and ( min-width: 800px ){
font-size:40px;
diff --git a/app/controllers/podcast_episodes_controller.rb b/app/controllers/podcast_episodes_controller.rb
index e2184b685..da0426df0 100644
--- a/app/controllers/podcast_episodes_controller.rb
+++ b/app/controllers/podcast_episodes_controller.rb
@@ -6,9 +6,9 @@ class PodcastEpisodesController < ApplicationController
@podcast_index = true
@podcasts = Podcast.available.order("title asc")
- @podcast_episodes = PodcastEpisode.
+ @podcast_episodes = PodcastEpisodeDecorator.decorate_collection(PodcastEpisode.
available.
- includes(:podcast).order("published_at desc").first(20)
+ includes(:podcast).order("published_at desc").first(20))
if params[:q].blank?
surrogate_keys = ["podcast_episodes_all"] + @podcast_episodes.map(&:record_key)
diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb
index 91b63996d..5b8e66496 100644
--- a/app/controllers/stories_controller.rb
+++ b/app/controllers/stories_controller.rb
@@ -141,7 +141,8 @@ class StoriesController < ApplicationController
@podcast_index = true
@article_index = true
@list_of = "podcast-episodes"
- @podcast_episodes = @podcast.podcast_episodes.reachable.order("published_at DESC").limit(30)
+ @podcast_episodes = @podcast.podcast_episodes.
+ reachable.order("published_at DESC").limit(30).decorate
set_surrogate_key_header "podcast_episodes"
render template: "podcast_episodes/index"
end
@@ -182,6 +183,7 @@ class StoriesController < ApplicationController
def handle_podcast_show
set_surrogate_key_header @episode.record_key
+ @episode = @episode.decorate
@podcast_episode_show = true
@comments_to_show_count = 25
@comment = Comment.new
diff --git a/app/decorators/podcast_episode_decorator.rb b/app/decorators/podcast_episode_decorator.rb
index beae9647b..c95dac37e 100644
--- a/app/decorators/podcast_episode_decorator.rb
+++ b/app/decorators/podcast_episode_decorator.rb
@@ -8,4 +8,18 @@ class PodcastEpisodeDecorator < ApplicationDecorator
def cached_tag_list_array
(tag_list || "").split(", ")
end
+
+ def readable_publish_date
+ return unless published_at
+
+ if published_at.year == Time.current.year
+ published_at.strftime("%b %e")
+ else
+ published_at.strftime("%b %e '%y")
+ end
+ end
+
+ def published_timestamp
+ published_at&.utc&.iso8601
+ end
end
diff --git a/app/views/articles/_podcast_episodes_feed.html.erb b/app/views/articles/_podcast_episodes_feed.html.erb
deleted file mode 100644
index dd2352014..000000000
--- a/app/views/articles/_podcast_episodes_feed.html.erb
+++ /dev/null
@@ -1,24 +0,0 @@
-<% @podcast_episodes.each_with_index do |episode, i| %>
-
-
-
- <%= cl_image_tag(episode.image_url || episode.podcast.image_url,
- type: "fetch",
- crop: "imagga_scale",
- width: 240,
- height: 240,
- quality: "auto",
- flags: "progressive",
- fetch_format: "auto",
- sign_url: true,
- alt: episode.title) %>
-
-
-
podcast<%= episode.title %>
-
-
- <%= episode.podcast.title %>
-
-
-
-<% end %>
diff --git a/app/views/podcast_episodes/_episodes_feed.html.erb b/app/views/podcast_episodes/_episodes_feed.html.erb
index c823dc12e..fb10428c0 100644
--- a/app/views/podcast_episodes/_episodes_feed.html.erb
+++ b/app/views/podcast_episodes/_episodes_feed.html.erb
@@ -19,6 +19,12 @@
diff --git a/app/views/podcast_episodes/show.html.erb b/app/views/podcast_episodes/show.html.erb
index ffd7c957a..7998e7b13 100644
--- a/app/views/podcast_episodes/show.html.erb
+++ b/app/views/podcast_episodes/show.html.erb
@@ -50,6 +50,11 @@
<% else %>
<%= @episode.title %>
<% end %>
+ <% if @episode.published_at? %>
+
+ <% end %>
diff --git a/spec/system/podcasts/user_visits_podcast_episode_spec.rb b/spec/system/podcasts/user_visits_podcast_episode_spec.rb
index 8576aa3b6..bf43a3d48 100644
--- a/spec/system/podcasts/user_visits_podcast_episode_spec.rb
+++ b/spec/system/podcasts/user_visits_podcast_episode_spec.rb
@@ -8,6 +8,7 @@ RSpec.describe "User visits podcast show page", type: :system do
visit podcast_episode.path.to_s
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
@@ -38,6 +39,15 @@ RSpec.describe "User visits podcast show page", type: :system do
end
end
+ context "when podcast has publish_at field" do
+ let!(:podcast_episode) { create(:podcast_episode, podcast_id: podcast.id, published_at: 7.hours.ago) }
+
+ it "sees published at" do
+ visit podcast_episode.path.to_s
+ expect(page).to have_css ".published-at"
+ end
+ end
+
context "when there're existing comments" do
let(:user) { create(:user) }
let(:comment) { create(:comment, user_id: user.id, commentable: podcast_episode) }
diff --git a/spec/system/podcasts/user_visits_podcast_page_spec.rb b/spec/system/podcasts/user_visits_podcast_page_spec.rb
index 63f804e6b..a811f52a1 100644
--- a/spec/system/podcasts/user_visits_podcast_page_spec.rb
+++ b/spec/system/podcasts/user_visits_podcast_page_spec.rb
@@ -2,7 +2,7 @@ require "rails_helper"
RSpec.describe "User visits a podcast page", type: :system do
let(:podcast) { create(:podcast) }
- let!(:podcast_episode) { create(:podcast_episode, podcast_id: podcast.id) }
+ let!(:podcast_episode1) { create(:podcast_episode, podcast_id: podcast.id, published_at: 2.hours.ago) }
let!(:podcast_episode2) { create(:podcast_episode, podcast_id: podcast.id) }
let(:another_episode) { create(:podcast_episode, podcast: create(:podcast)) }
let(:user) { create(:user) }
@@ -19,8 +19,13 @@ RSpec.describe "User visits a podcast page", type: :system do
expect(page).to have_selector("div.single-article", visible: true, count: 2)
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)
+ end
+
it "displays correct episodes" do
- expect(page).to have_link(nil, href: podcast_episode.path)
+ expect(page).to have_link(nil, href: podcast_episode1.path)
expect(page).to have_link(nil, href: podcast_episode2.path)
expect(page).not_to have_link(nil, href: another_episode.path)
end
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 23e81f3d0..79d557b1d 100644
--- a/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb
+++ b/spec/system/podcasts/user_visits_podcasts_root_page_spec.rb
@@ -1,8 +1,9 @@
require "rails_helper"
RSpec.describe "User visits /pod page", type: :system do
- let!(:podcast_episode) { create(:podcast_episode) }
- let!(:podcast_episode2) { create(:podcast_episode) }
+ let!(:podcast_episode1) { create(:podcast_episode, published_at: 7.hours.ago) }
+ let!(:podcast_episode2) { create(:podcast_episode, published_at: 7.days.ago) }
+ let!(:podcast_episode3) { create(:podcast_episode) }
let(:podcast) { create(:podcast, reachable: true, published: false) }
let(:unpublished_podcast) { create(:podcast, reachable: false) }
let!(:un_podcast_episode) { create(:podcast_episode, podcast: podcast, reachable: false) }
@@ -12,8 +13,16 @@ RSpec.describe "User visits /pod page", type: :system do
it "displays the podcasts" do
within "#articles-list" do
- expect(page).to have_link(nil, href: podcast_episode.path)
+ expect(page).to have_link(nil, href: podcast_episode1.path)
expect(page).to have_link(nil, href: podcast_episode2.path)
+ expect(page).to have_link(nil, href: podcast_episode3.path)
+ end
+ end
+
+ it "displays the podcasts with published_at" do
+ within "#articles-list" do
+ expect(page).to have_selector("time.published-at", count: 2)
+ expect(page).to have_selector("span.time-ago-indicator-initial-placeholder", count: 2)
end
end