set new math ENV.FEATURES flag based on root account, not site_admin
closes LS-1939 flag=none we moved the flag, but didn't update the checks. test plan: - enable new_math_equation_handling in site admin - disable in your root account - load any page but quiz edit or question banks in canvas > expect ENV.FEATURES.new_math_equation_handling to be false - enable the feature in your root account and load a page > expect ENV.FEATURES.new_math_equation_handling to be true - create a quiz, - include a comment with a math equation from the eq editor on one of the question answer's comments - on the quiz' edit page, check "show question details" > expect the equation in the answer's comment to be the equation and not MathJax output Change-Id: If85bc04733d9bbc4e3ee1676350f5411422198fc Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/259562 Reviewed-by: Jeff Largent <jeff.largent@instructure.com> QA-Review: Jeff Largent <jeff.largent@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Product-Review: Ed Schiebel <eschiebel@instructure.com>
This commit is contained in:
parent
94ad92fdb9
commit
4905c39397
|
@ -528,6 +528,16 @@ class ApplicationController < ActionController::Base
|
|||
prepend_view_path(path)
|
||||
end
|
||||
|
||||
# the way classic quizzes copies question data from the page into the
|
||||
# edit form causes the elements added for a11y to get duplicated
|
||||
# and other misadventures that caused 4 hotfixes in 3 days.
|
||||
# Let's just not use the new math handling there.
|
||||
def use_new_math_equation_handling?
|
||||
@domain_root_account&.feature_enabled?(:new_math_equation_handling) &&
|
||||
!(params[:controller] == "quizzes/quizzes" && params[:action] == "edit") &&
|
||||
params[:controller] != "question_banks"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# we track the cost of each request in RequestThrottle in order
|
||||
|
@ -2219,16 +2229,6 @@ class ApplicationController < ActionController::Base
|
|||
true
|
||||
end
|
||||
|
||||
# the way classic quizzes copies question data from the page into the
|
||||
# edit form causes the elements added for a11y to get duplicated
|
||||
# and other misadventures that caused 4 hotfixes in 3 days.
|
||||
# Let's just not use the new math handling there.
|
||||
def use_new_math_equation_handling?
|
||||
Account.site_admin.feature_enabled?(:new_math_equation_handling) &&
|
||||
!(params[:controller] == "quizzes/quizzes" && params[:action] == "edit") &&
|
||||
params[:controller] != "question_banks"
|
||||
end
|
||||
|
||||
def destroy_session
|
||||
logger.info "Destroying session: #{session[:session_id]}"
|
||||
@pseudonym_session.destroy rescue true
|
||||
|
|
|
@ -411,8 +411,7 @@ module QuizzesHelper
|
|||
html = hash_get(hash, "#{field}_html".to_sym)
|
||||
|
||||
if html
|
||||
use_new_math = Account.site_admin.feature_enabled?(:new_math_equation_handling) && action_name != "edit"
|
||||
UserContent.escape(Sanitize.clean(html, CanvasSanitize::SANITIZE), nil, use_new_math)
|
||||
UserContent.escape(Sanitize.clean(html, CanvasSanitize::SANITIZE), nil, controller.try(:use_new_math_equation_handling?))
|
||||
else
|
||||
hash_get(hash, field)
|
||||
end
|
||||
|
|
|
@ -1930,6 +1930,36 @@ describe ApplicationController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "new math equation handling feature" do
|
||||
let(:root_account) {Account.default}
|
||||
|
||||
before(:each) do
|
||||
controller.instance_variable_set(:@domain_root_account, root_account)
|
||||
end
|
||||
|
||||
it "should put false in ENV when disabled at site_admin" do
|
||||
Account.site_admin.disable_feature!(:new_math_equation_handling)
|
||||
expect(@controller.use_new_math_equation_handling?).to be_falsey
|
||||
expect(@controller.js_env[:FEATURES][:new_math_equation_handling]).to be_falsey
|
||||
end
|
||||
|
||||
it "should put false in ENV when enabled at site_admin but disabled at the root account" do
|
||||
Account.site_admin.enable_feature!(:new_math_equation_handling)
|
||||
root_account.disable_feature!(:new_math_equation_handling)
|
||||
expect(@controller.use_new_math_equation_handling?).to be_falsey
|
||||
expect(@controller.js_env[:FEATURES][:new_math_equation_handling]).to be_falsey
|
||||
end
|
||||
|
||||
it "should put true in ENV when enabled at site_admin and the root account" do
|
||||
Account.site_admin.enable_feature!(:new_math_equation_handling)
|
||||
root_account.enable_feature!(:new_math_equation_handling)
|
||||
expect(@controller.use_new_math_equation_handling?).to be_truthy
|
||||
expect(@controller.js_env[:FEATURES][:new_math_equation_handling]).to be_truthy
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe WikiPagesController do
|
||||
|
|
|
@ -548,5 +548,15 @@ describe QuizzesHelper do
|
|||
expect(comment).to match(/MathML/)
|
||||
expect(comment).to match(/∐/)
|
||||
end
|
||||
|
||||
it 'does not add MathML if new math handling feature is active' do
|
||||
def controller.use_new_math_equation_handling?
|
||||
true
|
||||
end
|
||||
comment = comment_get({
|
||||
foo_html: '<img class="equation_image" data-equation-content="\coprod"></img>'
|
||||
}, 'foo')
|
||||
expect(comment).to eq('<img class="equation_image" data-equation-content="\\coprod">')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue