From f600ead5874e3753b04b4e5a1b461197b030407b Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 21 Apr 2015 11:59:35 -0400 Subject: [PATCH] FIX: Don't validate approved posts. A moderator has already validated them. Otherwise we hit things like rate limits. --- app/models/queued_post.rb | 2 +- spec/models/queued_post_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/queued_post.rb b/app/models/queued_post.rb index 232d86e21..f93e7e8f1 100644 --- a/app/models/queued_post.rb +++ b/app/models/queued_post.rb @@ -51,7 +51,7 @@ class QueuedPost < ActiveRecord::Base QueuedPost.transaction do change_to!(:approved, approved_by) - creator = PostCreator.new(user, create_options) + creator = PostCreator.new(user, create_options.merge(skip_validations: true)) created_post = creator.create end created_post diff --git a/spec/models/queued_post_spec.rb b/spec/models/queued_post_spec.rb index bc1289b44..7ddeaed5b 100644 --- a/spec/models/queued_post_spec.rb +++ b/spec/models/queued_post_spec.rb @@ -41,7 +41,12 @@ describe QueuedPost do # We can't approve twice expect(-> { qp.approve!(admin) }).to raise_error(QueuedPost::InvalidStateTransition) + end + it "skips validations" do + qp.post_options[:title] = 'too short' + post = qp.approve!(admin) + expect(post).to be_present end it "follows the correct workflow for rejection" do