DEV: Replace #pluck_first monkey patch with native #pick (#467)

This commit is contained in:
Ted Johansson 2023-05-09 12:59:41 +08:00 committed by GitHub
parent d79fea7e4f
commit afb54c7c1e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -318,7 +318,7 @@ after_initialize do
end
user_id = topic_query.guardian.user.id if name == "me"
user_id ||= User.where(username_lower: name.downcase).pluck_first(:id)
user_id ||= User.where(username_lower: name.downcase).pick(:id)
if user_id
next(
@ -329,7 +329,7 @@ after_initialize do
)
end
group_id = Group.where(name: name.downcase).pluck_first(:id)
group_id = Group.where(name: name.downcase).pick(:id)
if group_id
next(

View File

@ -111,15 +111,15 @@ describe "integration tests" do
it "assigns topic" do
expect do DiscourseEvent.trigger(:assign_topic, topic, user1, admin) end.to change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
Assignment.where(topic: topic).pick(:assigned_to_id)
}.from(nil).to(user1.id)
expect do DiscourseEvent.trigger(:assign_topic, topic, user2, admin) end.to_not change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
Assignment.where(topic: topic).pick(:assigned_to_id)
}.from(user1.id)
expect do DiscourseEvent.trigger(:assign_topic, topic, user2, admin, true) end.to change {
Assignment.where(topic: topic).pluck_first(:assigned_to_id)
Assignment.where(topic: topic).pick(:assigned_to_id)
}.from(user1.id).to(user2.id)
end