Add root account association to external tools

Refs PLAT-4483

Test Plan:
Run migrations and verify you can set the
root_account association of a context external
tool

Change-Id: I77ead138f7e589f8a590536807e730140dfdebf9
Reviewed-on: https://gerrit.instructure.com/193854
Reviewed-by: Marc Phillips <mphillips@instructure.com>
Reviewed-by: Rob Orton <rob@instructure.com>
Reviewed-by: Drake Harper <dharper@instructure.com>
Tested-by: Jenkins
Product-Review: Marc Phillips <mphillips@instructure.com>
QA-Review: Marc Phillips <mphillips@instructure.com>
This commit is contained in:
wdransfield 2019-05-16 08:20:09 -06:00 committed by Weston Dransfield
parent 9d8e9127ca
commit 44bcb7a849
3 changed files with 34 additions and 1 deletions

View File

@ -24,6 +24,7 @@ class ContextExternalTool < ActiveRecord::Base
belongs_to :context, polymorphic: [:course, :account]
belongs_to :developer_key
belongs_to :root_account, class_name: 'Account'
include MasterCourses::Restrictor
restrict_columns :content, [:name, :description]

View File

@ -0,0 +1,27 @@
#
# Copyright (C) 2019 - 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 AddRootAccountIdToContextExternalTools < ActiveRecord::Migration[5.1]
tag :predeploy
disable_ddl_transaction!
def change
add_column :context_external_tools, :root_account_id, :integer, limit: 8
add_index :context_external_tools, :root_account_id, algorithm: :concurrently
end
end

View File

@ -35,13 +35,18 @@ describe ContextExternalTool do
shared_secret: 'secret',
name: 'test tool',
url: 'http://www.tool.com/launch',
developer_key: developer_key
developer_key: developer_key,
root_account: @root_account
)
end
it 'allows setting the developer key' do
expect(tool.developer_key).to eq developer_key
end
it 'allows setting the root account' do
expect(tool.root_account).to eq @root_account
end
end
describe '#login_or_launch_url' do