allow user to change immersive reader feature flag
closes MAT-254 flag=user_immersive_reader_wiki_pages This changes the feature flag for Microsoft Immersive Reader from an Account level flag to a Root Account one. This also adds a User level feature flag for the same feature. If the Root Account flag is on, then Immersive Reader will be on for the User regardless of the User flag. If not, then the User may turn it on themselves. Test Plan - Create a Page. - On master, set the root account Microsoft Immersive Reader flag to be enabled and locked. - Checkout this commit. - Verify that the Microsoft Immersive Reader flag is still on. - Verify that the Immersive Reader button is present on the Page as the student, regardless of their own feature flag state. - Switch to master and set Microsoft Immersive Reader to disabled and locked. - Checkout this commit. - Verify that the Microsoft Immersive Reader flag is off. - Verify that the Immersive Reader button is not present on the Page when the student's flag is off, and present when the student's flag is on. - Switch to master. - Set Microsoft Immersive Reader to Disabled+Unlocked at the SiteAdmin level. - Set Microsoft Immersive Reader to Enabled+Unlocked at the root account level. - Switch back to this commit. - Run the migration. - Verify that the Immersive Reader button is present on the Page as the student, regardless of their own feature flag state. Change-Id: I895a79d84aafae7fab59c6fe0be3b5ed4f52062e Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/267695 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
48e4c24049
commit
00d15ab97e
|
@ -2826,7 +2826,6 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
helper_method :show_student_view_button?
|
||||
|
||||
|
||||
def show_immersive_reader?
|
||||
controller_action = "#{params[:controller]}##{params[:action]}"
|
||||
immersive_reader_pages = if Account.site_admin.feature_enabled?(:more_immersive_reader)
|
||||
|
@ -2837,7 +2836,8 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
return false unless immersive_reader_pages.include?(controller_action)
|
||||
|
||||
@context&.account&.feature_enabled?(:immersive_reader_wiki_pages)
|
||||
@context&.root_account&.feature_enabled?(:immersive_reader_wiki_pages) ||
|
||||
@current_user&.feature_enabled?(:user_immersive_reader_wiki_pages)
|
||||
end
|
||||
helper_method :show_immersive_reader?
|
||||
|
||||
|
|
|
@ -5,11 +5,17 @@ immersive_reader_wiki_pages:
|
|||
display_name: Microsoft Immersive Reader
|
||||
description: |-
|
||||
Makes a Microsoft Immersive Reader link option show up on wiki pages.
|
||||
applies_to: Account
|
||||
root_opt_in: true
|
||||
applies_to: RootAccount
|
||||
more_immersive_reader:
|
||||
state: hidden
|
||||
display_name: More Microsoft Immersive Reader
|
||||
description: |-
|
||||
Makes Microsoft Immersive Reader appear in more supported areas.
|
||||
applies_to: SiteAdmin
|
||||
user_immersive_reader_wiki_pages:
|
||||
state: allowed
|
||||
display_name: Microsoft Immersive Reader
|
||||
description: Enables the Microsoft Immersive Reader button in supported areas
|
||||
of Canvas. The button may still be enabled in a course regardless of this
|
||||
setting if the account administrator has turned it on for all users.
|
||||
applies_to: User
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2021 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
class ChangeImmersiveReaderAllowedOnToOn < ActiveRecord::Migration[6.0]
|
||||
tag :postdeploy
|
||||
|
||||
def self.up
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
end
|
||||
|
||||
def self.down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2021 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
module DataFixup::ChangeImmersiveReaderAllowedOnToOn
|
||||
def self.run
|
||||
# Site Admin has the flag as STATE_DEFAULT_OFF, but just in case, ignore it here.
|
||||
root_accounts_scope = if Account.site_admin&.shard == Shard.current
|
||||
Account.root_accounts.active.where.not(id: Account.site_admin.id)
|
||||
else
|
||||
Account.root_accounts.active
|
||||
end
|
||||
|
||||
allowed_on_flags = FeatureFlag.where(
|
||||
context_id: root_accounts_scope,
|
||||
context_type: "Account",
|
||||
feature: :immersive_reader_wiki_pages,
|
||||
state: Feature::STATE_DEFAULT_ON
|
||||
)
|
||||
|
||||
allowed_on_flags.update_all(state: Feature::STATE_ON, updated_at: Time.zone.now)
|
||||
end
|
||||
end
|
|
@ -2060,17 +2060,7 @@ describe ApplicationController do
|
|||
controller.instance_variable_set(:@current_user, @student)
|
||||
end
|
||||
|
||||
it "is false when no immersive reader flags are enabled, even on supported pages" do
|
||||
controller.params[:controller] = "wiki_pages"
|
||||
controller.params[:action] = "show"
|
||||
expect(controller.send(:show_immersive_reader?)).to be false
|
||||
end
|
||||
|
||||
context "when root account has immersive reader flag enabled" do
|
||||
before(:once) do
|
||||
@course.root_account.enable_feature!(:immersive_reader_wiki_pages)
|
||||
end
|
||||
|
||||
shared_examples_for "pages with an immersive reader flag enabled" do
|
||||
it "is true for wiki_pages#show" do
|
||||
controller.params[:controller] = "wiki_pages"
|
||||
controller.params[:action] = "show"
|
||||
|
@ -2078,8 +2068,8 @@ describe ApplicationController do
|
|||
end
|
||||
|
||||
it "is false on pages where immersive reader is not supported" do
|
||||
controller.params[:controller] = "courses"
|
||||
controller.params[:action] = "show"
|
||||
controller.params[:controller] = "discussion_topics"
|
||||
controller.params[:action] = "index"
|
||||
expect(controller.send(:show_immersive_reader?)).to be false
|
||||
end
|
||||
|
||||
|
@ -2119,6 +2109,28 @@ describe ApplicationController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "is false when no immersive reader flags are enabled, even on supported pages" do
|
||||
controller.params[:controller] = "wiki_pages"
|
||||
controller.params[:action] = "show"
|
||||
expect(controller.send(:show_immersive_reader?)).to be false
|
||||
end
|
||||
|
||||
context "when root account has immersive reader flag enabled" do
|
||||
before(:once) do
|
||||
@course.root_account.enable_feature!(:immersive_reader_wiki_pages)
|
||||
end
|
||||
|
||||
it_behaves_like "pages with an immersive reader flag enabled"
|
||||
end
|
||||
|
||||
context "when user has immersive reader flag enabled" do
|
||||
before(:each) do
|
||||
@student.enable_feature!(:user_immersive_reader_wiki_pages)
|
||||
end
|
||||
|
||||
it_behaves_like "pages with an immersive reader flag enabled"
|
||||
end
|
||||
end
|
||||
|
||||
describe "new math equation handling feature" do
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
#
|
||||
# Copyright (C) 2021 - present Instructure, Inc.
|
||||
#
|
||||
# This file is part of Canvas.
|
||||
#
|
||||
# Canvas is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the Free
|
||||
# Software Foundation, version 3 of the License.
|
||||
#
|
||||
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
# details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License along
|
||||
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require "spec_helper"
|
||||
|
||||
describe DataFixup::ChangeImmersiveReaderAllowedOnToOn do
|
||||
describe ".run" do
|
||||
def set_immersive_reader_flag(account, state)
|
||||
FeatureFlag.find_or_create_by(
|
||||
context_id: account.id,
|
||||
context_type: "Account",
|
||||
feature: "immersive_reader_wiki_pages",
|
||||
state: state
|
||||
)
|
||||
end
|
||||
|
||||
context "when the account is the SiteAdmin account" do
|
||||
let(:account) { Account.site_admin }
|
||||
|
||||
before do
|
||||
@flag = set_immersive_reader_flag(account, Feature::STATE_DEFAULT_ON)
|
||||
end
|
||||
|
||||
it "leaves the feature flag in its current state" do
|
||||
expect {
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
}.not_to change {
|
||||
@flag.reload.state
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "when a root account has immersive_reader_wiki_pages allowed and off" do
|
||||
let(:account) { Account.create! }
|
||||
|
||||
before do
|
||||
@flag = set_immersive_reader_flag(account, Feature::STATE_DEFAULT_OFF)
|
||||
end
|
||||
|
||||
it "leaves the feature flag as disabled" do
|
||||
expect {
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
}.not_to change {
|
||||
@flag.reload.state
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "when a root account has immersive_reader_wiki_pages allowed and on" do
|
||||
let(:account) { Account.create! }
|
||||
|
||||
before do
|
||||
@flag = set_immersive_reader_flag(account, Feature::STATE_DEFAULT_ON)
|
||||
end
|
||||
|
||||
it "changes the feature flag to enabled" do
|
||||
expect {
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
}.to change {
|
||||
@flag.reload.state
|
||||
}.from(Feature::STATE_DEFAULT_ON).to(Feature::STATE_ON)
|
||||
end
|
||||
end
|
||||
|
||||
context "when a root account has immersive_reader_wiki_pages off" do
|
||||
let(:account) { Account.create! }
|
||||
|
||||
before do
|
||||
@flag = set_immersive_reader_flag(account, Feature::STATE_OFF)
|
||||
end
|
||||
|
||||
it "leaves the feature flag as disabled" do
|
||||
expect {
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
}.not_to change {
|
||||
@flag.reload.state
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
context "when a root account has immersive_reader_wiki_pages on" do
|
||||
let(:account) { Account.create! }
|
||||
|
||||
before do
|
||||
@flag = set_immersive_reader_flag(account, Feature::STATE_ON)
|
||||
end
|
||||
|
||||
it "leaves the feature flag as enabled" do
|
||||
expect {
|
||||
DataFixup::ChangeImmersiveReaderAllowedOnToOn.run
|
||||
}.not_to change {
|
||||
@flag.reload.state
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue