diff --git a/app/views/comments/index.html.erb b/app/views/comments/index.html.erb index e0849e742..c3883dda8 100644 --- a/app/views/comments/index.html.erb +++ b/app/views/comments/index.html.erb @@ -48,7 +48,7 @@ <% end %>

<%= @commentable.title %>

- <%= @commentable.user.name %> + <%= @commentable.is_a?(PodcastEpisode) ? @commentable.podcast.name : @commentable.user.name %> <%= "on " + @commentable.published_at.strftime("%B %d, %Y") if @commentable.published_at %>

diff --git a/spec/system/comments/user_views_podcast_comments_spec.rb b/spec/system/comments/user_views_podcast_comments_spec.rb new file mode 100644 index 000000000..837f479a4 --- /dev/null +++ b/spec/system/comments/user_views_podcast_comments_spec.rb @@ -0,0 +1,17 @@ +require "rails_helper" + +RSpec.describe "viewing podcast comments", type: :system, js: true do + let(:user) { create(:user) } + let(:podcast) { create(:podcast, creator: user) } + let(:podcast_episode) { create(:podcast_episode, podcast: podcast) } + let(:comment) { create(:comment, commentable: podcast_episode, user: user) } + + before do + sign_in user + visit "/#{podcast.slug}/#{podcast_episode.slug}/comments" + end + + it "renders comment" do + expect(page).to have_content(comment.body_html) + end +end