create tool_setting and tool_link models
fixes PLAT-600 test-plan: specs pass Change-Id: Ic7168bb5cca194b16b3c7f92ea51584ba9e747e7 Reviewed-on: https://gerrit.instructure.com/39714 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brad Humphrey <brad@instructure.com> Product-Review: Nathan Mills <nathanm@instructure.com> QA-Review: Nathan Mills <nathanm@instructure.com>
This commit is contained in:
parent
b55992e8ac
commit
0a7d44b815
|
@ -24,6 +24,7 @@ module Lti
|
|||
belongs_to :tool_proxy, class_name: 'Lti::ToolProxy'
|
||||
has_many :message_handlers, class_name: 'Lti::MessageHandler', :foreign_key => :resource_handler_id
|
||||
has_many :placements, class_name: 'Lti::ResourcePlacement'
|
||||
has_many :tool_links, :class_name => 'Lti::ToolLink'
|
||||
|
||||
serialize :icon_info
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
# Copyright (C) 2014 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 Lti
|
||||
class ToolLink < ActiveRecord::Base
|
||||
belongs_to :resource_handler, class_name: 'Lti::ResourceHandler'
|
||||
has_one :tool_setting, :class_name => 'Lti::ToolSetting', as: :settable
|
||||
|
||||
attr_accessible :uuid
|
||||
|
||||
after_initialize { self.uuid = SecureRandom::uuid}
|
||||
|
||||
end
|
||||
end
|
|
@ -27,6 +27,7 @@ module Lti
|
|||
belongs_to :context, :polymorphic => true
|
||||
|
||||
belongs_to :product_family, class_name: 'Lti::ProductFamily'
|
||||
has_one :tool_setting, :class_name => 'Lti::ToolSetting', as: :settable
|
||||
|
||||
serialize :raw_data
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ module Lti
|
|||
belongs_to :tool_proxy, class_name: 'Lti::ToolProxy'
|
||||
validates_inclusion_of :context_type, :allow_nil => true, :in => ['Course', 'Account']
|
||||
belongs_to :context, :polymorphic => true
|
||||
has_one :tool_setting, :class_name => 'Lti::ToolSetting', as: :settable
|
||||
|
||||
validates_presence_of :tool_proxy, :context
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# Copyright (C) 2014 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 Lti
|
||||
class ToolSetting < ActiveRecord::Base
|
||||
belongs_to :settable, polymorphic: true
|
||||
|
||||
serialize :custom
|
||||
end
|
||||
end
|
|
@ -0,0 +1,25 @@
|
|||
class AddLtiToolSettings < ActiveRecord::Migration
|
||||
tag :predeploy
|
||||
|
||||
def self.up
|
||||
create_table :lti_tool_settings do |t|
|
||||
t.integer :settable_id, limit: 8, null: false
|
||||
t.string :settable_type, null: false
|
||||
t.text :custom
|
||||
end
|
||||
|
||||
create_table :lti_tool_links do |t|
|
||||
t.integer :resource_handler_id, limit: 8, null: false
|
||||
t.string :uuid, null: false
|
||||
end
|
||||
|
||||
add_index :lti_tool_links, :uuid, unique: true
|
||||
add_index :lti_tool_settings, [:settable_id, :settable_type], unique: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
drop_table :lti_tool_settings
|
||||
drop_table :lti_tool_links
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,64 @@
|
|||
#
|
||||
# Copyright (C) 2014 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 File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
||||
|
||||
module Lti
|
||||
describe ToolLink do
|
||||
|
||||
let (:account) { Account.create }
|
||||
let (:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) }
|
||||
let (:resource_handler) { ResourceHandler.create(resource_type_code: 'code', name: 'resource name', tool_proxy: tool_proxy) }
|
||||
let (:message_handler) { MessageHandler.create(message_type: 'message_type', launch_path:'https://samplelaunch/blti', resource: resource_handler)}
|
||||
let (:tool_proxy) { ToolProxy.create(
|
||||
shared_secret: 'shared_secret',
|
||||
guid: 'guid',
|
||||
product_version: '1.0beta',
|
||||
lti_version: 'LTI-2p0',
|
||||
product_family: product_family,
|
||||
context: account,
|
||||
workflow_state: 'active',
|
||||
raw_data: 'some raw data'
|
||||
) }
|
||||
subject{resource_handler.tool_links.create}
|
||||
|
||||
|
||||
describe '#create' do
|
||||
|
||||
it 'sets the uuid by default' do
|
||||
|
||||
link = resource_handler.tool_links.create
|
||||
link.uuid.should_not == nil
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
context 'tool_settings' do
|
||||
it 'can have a tool setting' do
|
||||
subject.create_tool_setting(custom: {name: :foo})
|
||||
subject.tool_setting[:custom].should == {name: :foo}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
|
@ -43,6 +43,31 @@ describe ToolProxyBinding do
|
|||
subject.errors.first.should == [:tool_proxy, "can't be blank"]
|
||||
end
|
||||
|
||||
context 'tool_settings' do
|
||||
let (:account) { Account.create }
|
||||
let (:product_family) { ProductFamily.create(vendor_code: '123', product_code: 'abc', vendor_name: 'acme', root_account: account) }
|
||||
let (:resource_handler) { ResourceHandler.create(resource_type_code: 'code', name: 'resource name', tool_proxy: tool_proxy) }
|
||||
let (:message_handler) { MessageHandler.create(message_type: 'message_type', launch_path:'https://samplelaunch/blti', resource: resource_handler)}
|
||||
let (:tool_proxy) { ToolProxy.create(
|
||||
shared_secret: 'shared_secret',
|
||||
guid: 'guid',
|
||||
product_version: '1.0beta',
|
||||
lti_version: 'LTI-2p0',
|
||||
product_family: product_family,
|
||||
context: account,
|
||||
workflow_state: 'active',
|
||||
raw_data: 'some raw data'
|
||||
) }
|
||||
subject{ tool_proxy.bindings.create(context:account)}
|
||||
|
||||
it 'can have a tool setting' do
|
||||
subject.create_tool_setting(custom: {name: :foo})
|
||||
subject.tool_setting[:custom].should == {name: :foo}
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
|||
|
||||
module Lti
|
||||
describe ToolProxy do
|
||||
let (:account) {Account.new}
|
||||
let (:account) {Account.create}
|
||||
let (:product_family) {ProductFamily.create(vendor_code: '123', product_code:'abc', vendor_name:'acme', root_account:account)}
|
||||
let (:resource_handler) {ResourceHandler.new}
|
||||
|
||||
|
@ -102,6 +102,24 @@ module Lti
|
|||
subject.errors[:raw_data].should include("can't be blank")
|
||||
end
|
||||
|
||||
context 'tool_settings' do
|
||||
subject { ToolProxy.create(
|
||||
shared_secret: 'shared_secret',
|
||||
guid: 'guid',
|
||||
product_version: '1.0beta',
|
||||
lti_version: 'LTI-2p0',
|
||||
product_family: product_family,
|
||||
context: account,
|
||||
workflow_state: 'active',
|
||||
raw_data: 'some raw data'
|
||||
) }
|
||||
it 'can have a tool setting' do
|
||||
subject.create_tool_setting(custom: {name: :foo})
|
||||
subject.tool_setting[:custom].should == {name: :foo}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#
|
||||
# Copyright (C) 2014 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 File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
|
||||
|
||||
module Lti
|
||||
describe ToolSetting do
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue