mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: show proper error message when no user selected for private message
This commit is contained in:
parent
24a49daa71
commit
53809d526c
3 changed files with 4 additions and 5 deletions
|
@ -13,7 +13,7 @@ module HasErrors
|
||||||
end
|
end
|
||||||
|
|
||||||
def rollback_with!(obj, error)
|
def rollback_with!(obj, error)
|
||||||
obj.errors[:base] << error
|
obj.errors.add(:base, error)
|
||||||
rollback_from_errors!(obj)
|
rollback_from_errors!(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -317,8 +317,7 @@ class PostCreator
|
||||||
topic_creator = TopicCreator.new(@user, guardian, @opts)
|
topic_creator = TopicCreator.new(@user, guardian, @opts)
|
||||||
@topic = topic_creator.create
|
@topic = topic_creator.create
|
||||||
rescue ActiveRecord::Rollback
|
rescue ActiveRecord::Rollback
|
||||||
add_errors_from(topic_creator)
|
rollback_from_errors!(topic_creator)
|
||||||
return
|
|
||||||
end
|
end
|
||||||
@post.topic_id = @topic.id
|
@post.topic_id = @topic.id
|
||||||
@post.topic = @topic
|
@post.topic = @topic
|
||||||
|
|
|
@ -45,10 +45,10 @@ describe HasErrors do
|
||||||
it "triggers a rollback" do
|
it "triggers a rollback" do
|
||||||
|
|
||||||
expect(-> {
|
expect(-> {
|
||||||
error_test.rollback_with!(invalid_topic, :custom_error)
|
error_test.rollback_with!(invalid_topic, :too_many_users)
|
||||||
}).to raise_error(ActiveRecord::Rollback)
|
}).to raise_error(ActiveRecord::Rollback)
|
||||||
expect(error_test.errors).to be_present
|
expect(error_test.errors).to be_present
|
||||||
expect(error_test.errors[:base]).to include(:custom_error)
|
expect(error_test.errors[:base]).to include("You can only send warnings to one user at a time.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue