Allow staff_user_id to be modified (#9869)
This commit is contained in:
parent
7e3c4413e7
commit
83ab44c75b
5 changed files with 20 additions and 7 deletions
|
|
@ -97,6 +97,7 @@ module Admin
|
|||
community_member_label
|
||||
community_action
|
||||
community_copyright_start_year
|
||||
staff_user_id
|
||||
tagline
|
||||
]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ module Constants
|
|||
description: "Used to mark the year this forem was started.",
|
||||
placeholder: Time.zone.today.year.to_s
|
||||
},
|
||||
staff_user_id: {
|
||||
description: "Account ID which acts as automated 'staff'— used principally for welcome thread.",
|
||||
placeholder: ""
|
||||
},
|
||||
tagline: {
|
||||
description: "Used in signup modal.",
|
||||
placeholder: "We're a place where coders share, stay up-to-date and grow their careers."
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SiteConfig < RailsSettings::Base
|
|||
field :community_copyright_start_year, type: :integer,
|
||||
default: ApplicationConfig["COMMUNITY_COPYRIGHT_START_YEAR"] ||
|
||||
Time.zone.today.year
|
||||
field :staff_user_id, type: :integer, default: 1
|
||||
|
||||
# Emails
|
||||
field :email_addresses, type: :hash, default: {
|
||||
|
|
@ -115,7 +116,6 @@ class SiteConfig < RailsSettings::Base
|
|||
field :rate_limit_user_subscription_creation, type: :integer, default: 3
|
||||
|
||||
# Social Media
|
||||
field :staff_user_id, type: :integer, default: 1
|
||||
field :social_media_handles, type: :hash, default: {
|
||||
twitter: nil,
|
||||
facebook: nil,
|
||||
|
|
|
|||
|
|
@ -252,6 +252,15 @@
|
|||
placeholder: Constants::SiteConfig::DETAILS[:community_copyright_start_year][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:community_copyright_start_year][:description] %></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= admin_config_label :staff_user_id %>
|
||||
<%= f.text_field :staff_user_id,
|
||||
class: "form-control",
|
||||
value: SiteConfig.staff_user_id,
|
||||
placeholder: Constants::SiteConfig::DETAILS[:staff_user_id][:placeholder] %>
|
||||
<div class="alert alert-info"><%= Constants::SiteConfig::DETAILS[:staff_user_id][:description] %></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,11 @@ RSpec.describe "/admin/config", type: :request do
|
|||
post "/admin/config", params: { site_config: { tagline: description }, confirmation: confirmation_message }
|
||||
expect(SiteConfig.tagline).to eq(description)
|
||||
end
|
||||
|
||||
it "updates the staff_user_id" do
|
||||
post "/admin/config", params: { site_config: { staff_user_id: 22 }, confirmation: confirmation_message }
|
||||
expect(SiteConfig.staff_user_id).to eq(22)
|
||||
end
|
||||
end
|
||||
|
||||
describe "Emails" do
|
||||
|
|
@ -445,12 +450,6 @@ RSpec.describe "/admin/config", type: :request do
|
|||
end
|
||||
|
||||
describe "Social Media" do
|
||||
it "does not allow the staff_user_id to be updated" do
|
||||
expect(SiteConfig.staff_user_id).to eq(1)
|
||||
post "/admin/config", params: { site_config: { staff_user_id: 2 }, confirmation: confirmation_message }
|
||||
expect(SiteConfig.staff_user_id).to eq(1)
|
||||
end
|
||||
|
||||
it "updates social_media_handles" do
|
||||
expected_handle = { "facebook" => "tpd", "github" => "", "instagram" => "", "twitch" => "", "twitter" => "" }
|
||||
post "/admin/config", params: { site_config: { social_media_handles: expected_handle },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue