encapsulate rss_links logic to method
flag=react_discussions_post refs VICE-2087 Test Plan: - Specs pass Also added a test for existing logic, that .atom links, have always rendered. Change-Id: Ie6e080058d43dee476d96667bef21fdd3d445f87 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/275159 Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: Rob Orton <rob@instructure.com> Product-Review: Rob Orton <rob@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
This commit is contained in:
parent
3ef09eed34
commit
e3cde4c472
|
@ -650,18 +650,7 @@ class DiscussionTopicsController < ApplicationController
|
|||
|
||||
if (can_read_and_visible = @topic.grants_right?(@current_user, session, :read) && @topic.visible_for?(@current_user))
|
||||
@topic.change_read_state('read', @current_user) unless @locked.is_a?(Hash) && !@locked[:can_view]
|
||||
rss_context = @context_enrollment
|
||||
rss_context ||= @context if @context.available?
|
||||
if rss_context
|
||||
content_for_head helpers.auto_discovery_link_tag(:atom,
|
||||
feeds_topic_format_path(@topic.id, rss_context.feed_code, :atom),
|
||||
{ title: t(:discussion_atom_feed_title, "Discussion Atom Feed") })
|
||||
if @topic.podcast_enabled
|
||||
content_for_head helpers.auto_discovery_link_tag(:rss,
|
||||
feeds_topic_format_path(@topic.id, rss_context.feed_code, :rss),
|
||||
{ title: t(:discussion_podcast_feed_title, "Discussion Podcast Feed") })
|
||||
end
|
||||
end
|
||||
add_rss_links_to_content
|
||||
end
|
||||
|
||||
if @context.is_a?(Course) && @context.grants_right?(@current_user, session, :manage)
|
||||
|
@ -1568,6 +1557,21 @@ class DiscussionTopicsController < ApplicationController
|
|||
|
||||
private
|
||||
|
||||
def add_rss_links_to_content
|
||||
rss_context = @context_enrollment
|
||||
rss_context ||= @context if @context.available?
|
||||
if rss_context
|
||||
content_for_head helpers.auto_discovery_link_tag(:atom,
|
||||
feeds_topic_format_path(@topic.id, rss_context.feed_code, :atom),
|
||||
{ title: t(:discussion_atom_feed_title, "Discussion Atom Feed") })
|
||||
if @topic.podcast_enabled
|
||||
content_for_head helpers.auto_discovery_link_tag(:rss,
|
||||
feeds_topic_format_path(@topic.id, rss_context.feed_code, :rss),
|
||||
{ title: t(:discussion_podcast_feed_title, "Discussion Podcast Feed") })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def groups_and_group_topics
|
||||
@groups = @topic.group_category.groups.active
|
||||
if @topic.for_assignment? && @topic.assignment.only_visible_to_overrides?
|
||||
|
|
|
@ -412,7 +412,7 @@ describe DiscussionTopicsController do
|
|||
end
|
||||
|
||||
context "podcast_enabled" do
|
||||
it "adds podcast_url to header" do
|
||||
it "adds Discussion Podcast Feed to header" do
|
||||
discussion.podcast_enabled = true
|
||||
discussion.save
|
||||
|
||||
|
@ -421,6 +421,12 @@ describe DiscussionTopicsController do
|
|||
expect(response.to_a.to_s).to include("Discussion Podcast Feed")
|
||||
end
|
||||
end
|
||||
|
||||
it "adds Discussion Atom Feed to header" do
|
||||
subject
|
||||
expect(response.to_a.to_s).to match(/.+enrollment.+\.atom/)
|
||||
expect(response.to_a.to_s).to include("Discussion Atom Feed")
|
||||
end
|
||||
end
|
||||
|
||||
context 'section specific announcements' do
|
||||
|
|
Loading…
Reference in New Issue