DEV: Improve ArgumenError raised in PostOwnerChanger. (#15907)

Currently, it doesn't provide any context about the arguement which
caused the error.
This commit is contained in:
Alan Guo Xiang Tan
2022-02-16 12:52:20 +11:00
committed by GitHub
parent f9ec2b90a0
commit 6c374cf158
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -9,7 +9,9 @@ class PostOwnerChanger
@acting_user = params[:acting_user]
@skip_revision = params[:skip_revision] || false
raise ArgumentError unless @post_ids && @topic && @new_owner && @acting_user
[:post_ids, :topic, :new_owner, :acting_user].each do |arg|
raise ArgumentError.new(arg) if self.instance_variable_get("@#{arg}").blank?
end
end
def change_owner!
+1 -1
View File
@@ -14,7 +14,7 @@ describe PostOwnerChanger do
it "raises an error with a parameter missing" do
expect {
PostOwnerChanger.new(post_ids: [p1.id], topic_id: topic.id, new_owner: nil, acting_user: editor)
}.to raise_error(ArgumentError)
}.to raise_error(ArgumentError, /new_owner/)
end
it "calls PostRevisor" do