FIX: Account for moderators in group to TL mapping (#25326)
If configuring only moderators in a group based access setting, the mapping to the old setting wouldn't work correctly, because the case was unaccounted for. This PR accounts for moderators group when doing the mapping.
This commit is contained in:
parent
561851b104
commit
46f1c209be
|
@ -3029,6 +3029,7 @@ tags:
|
||||||
client: true
|
client: true
|
||||||
min_trust_to_create_tag:
|
min_trust_to_create_tag:
|
||||||
default: "3"
|
default: "3"
|
||||||
|
type: enum
|
||||||
enum: "TrustLevelAndStaffSetting"
|
enum: "TrustLevelAndStaffSetting"
|
||||||
hidden: true
|
hidden: true
|
||||||
create_tag_allowed_groups:
|
create_tag_allowed_groups:
|
||||||
|
|
|
@ -77,13 +77,16 @@ module SiteSettings::DeprecatedSettings
|
||||||
|
|
||||||
if tl_and_staff
|
if tl_and_staff
|
||||||
valid_auto_groups_excluding_staff_and_admins =
|
valid_auto_groups_excluding_staff_and_admins =
|
||||||
valid_auto_groups - [Group::AUTO_GROUPS[:staff], Group::AUTO_GROUPS[:admins]]
|
valid_auto_groups -
|
||||||
|
[Group::AUTO_GROUPS[:staff], Group::AUTO_GROUPS[:admins], Group::AUTO_GROUPS[:moderators]]
|
||||||
|
|
||||||
if valid_auto_groups_excluding_staff_and_admins.any?
|
if valid_auto_groups_excluding_staff_and_admins.any?
|
||||||
return valid_auto_groups_excluding_staff_and_admins.min - Group::AUTO_GROUPS[:trust_level_0]
|
return valid_auto_groups_excluding_staff_and_admins.min - Group::AUTO_GROUPS[:trust_level_0]
|
||||||
end
|
end
|
||||||
|
|
||||||
if valid_auto_groups.include?(Group::AUTO_GROUPS[:staff])
|
if valid_auto_groups.include?(Group::AUTO_GROUPS[:moderators])
|
||||||
|
"moderator"
|
||||||
|
elsif valid_auto_groups.include?(Group::AUTO_GROUPS[:staff])
|
||||||
"staff"
|
"staff"
|
||||||
elsif valid_auto_groups.include?(Group::AUTO_GROUPS[:admins])
|
elsif valid_auto_groups.include?(Group::AUTO_GROUPS[:admins])
|
||||||
"admin"
|
"admin"
|
||||||
|
|
|
@ -152,6 +152,11 @@ RSpec.xdescribe SiteSettings::DeprecatedSettings do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns moderator if there is only the moderators auto group in the new group setting" do
|
||||||
|
SiteSetting.invite_allowed_groups = "#{Group::AUTO_GROUPS[:moderators]}"
|
||||||
|
expect(SiteSetting.min_trust_level_to_allow_invite_tl_and_staff).to eq("moderator")
|
||||||
|
end
|
||||||
|
|
||||||
it "returns staff if there are staff and admin auto groups in the new group setting" do
|
it "returns staff if there are staff and admin auto groups in the new group setting" do
|
||||||
SiteSetting.invite_allowed_groups =
|
SiteSetting.invite_allowed_groups =
|
||||||
"#{Group::AUTO_GROUPS[:admins]}|#{Group::AUTO_GROUPS[:staff]}"
|
"#{Group::AUTO_GROUPS[:admins]}|#{Group::AUTO_GROUPS[:staff]}"
|
||||||
|
|
Loading…
Reference in New Issue