data fixup for MC LTI tool

closes LS-1182
flag = submission_type_tool_placement

Test Plan:
- spec runs ok

Change-Id: I36eb9050e9dc4114cad87ebf4101413d69d7b93e
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/242136
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Robin Kuss <rkuss@instructure.com>
Product-Review: Clint Furse <cfurse@instructure.com>
This commit is contained in:
Clint Furse 2020-07-07 11:36:18 -06:00
parent 42cb2c1529
commit 54212b43da
3 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#
# Copyright (C) 2020 - 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 UpdateMasteryConnectToolConfig < ActiveRecord::Migration[5.2]
tag :postdeploy
disable_ddl_transaction!
def up
DataFixup::UpdateMasteryConnectToolConfig.send_later_if_production_enqueue_args(
:run,
{
:priority => Delayed::LOWER_PRIORITY,
:strand => "mc_tool_config_update_#{Shard.current.database_server.id}"
}
)
end
def down; end
end

View File

@ -0,0 +1,32 @@
#
# Copyright (C) 2020 - 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::UpdateMasteryConnectToolConfig
def self.run
ContextExternalTool.active.where(domain: 'app.masteryconnect.com').find_each do |cet|
next if cet.settings['submission_type_selection']
cet.settings['submission_type_selection'] = {
"text" => "Link Assessment",
"url" => "https://app.masteryconnect.com/lti/v1.1/launch/classrooms",
"message_type" => "ContentItemSelectionRequest",
"selection_width" => 720,
"selection_height" => 700
}
cet.save!
end
end
end

View File

@ -0,0 +1,64 @@
#
# Copyright (C) 2020 - 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_relative '../../spec_helper'
describe DataFixup::UpdateMasteryConnectToolConfig do
before :once do
course_model
end
describe 'context_external_tool' do
it 'contains the correct settings after the fixup' do
tool = external_tool_model(context: @course, opts: { domain: 'app.masteryconnect.com' })
DataFixup::UpdateMasteryConnectToolConfig.run
tool.reload
expect(tool.settings).to include("submission_type_selection")
end
it 'does not modify settings if not mastery connect tool' do
tool = external_tool_model(context: @course, opts: { domain: 'some.other.tool.com' })
DataFixup::UpdateMasteryConnectToolConfig.run
tool.reload
expect(tool.settings).not_to include("submission_type_selection")
end
it 'does not modify settings if placement already exists' do
settings = {
"submission_type_selection" => {
foo: 'bar'
}
}
tool = external_tool_model(context: @course, opts: { domain: 'app.masteryconnect.com', settings: settings })
DataFixup::UpdateMasteryConnectToolConfig.run
tool.reload
expect(tool.settings).to eq(settings)
end
it 'updates multiple installs of the mastery connect tool' do
tool1 = external_tool_model(context: @course, opts: { domain: 'app.masteryconnect.com' })
tool2 = external_tool_model(context: @course, opts: { domain: 'app.masteryconnect.com' })
DataFixup::UpdateMasteryConnectToolConfig.run
tool1.reload
tool2.reload
expect(tool1.settings).to include("submission_type_selection")
expect(tool2.settings).to include("submission_type_selection")
end
end
end