make routes work for media downloads
closes FOO-1186 flag=none discussion entries and announcements were generating a lot of failures TEST PLAN: 1) make a new discussion entry with a video embed. 2) notification should get sent, and it should have a media download url pointing at the course the topic lives in Change-Id: I888a8508bd18ac9e37727eab5ede9e7a0102f184 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/252278 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Rob Orton <rob@instructure.com> QA-Review: Ethan Vizitei <evizitei@instructure.com> Product-Review: Ethan Vizitei <evizitei@instructure.com>
This commit is contained in:
parent
0070f199be
commit
e6ae468af4
|
@ -91,11 +91,24 @@ module Api
|
|||
end
|
||||
|
||||
def media_context
|
||||
# not all objects are clean to find media urls for.
|
||||
# If the current context is one of those classes,
|
||||
# then we should look up what the actual context is that
|
||||
# would have a reasonable media url on it (usually a course).
|
||||
# If you are trying to do "media_redirect_url" on a context
|
||||
# where you're finding a media url helper doesn't exist, you probably
|
||||
# need to add a case here.
|
||||
case context
|
||||
when Group
|
||||
when Announcement
|
||||
context.context
|
||||
when CourseSection
|
||||
context.course
|
||||
when DiscussionTopic
|
||||
context.course
|
||||
when DiscussionEntry
|
||||
context.discussion_topic.course
|
||||
when Group
|
||||
context.context
|
||||
else
|
||||
context
|
||||
end
|
||||
|
|
|
@ -43,6 +43,25 @@ module Api
|
|||
it "passes through polymorphic urls" do
|
||||
expect(proxy.media_redirect_url("123", "video")).to eq("http://example.com/courses/1/media_download?entryId=123&media_type=video&redirect=1")
|
||||
end
|
||||
|
||||
it "has media redirect routes for discussion entries" do
|
||||
course = course_model
|
||||
topic = course.discussion_topics.create!
|
||||
entry = DiscussionEntry.new
|
||||
entry.id = 1
|
||||
entry.discussion_topic = topic
|
||||
proxy = UrlProxy.new(StubUrlHelper.new, entry, "example.com", "http")
|
||||
expect(proxy.media_redirect_url("123", "video")).to eq("http://example.com/courses/#{course.id}/media_download?entryId=123&media_type=video&redirect=1")
|
||||
end
|
||||
|
||||
it "can produce a redirect route for announcements" do
|
||||
course = course_model
|
||||
announcement = Announcement.new
|
||||
announcement.id = 1
|
||||
announcement.context = course
|
||||
proxy = UrlProxy.new(StubUrlHelper.new, announcement, "example.com", "http")
|
||||
expect(proxy.media_redirect_url("123", "video")).to eq("http://example.com/courses/#{course.id}/media_download?entryId=123&media_type=video&redirect=1")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#api_endpoint_info" do
|
||||
|
|
Loading…
Reference in New Issue