mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 03:10:46 -06:00
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:
parent
f9ec2b90a0
commit
6c374cf158
@ -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!
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user