mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: Regression where a topic rollback would not properly report errors to the client.
This commit is contained in:
parent
3ae72259a6
commit
1b5ec42173
2 changed files with 21 additions and 2 deletions
|
@ -131,8 +131,15 @@ class PostCreator
|
|||
def setup_topic
|
||||
if @opts[:topic_id].blank?
|
||||
topic_creator = TopicCreator.new(@user, guardian, @opts)
|
||||
topic = topic_creator.create
|
||||
@errors = topic_creator.errors
|
||||
|
||||
begin
|
||||
topic = topic_creator.create
|
||||
@errors = topic_creator.errors
|
||||
rescue ActiveRecord::Rollback => ex
|
||||
# In the event of a rollback, grab the errors from the topic
|
||||
@errors = topic_creator.errors
|
||||
raise ex
|
||||
end
|
||||
|
||||
@new_topic = true
|
||||
else
|
||||
|
|
|
@ -26,6 +26,18 @@ describe PostCreator do
|
|||
lambda { creator.create }.should raise_error(Discourse::InvalidAccess)
|
||||
end
|
||||
|
||||
|
||||
context "invalid title" do
|
||||
|
||||
let(:creator_invalid_title) { PostCreator.new(user, basic_topic_params.merge(title: 'a')) }
|
||||
|
||||
it "has errors" do
|
||||
creator_invalid_title.create
|
||||
expect(creator_invalid_title.errors).to be_present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'success' do
|
||||
|
||||
it "doesn't return true for spam" do
|
||||
|
|
Loading…
Reference in a new issue