mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
FIX: Do not allow invite_only
and enable_sso
at the same time
This functionality was never supported but before the new review queue it didn't have any errors. Now the combination of settings is prevented and existing sites with sso enabled will be migrated to remove invite only.
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe EnableInviteOnlyValidator do
|
||||
subject { described_class.new }
|
||||
|
||||
context "when sso is enabled" do
|
||||
before do
|
||||
SiteSetting.sso_url = "https://example.com/sso"
|
||||
SiteSetting.enable_sso = true
|
||||
end
|
||||
|
||||
it "is valid when false" do
|
||||
expect(subject.valid_value?('f')).to eq(true)
|
||||
end
|
||||
|
||||
it "is isn't value for true" do
|
||||
expect(subject.valid_value?('t')).to eq(false)
|
||||
expect(subject.error_message).to eq(I18n.t(
|
||||
'site_settings.errors.sso_invite_only'
|
||||
))
|
||||
end
|
||||
end
|
||||
|
||||
context "when sso isn't enabled" do
|
||||
it "is valid when true or false" do
|
||||
expect(subject.valid_value?('f')).to eq(true)
|
||||
expect(subject.valid_value?('t')).to eq(true)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -26,6 +26,24 @@ RSpec.describe EnableSsoValidator do
|
||||
end
|
||||
end
|
||||
|
||||
describe "when invite_only is set" do
|
||||
before do
|
||||
SiteSetting.invite_only = true
|
||||
SiteSetting.sso_url = 'https://example.com/sso'
|
||||
end
|
||||
|
||||
it 'allows a false value' do
|
||||
expect(subject.valid_value?('f')).to eq(true)
|
||||
end
|
||||
|
||||
it "doesn't allow true" do
|
||||
expect(subject.valid_value?('t')).to eq(false)
|
||||
expect(subject.error_message).to eq(I18n.t(
|
||||
'site_settings.errors.sso_invite_only'
|
||||
))
|
||||
end
|
||||
end
|
||||
|
||||
describe "when 'sso url' is present" do
|
||||
before do
|
||||
SiteSetting.sso_url = "https://www.example.com/sso"
|
||||
|
Reference in New Issue
Block a user