fix media_type for media submission comments
fix the response media_type to be either video or audio instead of the specific mime type when the below api endpoint is called api/v1/courses/courseId:/assignments/assignmentId:/submissions fixes MBL-17110 flag=assignments_2_student test plan: - have a course with an assignment and the Assignment Enhancements fla on - add a media comment as a student to the assignment - send a GET request to the following endpoint: api/v1/courses/:course_id/assignments/:assignment_id/submissions ?include%5B%5D=submission_comments - find the submission with the media comment - find the specific comment under the field "submission_comments" - the comment will have a "media_comment" field in the comment - confirm that the media_comment object has a field "media_type" that has just video or audio instead of the specific MIME type such as video/quicktime Change-Id: I32da86c9934ca8955561b3e57262e8b81500c0bc Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/330653 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Derek Williams <derek.williams@instructure.com> Reviewed-by: Christopher Soto <christopher.soto@instructure.com> QA-Review: Kai Bjorkman <kbjorkman@instructure.com> Product-Review: Ravi Koll <ravi.koll@instructure.com>
This commit is contained in:
parent
d08a86870e
commit
93b7edab6c
|
@ -541,11 +541,12 @@ module Api
|
|||
|
||||
def media_comment_json(media_object_or_hash)
|
||||
media_object_or_hash = OpenStruct.new(media_object_or_hash) if media_object_or_hash.is_a?(Hash)
|
||||
convert_media_type = Attachment.mime_class(media_object_or_hash.media_type)
|
||||
{
|
||||
"content-type" => "#{media_object_or_hash.media_type}/mp4",
|
||||
"content-type" => "#{convert_media_type}/mp4",
|
||||
"display_name" => media_object_or_hash.title.presence || media_object_or_hash.user_entered_title,
|
||||
"media_id" => media_object_or_hash.media_id,
|
||||
"media_type" => media_object_or_hash.media_type,
|
||||
"media_type" => convert_media_type,
|
||||
"url" => user_media_download_url(user_id: @current_user.id,
|
||||
entryId: media_object_or_hash.media_id,
|
||||
type: "mp4",
|
||||
|
|
|
@ -21,6 +21,23 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe Api::V1::SubmissionComment do
|
||||
subject(:fake_controller) do
|
||||
Class.new do
|
||||
include Api
|
||||
include Api::V1::Submission
|
||||
include Api::V1::SubmissionComment
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
attr_writer :current_user
|
||||
|
||||
private
|
||||
|
||||
def default_url_options
|
||||
{ host: :localhost }
|
||||
end
|
||||
end.new
|
||||
end
|
||||
|
||||
before(:once) do
|
||||
course = Course.create!
|
||||
@student = User.create!
|
||||
|
@ -47,6 +64,22 @@ describe Api::V1::SubmissionComment do
|
|||
it "'edited_at' is nil if the submission comment has not been edited" do
|
||||
expect(comment_json[:edited_at]).to be_nil
|
||||
end
|
||||
|
||||
it "media_type in submission comment json has video instead of the specific mime type" do
|
||||
@submission_comment.media_comment_id = 1
|
||||
@submission_comment.media_comment_type = "video/mp4"
|
||||
fake_controller.current_user = @student
|
||||
submission_comment_json = fake_controller.submission_comment_json(@submission_comment, @student)
|
||||
expect(submission_comment_json["media_comment"]["media_type"]).to eq("video")
|
||||
end
|
||||
|
||||
it "media_type in submission comment json has audio instead of the specific mime type" do
|
||||
@submission_comment.media_comment_id = 1
|
||||
@submission_comment.media_comment_type = "audio/mp4"
|
||||
fake_controller.current_user = @student
|
||||
submission_comment_json = fake_controller.submission_comment_json(@submission_comment, @student)
|
||||
expect(submission_comment_json["media_comment"]["media_type"]).to eq("audio")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#anonymous_moderated_submission_comments_json" do
|
||||
|
|
|
@ -575,6 +575,15 @@ describe Api::V1::Submission do
|
|||
expect(submission).to be_read(user)
|
||||
end
|
||||
end
|
||||
|
||||
it "submission json returns video when media comment type is a specific video mime type" do
|
||||
submission = assignment.submission_for_student(user)
|
||||
submission.media_comment_id = 1
|
||||
submission.media_comment_type = "video/mp4"
|
||||
fake_controller.current_user = user
|
||||
submission_json = fake_controller.submission_json(submission, assignment, user, session, context)
|
||||
expect(submission_json.fetch("media_comment")["media_type"]).to eq "video"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#submission_zip" do
|
||||
|
|
Loading…
Reference in New Issue