properly detect sessions plugin

fixes CORE-2320

check if it's enabled, not if it has (possibly inherited) settings

test plan:
 * have canvas auth, don't set up the sessions plugin
 * /login/canvas should have a remember me checkbox

Change-Id: Ia29d0f4a4cd7a8bd04f58ad331f01303f5aa8647
Reviewed-on: https://gerrit.instructure.com/180627
Tested-by: Jenkins
QA-Review: Tucker Mcknight <tmcknight@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
Reviewed-by: James Williams <jamesw@instructure.com>
This commit is contained in:
Cody Cutrer 2019-02-05 14:12:07 -07:00
parent 15d13bff49
commit 07125b3662
2 changed files with 9 additions and 12 deletions

View File

@ -18,7 +18,7 @@
module Login::CanvasHelper
def session_timeout_enabled?
PluginSetting.settings_for_plugin 'sessions'
PluginSetting.cached_plugin_setting('sessions')&.enabled?
end
def reg_link_data(auth_type)

View File

@ -20,22 +20,19 @@ require_relative '../../spec_helper'
describe Login::CanvasHelper do
describe "#session_timeout_enabled" do
context "when the sessions plugin is enabled" do
before do
expect(PluginSetting).to receive(:settings_for_plugin).with('sessions').and_return({"session_timeout" => 123})
end
context "when the sessions plugin is enabled" do
it "returns true" do
ps = PluginSetting.new
ps.name = 'sessions'
ps.disabled = false
ps.settings = {"session_timeout" => 123}
ps.save!
expect(helper.session_timeout_enabled?).to be_truthy
end
end
context "when the sessions plugin is disabled" do
before do
expect(PluginSetting).to receive(:settings_for_plugin).with('sessions').and_return(nil)
end
it "returns false" do
context "when the sessions plugin is disabled" do
it "returns false" do
expect(helper.session_timeout_enabled?).to be_falsey
end
end