2021-06-01 16:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-07-27 22:27:38 -04:00
|
|
|
RSpec.describe TrustLevelSetting do
|
2021-06-01 16:11:48 -04:00
|
|
|
describe ".values" do
|
2021-06-07 23:13:38 -04:00
|
|
|
after { I18n.reload! }
|
|
|
|
|
2021-06-01 16:11:48 -04:00
|
|
|
it "returns translated names" do
|
|
|
|
TranslationOverride.upsert!(I18n.locale, "js.trust_levels.names.newuser", "New Member")
|
|
|
|
|
|
|
|
value = TrustLevelSetting.values.first
|
|
|
|
expect(value[:name]).to eq(
|
|
|
|
I18n.t("js.trust_levels.detailed_name", level: 0, name: "New Member"),
|
|
|
|
)
|
|
|
|
expect(value[:value]).to eq(0)
|
|
|
|
end
|
|
|
|
end
|
2024-01-03 01:55:28 -05:00
|
|
|
|
2024-01-03 06:32:26 -05:00
|
|
|
xdescribe ".valid_value?" do
|
2024-01-03 01:55:28 -05:00
|
|
|
let(:deprecated_test) { "#{Rails.root}/spec/fixtures/site_settings/deprecated_test.yml" }
|
|
|
|
|
|
|
|
before { SiteSetting.load_settings(deprecated_test) }
|
|
|
|
|
|
|
|
it "allows all trust levels as valid values" do
|
|
|
|
expect(TrustLevelSetting.valid_value?(TrustLevel[0])).to eq(true)
|
|
|
|
expect(TrustLevelSetting.valid_value?(TrustLevel[1])).to eq(true)
|
|
|
|
expect(TrustLevelSetting.valid_value?(TrustLevel[2])).to eq(true)
|
|
|
|
expect(TrustLevelSetting.valid_value?(TrustLevel[3])).to eq(true)
|
|
|
|
expect(TrustLevelSetting.valid_value?(TrustLevel[4])).to eq(true)
|
|
|
|
expect(TrustLevelSetting.valid_value?(20)).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow 'admin' or 'staff' as valid values" do
|
|
|
|
expect(TrustLevelSetting.valid_value?("admin")).to eq(false)
|
|
|
|
expect(TrustLevelSetting.valid_value?("staff")).to eq(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not allow setting 'admin' or 'staff' as valid values" do
|
|
|
|
expect { SiteSetting.min_trust_level_to_allow_invite = "admin" }.to raise_error(
|
|
|
|
Discourse::InvalidParameters,
|
|
|
|
)
|
|
|
|
expect { SiteSetting.min_trust_level_to_allow_invite = "staff" }.to raise_error(
|
|
|
|
Discourse::InvalidParameters,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2021-06-01 16:11:48 -04:00
|
|
|
end
|