add file name in blank anchor tags in imported cc content
test plan: * import a cc package with blank file anchor tags in html content * they should be visible because they are now populated with the file name closes #LA-1020 Change-Id: I82adb68a01b134ecf29ee4db6dde11487b8b186c Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/237443 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Jeremy Stanley <jeremy@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
36d928d72a
commit
941f5997a9
|
@ -94,6 +94,7 @@ module CC::Importer::Standard
|
|||
end
|
||||
|
||||
def find_file_migration_id(path)
|
||||
return unless path.present?
|
||||
mig_id = @file_path_migration_id[path] || @file_path_migration_id[path.gsub(%r{\$[^$]*\$|\.\./}, '')] ||
|
||||
@file_path_migration_id[path.gsub(%r{\$[^$]*\$|\.\./}, '').sub(WEB_RESOURCES_FOLDER + '/', '')]
|
||||
|
||||
|
@ -167,6 +168,10 @@ module CC::Importer::Standard
|
|||
val.gsub!(FILEBASE_REGEX, '')
|
||||
if new_url = get_canvas_att_replacement_url(val, resource_dir)
|
||||
node[attr] = URI::escape(new_url)
|
||||
|
||||
if node.text.strip.blank? && !node.at_css("img") # add in the filename if the link is blank and doesn't have something visible like an image
|
||||
node.inner_html = HtmlTextHelper.escape_html(File.basename(val)) + (node.inner_html || "")
|
||||
end
|
||||
end
|
||||
else
|
||||
if ImportedHtmlConverter.relative_url?(val)
|
||||
|
|
Binary file not shown.
|
@ -717,4 +717,16 @@ describe "other cc files" do
|
|||
expect(@course.reload.syllabus_body).to include("<p>beep beep</p>")
|
||||
end
|
||||
end
|
||||
|
||||
describe "empty file link name inference" do
|
||||
it "should add the file name to empty links in html content" do
|
||||
import_cc_file("cc_empty_link.zip")
|
||||
assmt = @course.assignments.where(:migration_id => "assignment1").first
|
||||
file = @course.attachments.where(:migration_id => "file1").first
|
||||
doc = Nokogiri::HTML::DocumentFragment.parse(assmt.description)
|
||||
link = doc.at_css("a")
|
||||
expect(link.attr('href')).to include("courses/#{@course.id}/files/#{file.id}")
|
||||
expect(link.text.strip).to eq file.display_name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue