DEV: Use Discourse::SYSTEM_USER_ID in fixtures/009_users (#24743)

I couldn't find where we created the system user and
this is why -- everywhere else in the app we reference
SYSTEM_USER_ID but here.
This commit is contained in:
Martin Brennan 2023-12-07 09:04:45 +10:00 committed by GitHub
parent c197f8c6ee
commit 7afb5fc481
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 17 additions and 17 deletions

View File

@ -474,7 +474,7 @@ class Group < ActiveRecord::Base
group_users
.pluck(:user_id, :notification_level)
.each do |user_id, notification_level|
next if user_id == -1
next if user_id == Discourse::SYSTEM_USER_ID
next if user_id == topic.user_id
next if ignore_existing && TopicUser.where(user_id: user_id, topic_id: topic.id).exists?

View File

@ -2,7 +2,7 @@
# kind of odd, but we need it, we also need to nuke usage of User from inside migrations
# very poor form
user = User.find_by("id <> -1 and username_lower = 'system'")
user = User.find_by("id <> #{Discourse::SYSTEM_USER_ID} and username_lower = 'system'")
if user
user.username = UserNameSuggester.suggest("system")
user.save
@ -12,11 +12,11 @@ UserEmail.seed do |ue|
ue.id = -1
ue.email = "no_email"
ue.primary = true
ue.user_id = -1
ue.user_id = Discourse::SYSTEM_USER_ID
end
User.seed do |u|
u.id = -1
u.id = Discourse::SYSTEM_USER_ID
u.name = "system"
u.username = "system"
u.username_lower = "system"
@ -28,12 +28,12 @@ User.seed do |u|
u.trust_level = TrustLevel[4]
end
UserOption.where(user_id: -1).update_all(
UserOption.where(user_id: Discourse::SYSTEM_USER_ID).update_all(
email_messages_level: UserOption.email_level_types[:never],
email_level: UserOption.email_level_types[:never],
)
Group.user_trust_level_change!(-1, TrustLevel[4])
Group.user_trust_level_change!(Discourse::SYSTEM_USER_ID, TrustLevel[4])
# User for the smoke tests
if ENV["SMOKE"] == "1"

View File

@ -25,7 +25,7 @@ if !Theme.exists?
end
name = I18n.t("color_schemes.default_theme_name")
default_theme = Theme.create!(name: name, user_id: -1)
default_theme = Theme.create!(name: name, user_id: Discourse::SYSTEM_USER_ID)
default_theme.set_default!
if SiteSetting.default_dark_mode_color_scheme_id ==

View File

@ -516,7 +516,7 @@ class PresenceChannel
#{UPDATE_GLOBAL_CHANNELS_LUA}
-- Update the user session count in the channel hash
local val = redis.call('HINCRBY', hash_key, user_id, -1)
local val = redis.call('HINCRBY', hash_key, user_id, #{Discourse::SYSTEM_USER_ID})
if val <= 0 then
redis.call('HDEL', hash_key, user_id)
removed_users = 1
@ -607,7 +607,7 @@ class PresenceChannel
get_mutex()
end
local val = redis.call('HINCRBY', hash_key, user_id, -1)
local val = redis.call('HINCRBY', hash_key, user_id, #{Discourse::SYSTEM_USER_ID})
if val <= 0 then
table.insert(expired_user_ids, tonumber(user_id))
redis.call('HDEL', hash_key, user_id)

View File

@ -215,7 +215,7 @@ RSpec.describe ApplicationHelper do
dark_theme =
Theme.create(
name: "Dark",
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
color_scheme_id: ColorScheme.find_by(base_scheme_id: "Dark").id,
)
helper.request.env[:resolved_theme_id] = dark_theme.id
@ -275,7 +275,7 @@ RSpec.describe ApplicationHelper do
_dark_theme =
Theme.create(
name: "Dark",
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
color_scheme_id: ColorScheme.find_by(base_scheme_id: "Dark").id,
)
end
@ -300,7 +300,7 @@ RSpec.describe ApplicationHelper do
dark_theme =
Theme.create(
name: "Dark",
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
color_scheme_id: ColorScheme.find_by(base_scheme_id: "Dark").id,
)
helper.request.env[:resolved_theme_id] = dark_theme.id
@ -798,7 +798,7 @@ RSpec.describe ApplicationHelper do
dark_theme =
Theme.create(
name: "Dark",
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
color_scheme_id: ColorScheme.find_by(base_scheme_id: "Dark").id,
)
helper.request.env[:resolved_theme_id] = dark_theme.id

View File

@ -16,7 +16,7 @@ RSpec.describe Jobs::CorrectMissingDualstackUrls do
url: "//custom-bucket.s3-us-east-1.amazonaws.com/somewhere/a.png",
original_filename: "a.png",
filesize: 100,
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
)
bad_upload =
@ -24,7 +24,7 @@ RSpec.describe Jobs::CorrectMissingDualstackUrls do
url: "//custom-bucket.s3-us-west-1.amazonaws.com/somewhere/a.png",
original_filename: "a.png",
filesize: 100,
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
)
current_optimized =

View File

@ -1022,7 +1022,7 @@ RSpec.describe Category do
topic = Topic.find_by_id(post1.topic_id)
TopicTimer.create!(
user_id: -1,
user_id: Discourse::SYSTEM_USER_ID,
topic: topic,
execute_at: 1.hour.from_now,
status_type: TopicTimer.types[:bump],

View File

@ -1931,7 +1931,7 @@ RSpec.describe GroupsController do
end
it "returns skipped_usernames response body when removing a valid user but is not a member of that group" do
delete "/groups/#{group.id}/members.json", params: { user_id: -1 }
delete "/groups/#{group.id}/members.json", params: { user_id: Discourse::SYSTEM_USER_ID }
response_body = response.parsed_body
expect(response.status).to eq(200)