move not_selected from external tools settings to it's own column

fixes: PLAT-646

Test Plan:
 * Install an external tool with the property "not_selectable" as true
 * when you look in the asmnt/module item external tool list the tool
   should not be listed

Change-Id: If66e09b83373fad83274d0120cb464e7caf60c83
Reviewed-on: https://gerrit.instructure.com/41205
Tested-by: Jenkins <jenkins@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
Product-Review: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
Nathan Mills 2014-09-16 13:59:23 -06:00 committed by Bracken Mosbacker
parent 1e59852498
commit 5af52334f6
5 changed files with 14 additions and 5 deletions

View File

@ -267,12 +267,12 @@ class ContextExternalTool < ActiveRecord::Base
settings[:text]
end
def not_selectable=(bool)
settings[:not_selectable] = Canvas::Plugin.value_to_boolean(bool)
def not_selectable
!!read_attribute(:not_selectable)
end
def not_selectable
settings[:not_selectable]
def not_selectable=(bool)
write_attribute(:not_selectable, Canvas::Plugin.value_to_boolean(bool))
end
def selectable

View File

@ -40,6 +40,7 @@ module Importers
end
item.domain = hash[:domain] unless hash[:domain].blank?
item.privacy_level = hash[:privacy_level] || 'name_only'
item.not_selectable = hash[:not_selectable] if hash[:not_selectable]
item.consumer_key ||= hash[:consumer_key] || 'fake'
item.shared_secret ||= hash[:shared_secret] || 'fake'
item.settings = create_tool_settings(hash)

View File

@ -0,0 +1,7 @@
class AddExternalToolsNotSelectableColumn < ActiveRecord::Migration
tag :predeploy
def change
add_column :context_external_tools, :not_selectable, :boolean
end
end

View File

@ -80,6 +80,7 @@ module CC::Importer
if ext[:platform] == CANVAS_PLATFORM
tool[:privacy_level] = ext[:custom_fields].delete 'privacy_level'
tool[:not_selectable] = ext[:custom_fields].delete 'not_selectable'
tool[:domain] = ext[:custom_fields].delete 'domain'
tool[:consumer_key] = ext[:custom_fields].delete 'consumer_key'
tool[:shared_secret] = ext[:custom_fields].delete 'shared_secret'

View File

@ -417,7 +417,7 @@ describe ExternalToolsController do
assigns[:tool].url.should == "http://example.com/other_url"
assigns[:tool].consumer_key.should == "key"
assigns[:tool].shared_secret.should == "secret"
assigns[:tool].not_selectable.should == "true"
assigns[:tool].not_selectable.should be_truthy
assigns[:tool].has_placement?(:editor_button).should be_true
end