make rcs enabled setting enable all risk levels
refs CORE-50 test plan: - in rails console run: Setting.set('rich_content_service_enabled', 'true') - start canvas (or restart if already running) - turn of the rcs feature flag if on - all editors should be using RCS Change-Id: I9912b14bc92182716921acf6a5c2ffa51e1d1e23 Reviewed-on: https://gerrit.instructure.com/148757 Tested-by: Jenkins Reviewed-by: Clay Diffrient <cdiffrient@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Brent Burgoyne <bburgoyne@instructure.com>
This commit is contained in:
parent
c6eee95d91
commit
d78e11064a
|
@ -66,10 +66,9 @@ module Services
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def contextually_on(root_account, risk_level)
|
def contextually_on(root_account, _risk_level)
|
||||||
enabled = Setting.get('rich_content_service_enabled', 'false') == 'true'
|
enabled = Setting.get('rich_content_service_enabled', 'false') == 'true'
|
||||||
low_risk = risk_level == :basic || risk_level == :sidebar
|
enabled || check_feature_flag(root_account, :rich_content_service_high_risk)
|
||||||
(enabled && low_risk) || check_feature_flag(root_account, :rich_content_service_high_risk)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,20 +23,23 @@ module Services
|
||||||
before do
|
before do
|
||||||
allow(Services::RichContent).to receive(:contextually_on).and_call_original
|
allow(Services::RichContent).to receive(:contextually_on).and_call_original
|
||||||
allow(Canvas::DynamicSettings).to receive(:find).with(any_args).and_call_original
|
allow(Canvas::DynamicSettings).to receive(:find).with(any_args).and_call_original
|
||||||
allow(Canvas::DynamicSettings).to receive(:find)
|
allow(Canvas::DynamicSettings).to receive(:find).
|
||||||
.with('rich-content-service', default_ttl: 5.minutes)
|
with('rich-content-service', default_ttl: 5.minutes).
|
||||||
.and_return({
|
and_return({
|
||||||
"app-host" => "rce-app",
|
"app-host" => "rce-app",
|
||||||
"cdn-host" => "rce-cdn"
|
"cdn-host" => "rce-cdn"
|
||||||
})
|
})
|
||||||
allow(Setting).to receive(:get)
|
allow(Setting).to receive(:get)
|
||||||
allow(Setting).to receive(:get)
|
allow(Setting).to receive(:get).
|
||||||
.with('rich_content_service_enabled', 'false')
|
with('rich_content_service_enabled', 'false').
|
||||||
.and_return('true')
|
and_return('true')
|
||||||
end
|
end
|
||||||
|
|
||||||
describe ".env_for" do
|
describe ".env_for" do
|
||||||
it "just returns disabled value if no root_account" do
|
it "just returns disabled value if no root_account" do
|
||||||
|
allow(Setting).to receive(:get).
|
||||||
|
with('rich_content_service_enabled', 'false').
|
||||||
|
and_return('false')
|
||||||
expect(described_class.env_for(nil)).to eq({
|
expect(described_class.env_for(nil)).to eq({
|
||||||
RICH_CONTENT_SERVICE_ENABLED: false
|
RICH_CONTENT_SERVICE_ENABLED: false
|
||||||
})
|
})
|
||||||
|
@ -50,9 +53,9 @@ module Services
|
||||||
end
|
end
|
||||||
|
|
||||||
it "populates hosts with an error signal when consul is down" do
|
it "populates hosts with an error signal when consul is down" do
|
||||||
allow(Canvas::DynamicSettings).to receive(:find)
|
allow(Canvas::DynamicSettings).to receive(:find).
|
||||||
.with('rich-content-service', default_ttl: 5.minutes)
|
with('rich-content-service', default_ttl: 5.minutes).
|
||||||
.and_raise(Imperium::UnableToConnectError, "can't talk to consul")
|
and_raise(Imperium::UnableToConnectError, "can't talk to consul")
|
||||||
root_account = double("root_account", feature_enabled?: true)
|
root_account = double("root_account", feature_enabled?: true)
|
||||||
env = described_class.env_for(root_account)
|
env = described_class.env_for(root_account)
|
||||||
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
||||||
|
@ -149,9 +152,14 @@ module Services
|
||||||
allow(root_account).to receive(:feature_enabled?).and_return(false)
|
allow(root_account).to receive(:feature_enabled?).and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is contextually off when no risk specified" do
|
it "is contextually on when no risk specified" do
|
||||||
env = described_class.env_for(root_account)
|
env = described_class.env_for(root_account)
|
||||||
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_falsey
|
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is contextually on for high risk areas" do
|
||||||
|
env = described_class.env_for(root_account, risk_level: :highrisk)
|
||||||
|
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is contextually on for low risk areas" do
|
it "is contextually on for low risk areas" do
|
||||||
|
@ -166,6 +174,9 @@ module Services
|
||||||
end
|
end
|
||||||
|
|
||||||
it "treats nil feature values as false" do
|
it "treats nil feature values as false" do
|
||||||
|
allow(Setting).to receive(:get).
|
||||||
|
with('rich_content_service_enabled', 'false').
|
||||||
|
and_return('false')
|
||||||
root_account = double("root_account")
|
root_account = double("root_account")
|
||||||
allow(root_account).to receive(:feature_enabled?).with(:rich_content_service_high_risk).and_return(nil)
|
allow(root_account).to receive(:feature_enabled?).with(:rich_content_service_high_risk).and_return(nil)
|
||||||
env = described_class.env_for(root_account)
|
env = described_class.env_for(root_account)
|
||||||
|
@ -194,19 +205,19 @@ module Services
|
||||||
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
it "off for high risk if flag is disabled" do
|
it "on for high risk if flag is disabled" do
|
||||||
account = account_model
|
account = account_model
|
||||||
account.disable_feature!(:rich_content_service_high_risk)
|
account.disable_feature!(:rich_content_service_high_risk)
|
||||||
env = described_class.env_for(account)
|
env = described_class.env_for(account)
|
||||||
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_falsey
|
expect(env[:RICH_CONTENT_SERVICE_ENABLED]).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "without rich_content_service_enabled setting true" do
|
context "without rich_content_service_enabled setting true" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
allow(Setting).to receive(:get)
|
allow(Setting).to receive(:get).
|
||||||
.with('rich_content_service_enabled', 'false')
|
with('rich_content_service_enabled', 'false').
|
||||||
.and_return(false)
|
and_return(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "on for all risk levels if feature flag is enabled" do
|
it "on for all risk levels if feature flag is enabled" do
|
||||||
|
|
Loading…
Reference in New Issue