mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Allow posts in any queue to support topic/post attributes
This commit is contained in:
parent
af1571a58f
commit
9ffec28076
3 changed files with 3 additions and 27 deletions
|
@ -7,21 +7,6 @@ class QueuedPost < ActiveRecord::Base
|
||||||
belongs_to :approved_by, class_name: "User"
|
belongs_to :approved_by, class_name: "User"
|
||||||
belongs_to :rejected_by, class_name: "User"
|
belongs_to :rejected_by, class_name: "User"
|
||||||
|
|
||||||
def self.attributes_by_queue
|
|
||||||
@attributes_by_queue ||= {
|
|
||||||
base: [:archetype,
|
|
||||||
:via_email,
|
|
||||||
:raw_email,
|
|
||||||
:auto_track,
|
|
||||||
:custom_fields,
|
|
||||||
:cooking_options,
|
|
||||||
:cook_method,
|
|
||||||
:image_sizes],
|
|
||||||
new_post: [:reply_to_post_number],
|
|
||||||
new_topic: [:title, :category, :meta_data, :archetype],
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.states
|
def self.states
|
||||||
@states ||= Enum.new(:new, :approved, :rejected)
|
@states ||= Enum.new(:new, :approved, :rejected)
|
||||||
end
|
end
|
||||||
|
@ -41,10 +26,9 @@ class QueuedPost < ActiveRecord::Base
|
||||||
|
|
||||||
def create_options
|
def create_options
|
||||||
opts = {raw: raw}
|
opts = {raw: raw}
|
||||||
post_attributes.each {|a| opts[a] = post_options[a.to_s] }
|
opts.merge!(post_options.symbolize_keys)
|
||||||
|
|
||||||
opts[:cooking_options].symbolize_keys! if opts[:cooking_options]
|
opts[:cooking_options].symbolize_keys! if opts[:cooking_options]
|
||||||
|
|
||||||
opts[:topic_id] = topic_id if topic_id
|
opts[:topic_id] = topic_id if topic_id
|
||||||
opts
|
opts
|
||||||
end
|
end
|
||||||
|
@ -60,16 +44,8 @@ class QueuedPost < ActiveRecord::Base
|
||||||
created_post
|
created_post
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all_attributes_for(queue)
|
|
||||||
[QueuedPost.attributes_by_queue[:base], QueuedPost.attributes_by_queue[queue.to_sym]].flatten.compact
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def post_attributes
|
|
||||||
QueuedPost.all_attributes_for(queue)
|
|
||||||
end
|
|
||||||
|
|
||||||
def change_to!(state, changed_by)
|
def change_to!(state, changed_by)
|
||||||
state_val = QueuedPost.states[state]
|
state_val = QueuedPost.states[state]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Fabricator(:queued_post) do
|
Fabricator(:queued_post) do
|
||||||
queue 'new_post'
|
queue 'test'
|
||||||
state QueuedPost.states[:new]
|
state QueuedPost.states[:new]
|
||||||
user
|
user
|
||||||
topic
|
topic
|
||||||
|
|
|
@ -63,7 +63,7 @@ describe QueuedPost do
|
||||||
|
|
||||||
context "with a valid topic" do
|
context "with a valid topic" do
|
||||||
let!(:category) { Fabricate(:category) }
|
let!(:category) { Fabricate(:category) }
|
||||||
let(:qp) { QueuedPost.create(queue: 'new_topic',
|
let(:qp) { QueuedPost.create(queue: 'eviltrout',
|
||||||
state: QueuedPost.states[:new],
|
state: QueuedPost.states[:new],
|
||||||
user_id: user.id,
|
user_id: user.id,
|
||||||
raw: 'This post should be queued up',
|
raw: 'This post should be queued up',
|
||||||
|
|
Loading…
Reference in a new issue