resubmit to scribd on inline view
test plan: 1. have an environment with scribd and google doc previews enabled 2. create a document, in a format compatible with both scribd and google docs (it needs to be a new document that isn't in scribd yet) 3. upload this document to a course 4. give a few minutes for scribd to process it 5. make sure the scribd preview works in the files tab 6. delete the file from the course 7. undelete the file (use /courses/X/undelete) 8. preview the file in the files tab; it should use google docs since the scribd doc was deleted 9. wait a few minutes (canvas noticed the file was scribdable but had no scribd doc when you previewed in the last step, and resubmitted it to scribd) and then reload the page 10. a subsequent preview should show up in scribd 11. in addition to the files tab, also test a. documents embedded in rich text via wiki sidebar b. student submissions in SpeedGrader (probably requires the console, because there's no undelete for user files) fixes CNVS-6774 Change-Id: Ic9fa5d43ef16522e1bd7a12d45f1f5dc7efbfe6f Reviewed-on: https://gerrit.instructure.com/22378 QA-Review: August Thornton <august@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com> Tested-by: Jenkins <jenkins@instructure.com>
This commit is contained in:
parent
9b961986f1
commit
b216585323
|
@ -281,7 +281,9 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if (params[:download] && params[:verifier] && params[:verifier] == @attachment.uuid) || authorized_action(@attachment, @current_user, :read)
|
if (params[:download] && params[:verifier] && params[:verifier] == @attachment.uuid) ||
|
||||||
|
@attachment.attachment_associations.where(:context_type => 'Submission').any? { |aa| aa.context.grants_right?(@current_user, session, :read) } ||
|
||||||
|
authorized_action(@attachment, @current_user, :read)
|
||||||
if params[:download]
|
if params[:download]
|
||||||
if (params[:verifier] && params[:verifier] == @attachment.uuid) || (@attachment.grants_right?(@current_user, session, :download))
|
if (params[:verifier] && params[:verifier] == @attachment.uuid) || (@attachment.grants_right?(@current_user, session, :download))
|
||||||
disable_page_views if params[:preview]
|
disable_page_views if params[:preview]
|
||||||
|
|
|
@ -1686,5 +1686,15 @@ class Attachment < ActiveRecord::Base
|
||||||
|
|
||||||
def record_inline_view
|
def record_inline_view
|
||||||
update_attribute(:last_inline_view, Time.now)
|
update_attribute(:last_inline_view, Time.now)
|
||||||
|
check_rerender_scribd_doc unless self.scribd_doc
|
||||||
|
end
|
||||||
|
|
||||||
|
def check_rerender_scribd_doc
|
||||||
|
if scribdable? && scribd_doc.nil?
|
||||||
|
self.scribd_attempts = 0
|
||||||
|
self.workflow_state = 'pending_upload'
|
||||||
|
self.save!
|
||||||
|
send_later :submit_to_scribd!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,7 +35,7 @@ define([
|
||||||
"application/vnd.sun.xml.writer": [1, 1],
|
"application/vnd.sun.xml.writer": [1, 1],
|
||||||
"application/excel": [1, 1],
|
"application/excel": [1, 1],
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [1, 1],
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [1, 1],
|
||||||
"text/rtf": [1, false],
|
"text/rtf": [1, 1],
|
||||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.template": [1, 1],
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.template": [1, 1],
|
||||||
"application/vnd.sun.xml.impress": [1, 1],
|
"application/vnd.sun.xml.impress": [1, 1],
|
||||||
"application/vnd.sun.xml.calc": [1, 1],
|
"application/vnd.sun.xml.calc": [1, 1],
|
||||||
|
@ -90,7 +90,7 @@ define([
|
||||||
// if I have a url to ping back to the app that I viewed this file inline, ping it.
|
// if I have a url to ping back to the app that I viewed this file inline, ping it.
|
||||||
if (opts.attachment_view_inline_ping_url) {
|
if (opts.attachment_view_inline_ping_url) {
|
||||||
$.ajaxJSON(opts.attachment_view_inline_ping_url, 'POST', {}, function() { }, function() { });
|
$.ajaxJSON(opts.attachment_view_inline_ping_url, 'POST', {}, function() { }, function() { });
|
||||||
$.trackEvent('Doc Previews', serviceUsed, JSON.stringify(opts));
|
$.trackEvent('Doc Previews', serviceUsed, JSON.stringify(opts, ['attachment_id', 'submission_id', 'mimetype', 'crocodoc_session_url', 'scribd_doc_id']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -304,6 +304,19 @@ describe FilesController do
|
||||||
@file.reload.last_inline_view.should > 1.minute.ago
|
@file.reload.last_inline_view.should > 1.minute.ago
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should record the inline view when a teacher previews a student's submission" do
|
||||||
|
course_with_student :active_all => true
|
||||||
|
@assignment = @course.assignments.create!(:title => 'upload_assignment', :submission_types => 'online_upload')
|
||||||
|
attachment_model :context => @student
|
||||||
|
@assignment.submit_homework @student, :attachments => [@attachment]
|
||||||
|
|
||||||
|
teacher_in_course :active_all => true
|
||||||
|
user_session @teacher
|
||||||
|
get 'show', :user_id => @student.id, :id => @attachment.id, :inline => 1
|
||||||
|
response.should be_success
|
||||||
|
@attachment.reload.last_inline_view.should > 1.minute.ago
|
||||||
|
end
|
||||||
|
|
||||||
it "should mark files as viewed for module progressions if the file data is requested and it includes the scribd_doc data" do
|
it "should mark files as viewed for module progressions if the file data is requested and it includes the scribd_doc data" do
|
||||||
file_in_a_module
|
file_in_a_module
|
||||||
@file.scribd_doc = Scribd::Document.new
|
@file.scribd_doc = Scribd::Document.new
|
||||||
|
|
|
@ -365,8 +365,15 @@ describe Attachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
context "scribd cleanup" do
|
context "scribd cleanup" do
|
||||||
def fake_scribd_doc(doc_id = String.random(8))
|
before do
|
||||||
ScribdAPI.stubs(:enabled?).returns(true)
|
ScribdAPI.stubs(:enabled?).returns(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
after do
|
||||||
|
ScribdAPI.unstub(:enabled?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def fake_scribd_doc(doc_id = String.random(8))
|
||||||
scribd_doc = Scribd::Document.new
|
scribd_doc = Scribd::Document.new
|
||||||
scribd_doc.doc_id = doc_id
|
scribd_doc.doc_id = doc_id
|
||||||
scribd_doc.secret_password = 'asdf'
|
scribd_doc.secret_password = 'asdf'
|
||||||
|
@ -375,7 +382,6 @@ describe Attachment do
|
||||||
end
|
end
|
||||||
|
|
||||||
def attachment_with_scribd_doc(doc = fake_scribd_doc, opts = {})
|
def attachment_with_scribd_doc(doc = fake_scribd_doc, opts = {})
|
||||||
ScribdAPI.stubs(:enabled?).returns(true)
|
|
||||||
att = attachment_model(opts)
|
att = attachment_model(opts)
|
||||||
att.scribd_doc = doc
|
att.scribd_doc = doc
|
||||||
att.save!
|
att.save!
|
||||||
|
@ -463,6 +469,45 @@ describe Attachment do
|
||||||
@child.read_attribute(:scribd_doc).should be_nil
|
@child.read_attribute(:scribd_doc).should be_nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "check_rerender_scribd_doc" do
|
||||||
|
before do
|
||||||
|
scribd_mime_type_model(:extension => 'docx')
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should resubmit a deleted scribd doc" do
|
||||||
|
@attachment = attachment_with_scribd_doc(fake_scribd_doc, :filename => 'file.docx', :scribd_attempts => 3)
|
||||||
|
@attachment.scribd_doc.expects(:destroy).once.returns(true)
|
||||||
|
@attachment.delete_scribd_doc
|
||||||
|
expect {
|
||||||
|
@attachment.check_rerender_scribd_doc
|
||||||
|
}.to change(Delayed::Job, :count).by(1)
|
||||||
|
Delayed::Job.find_by_tag('Attachment#submit_to_scribd!').should_not be_nil
|
||||||
|
@attachment.should be_pending_upload
|
||||||
|
@attachment.scribd_attempts.should == 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should do nothing if a scribd_doc already exists" do
|
||||||
|
@attachment = attachment_with_scribd_doc(fake_scribd_doc, :filename => 'file.docx')
|
||||||
|
expect {
|
||||||
|
@attachment.check_rerender_scribd_doc
|
||||||
|
}.to change(Delayed::Job, :count).by(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should be invoked on record_inline_view" do
|
||||||
|
@attachment = attachment_model(:filename => 'file.docx')
|
||||||
|
expect {
|
||||||
|
@attachment.record_inline_view
|
||||||
|
}.to change(Delayed::Job, :count).by(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should do nothing on non-scribdable types" do
|
||||||
|
@attachment = attachment_model(:filename => 'file.lolcats')
|
||||||
|
expect {
|
||||||
|
@attachment.check_rerender_scribd_doc
|
||||||
|
}.to change(Delayed::Job, :count).by(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "conversion_status" do
|
context "conversion_status" do
|
||||||
|
|
Loading…
Reference in New Issue