From 5af52334f6b76851a0b06fd863dab12b73e91470 Mon Sep 17 00:00:00 2001 From: Nathan Mills Date: Tue, 16 Sep 2014 13:59:23 -0600 Subject: [PATCH] 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 QA-Review: Clare Strong Reviewed-by: Bracken Mosbacker Product-Review: Bracken Mosbacker --- app/models/context_external_tool.rb | 8 ++++---- app/models/importers/context_external_tool_importer.rb | 1 + ...0916195352_add_external_tools_not_selectable_column.rb | 7 +++++++ lib/cc/importer/blti_converter.rb | 1 + spec/controllers/external_tools_controller_spec.rb | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20140916195352_add_external_tools_not_selectable_column.rb diff --git a/app/models/context_external_tool.rb b/app/models/context_external_tool.rb index b88d39d108f..d56139215e5 100644 --- a/app/models/context_external_tool.rb +++ b/app/models/context_external_tool.rb @@ -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 diff --git a/app/models/importers/context_external_tool_importer.rb b/app/models/importers/context_external_tool_importer.rb index d257a774cfa..5e8cd40dd28 100644 --- a/app/models/importers/context_external_tool_importer.rb +++ b/app/models/importers/context_external_tool_importer.rb @@ -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) diff --git a/db/migrate/20140916195352_add_external_tools_not_selectable_column.rb b/db/migrate/20140916195352_add_external_tools_not_selectable_column.rb new file mode 100644 index 00000000000..e4e7c1be829 --- /dev/null +++ b/db/migrate/20140916195352_add_external_tools_not_selectable_column.rb @@ -0,0 +1,7 @@ +class AddExternalToolsNotSelectableColumn < ActiveRecord::Migration + tag :predeploy + + def change + add_column :context_external_tools, :not_selectable, :boolean + end +end diff --git a/lib/cc/importer/blti_converter.rb b/lib/cc/importer/blti_converter.rb index d9cd605fa19..7c8e63a9e66 100644 --- a/lib/cc/importer/blti_converter.rb +++ b/lib/cc/importer/blti_converter.rb @@ -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' diff --git a/spec/controllers/external_tools_controller_spec.rb b/spec/controllers/external_tools_controller_spec.rb index 65ba0be50f0..8a9d0e5dc9b 100644 --- a/spec/controllers/external_tools_controller_spec.rb +++ b/spec/controllers/external_tools_controller_spec.rb @@ -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