Skip to content

Commit 832fb20

Browse files
Ryan Florencejenseng
authored andcommitted
allow any url for mathquill fixes #8038
Change-Id: I41b5296fdd0d375fa291bdbebdcfd63b4e79b9d3 Reviewed-on: https://gerrit.instructure.com/9881 Reviewed-by: Jon Jensen <jon@instructure.com> Tested-by: Hudson <hudson@instructure.com>
1 parent 8cbd32c commit 832fb20

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

app/controllers/equation_images_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ class EquationImagesController < ApplicationController
22

33
# Facade to codecogs API so we retain control
44
def show
5+
# TODO: escape id here, and stop double escaping it in
6+
# public/javascripts/tinymce/jscripts/tiny_mce/plugins/instructure_equation/editor_plugin.js
7+
# this will require a corresponding data migration to fix
58
redirect_to 'http://latex.codecogs.com/gif.latex?' + params[:id]
69
end
710

8-
end
11+
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ def et_routes(route_object, context)
833833
lti.post "tools/:tool_id/ext_grade_passback", :controller => :lti_api, :action => :legacy_grade_passback, :path_name => "blti_legacy_grade_passback_api"
834834
end
835835

836-
map.resources :equation_images, :only => :show
836+
map.equation_images 'equation_images/:id', :controller => :equation_images, :action => :show, :id => /.+/
837837

838838
# assignments at the top level (without a context) -- we have some specs that
839839
# assert these routes exist, but just 404. I'm not sure we ever actually want

spec/selenium/wiki_and_tiny_spec.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
end
144144

145145
it "should add an equation to the rce by using the equation editor" do
146-
equation_text = '\\text{yay math stuff:}\\:\\frac{d}{dx}\\sqrt{x}=\\frac{d}{dx}x^{\\frac{1}{2}}=\\frac{1}{2}x^{-\\frac{1}{2}}=\\frac{1}{2\\sqrt{x}}'
146+
equation_text = '\\text{yay math stuff:}\\:\\frac{d}{dx}\\sqrt{x}=\\frac{d}{dx}x^{\\frac{1}{2}}=\\frac{1}{2}x^{-\\frac{1}{2}}=\\frac{1}{2\\sqrt{x}}\\text{that. is. so. cool.}'
147147

148148
get "/courses/#{@course.id}/wiki"
149149

@@ -175,10 +175,22 @@
175175
textarea.send_keys "=1/2"
176176
f('.mathquill-editor .mathquill-toolbar a[title="\\\\sqrt"]').click
177177
textarea.send_keys "x"
178+
textarea.send_keys :arrow_right
179+
textarea.send_keys :arrow_right
180+
textarea.send_keys "\\text that. is. so. cool."
178181
driver.find_element(:id, 'instructure_equation_prompt_form').submit
179182
wait_for_ajax_requests
180183
in_frame "wiki_page_body_ifr" do
181-
keep_trying_until { driver.find_element(:css, '.equation_image').attribute('title').should == equation_text }
184+
keep_trying_until { f('.equation_image').attribute('title').should == equation_text }
185+
186+
# currently there's an issue where the equation is double-escaped in the
187+
# src, though it's correct after the redirect to codecogs. here we just
188+
# want to confirm we redirect correctly. so when that bug is fixed, this
189+
# spec should still pass.
190+
src = f('.equation_image').attribute('src')
191+
response = Net::HTTP.get_response(URI.parse(src))
192+
response.code.should eql "302"
193+
response.header['location'].should include URI.encode(equation_text, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
182194
end
183195
end
184196

0 commit comments

Comments
 (0)